/**
  * @test
  */
 public function notifiesObserversOfNewlyAddedRules()
 {
     $mockObserver = $this->getMock('PHPAccessControl\\Rule\\RuleListObserver');
     $mockObserver->expects($this->once())->method('notifyRuleAdded')->with($this->equalTo(CreateRule::allow(Situation::UserViewPost())));
     $this->ruleList->addObserver($mockObserver);
     $this->ruleList->addRule(CreateRule::allow(Situation::UserViewPost()));
 }
 /**
  * @test
  */
 public function mostSpecificMatchingRulesAreTheOnesWithMoreGeneralSituationIfNoneWithSameSituation()
 {
     // given
     $rule = CreateRule::allow(Situation::UserViewPost());
     $this->ruleList->addRule($rule);
     // when
     $mostSpecificMatchingRules = $this->ruleFinder->findMostSpecificMatchingRulesFor(Situation::UserViewPostWithCategoryIdEquals5());
     // then
     $this->assertEquals(array($rule), $mostSpecificMatchingRules);
 }
 /**
  * @test
  */
 public function allowedWinsFromDenied()
 {
     $this->rules->addRule(CreateRule::deny(Situation::userViewPost()));
     $this->rules->addRule(CreateRule::allow(Situation::userViewPost()));
     $this->assertTrue($this->permissionResolver->isAllowedByInheritance(Situation::userViewPost()));
 }