AnonymousTest.php 3.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. <?php
  2. namespace Muzich\CoreBundle\Tests\Controller;
  3. use Muzich\CoreBundle\lib\FunctionalTest;
  4. use Muzich\CoreBundle\Tests\lib\Security\Context as SecurityContextTest;
  5. use Muzich\CoreBundle\Security\Context as SecurityContext;
  6. class NoPassTest extends FunctionalTest
  7. {
  8. protected $security_context_test;
  9. protected function init()
  10. {
  11. $this->client = self::createClient();
  12. $this->security_context_test = new SecurityContextTest($this->client, $this);
  13. }
  14. public function testLimitedActionsForAnonymous()
  15. {
  16. $this->init();
  17. $this->checkUserIsAnonymous();
  18. $this->checkUserCantMakeProhibedActionsForAnonymous();
  19. $this->registerUser('dijarr@mail.com');
  20. $this->checkUserIsNotProhibedForAnonymousActions();
  21. }
  22. protected function checkUserIsAnonymous()
  23. {
  24. $this->assertEquals('anon.', $this->getUser());
  25. }
  26. protected function checkUserCantMakeProhibedActionsForAnonymous()
  27. {
  28. $this->checkUserProhibedActionStatus(true);
  29. }
  30. protected function checkUserProhibedActionStatus($match)
  31. {
  32. $this->security_context_test->testUserCantMakeActionStatus(
  33. SecurityContext::ACTION_ELEMENT_ADD,
  34. SecurityContext::CONDITION_USER_NOT_CONNECTED,
  35. $match
  36. );
  37. $this->security_context_test->testUserCantMakeActionStatus(
  38. SecurityContext::ACTION_ELEMENT_NOTE,
  39. SecurityContext::CONDITION_USER_NOT_CONNECTED,
  40. $match
  41. );
  42. $this->security_context_test->testUserCantMakeActionStatus(
  43. SecurityContext::ACTION_COMMENT_ALERT,
  44. SecurityContext::CONDITION_USER_NOT_CONNECTED,
  45. $match
  46. );
  47. $this->security_context_test->testUserCantMakeActionStatus(
  48. SecurityContext::ACTION_ELEMENT_ALERT,
  49. SecurityContext::CONDITION_USER_NOT_CONNECTED,
  50. $match
  51. );
  52. $this->security_context_test->testUserCantMakeActionStatus(
  53. SecurityContext::ACTION_TAG_ADD,
  54. SecurityContext::CONDITION_USER_NOT_CONNECTED,
  55. $match
  56. );
  57. $this->security_context_test->testUserCantMakeActionStatus(
  58. SecurityContext::ACTION_ELEMENT_TAGS_PROPOSITION,
  59. SecurityContext::CONDITION_USER_NOT_CONNECTED,
  60. $match
  61. );
  62. $this->security_context_test->testUserCantMakeActionStatus(
  63. SecurityContext::ACTION_GROUP_ADD,
  64. SecurityContext::CONDITION_USER_NOT_CONNECTED,
  65. $match
  66. );
  67. $this->security_context_test->testUserCantMakeActionStatus(
  68. SecurityContext::ACTION_ELEMENT_ADD_TO_FAVORITES,
  69. SecurityContext::CONDITION_USER_NOT_CONNECTED,
  70. $match
  71. );
  72. $this->security_context_test->testUserCantMakeActionStatus(
  73. SecurityContext::ACTION_COMMENT_ADD,
  74. SecurityContext::CONDITION_USER_NOT_CONNECTED,
  75. $match
  76. );
  77. $this->security_context_test->testUserCantMakeActionStatus(
  78. SecurityContext::ACTION_USER_FOLLOW,
  79. SecurityContext::CONDITION_USER_NOT_CONNECTED,
  80. $match
  81. );
  82. }
  83. protected function registerUser($email)
  84. {
  85. $this->procedure_registration_success($email);
  86. }
  87. protected function checkUserIsNotProhibedForAnonymousActions()
  88. {
  89. $this->checkUserProhibedActionStatus(false);
  90. }
  91. }