ElggSiteTest.php 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. <?php
  2. /**
  3. * Elgg Test \ElggSite
  4. *
  5. * @package Elgg
  6. * @subpackage Test
  7. */
  8. class ElggCoreSiteTest extends \ElggCoreUnitTest {
  9. /**
  10. * @var \ElggSite
  11. */
  12. public $site;
  13. /**
  14. * Called before each test object.
  15. */
  16. public function __construct() {
  17. parent::__construct();
  18. }
  19. /**
  20. * Called before each test method.
  21. */
  22. public function setUp() {
  23. $this->site = new \ElggSiteTest();
  24. }
  25. /**
  26. * Called after each test method.
  27. */
  28. public function tearDown() {
  29. unset($this->site);
  30. }
  31. /**
  32. * Called after each test object.
  33. */
  34. public function __destruct() {
  35. parent::__destruct();
  36. }
  37. public function testElggSiteConstructor() {
  38. $attributes = array();
  39. $attributes['guid'] = null;
  40. $attributes['type'] = 'site';
  41. $attributes['subtype'] = null;
  42. $attributes['owner_guid'] = elgg_get_logged_in_user_guid();
  43. $attributes['container_guid'] = elgg_get_logged_in_user_guid();
  44. $attributes['site_guid'] = null;
  45. $attributes['access_id'] = ACCESS_PRIVATE;
  46. $attributes['time_created'] = null;
  47. $attributes['time_updated'] = null;
  48. $attributes['last_action'] = null;
  49. $attributes['enabled'] = 'yes';
  50. $attributes['name'] = null;
  51. $attributes['description'] = null;
  52. $attributes['url'] = null;
  53. ksort($attributes);
  54. $entity_attributes = $this->site->expose_attributes();
  55. ksort($entity_attributes);
  56. $this->assertIdentical($entity_attributes, $attributes);
  57. }
  58. public function testElggSiteSaveAndDelete() {
  59. $guid = $this->site->save();
  60. $this->assertIsA($guid, 'int');
  61. $this->assertTrue($guid > 0);
  62. $this->assertIdentical(true, $this->site->delete());
  63. }
  64. public function testElggSiteGetUrl() {
  65. $this->site->url = 'http://example.com/';
  66. $this->assertIdentical($this->site->getURL(), 'http://example.com/');
  67. }
  68. }
  69. class ElggSiteTest extends \ElggSite {
  70. public function expose_attributes() {
  71. return $this->attributes;
  72. }
  73. }