ElggCommentTest.php 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. <?php
  2. /**
  3. * Elgg Test \ElggComment
  4. *
  5. * @package Elgg
  6. * @subpackage Test
  7. */
  8. class ElggCoreCommentTest extends \ElggCoreUnitTest {
  9. /**
  10. * @var \ElggComment
  11. */
  12. protected $comment;
  13. /**
  14. * @var \ElggObject
  15. */
  16. protected $container;
  17. /**
  18. * Called before each test method.
  19. */
  20. public function setUp() {
  21. $this->container = new \ElggObject();
  22. $this->container->access_id = ACCESS_PUBLIC;
  23. $this->container->save();
  24. $this->comment = new \ElggComment();
  25. $this->comment->description = 'comment description';
  26. $this->comment->container_guid = $this->container->guid;
  27. $this->comment->access_id = $this->container->access_id;
  28. $this->comment->save();
  29. }
  30. public function testCommentAccessSync() {
  31. _elgg_disable_caching_for_entity($this->comment->guid);
  32. _elgg_disable_caching_for_entity($this->container->guid);
  33. $this->assertEqual($this->comment->access_id, $this->container->access_id);
  34. // now change the access of the container
  35. $this->container->access_id = ACCESS_LOGGED_IN;
  36. $this->container->save();
  37. $updated_container = get_entity($this->container->guid);
  38. $updated_comment = get_entity($this->comment->guid);
  39. $this->assertEqual($updated_comment->access_id, $updated_container->access_id);
  40. }
  41. /**
  42. * Called after each test method.
  43. */
  44. public function tearDown() {
  45. $this->container->delete();
  46. $this->comment->delete();
  47. }
  48. }