function it_should_allow_to_check_logical_or(Rule $left, Rule $right) { $left->check(null)->shouldBeCalled()->willReturn(false); $right->check(null)->shouldBeCalled()->willReturn(true); $this->setLeft($left); $this->setRight($right); $this->check(null)->shouldReturn(true); }
function it_should_allow_to_build_a_rule(Library $ruleLibrary, Library $assertionLibrary, Rule $rule, Rule $left, Rule $right, Assertion $assertion) { $data = ['name' => 'test', 'left' => ['name' => 'left', 'assertion' => ['name' => 'test']], 'right' => ['name' => 'right'], 'parameter' => 1]; $left->implement('Indigo\\Ruler\\Builder\\HasAssertion'); $left->beADoubleOf('Indigo\\Ruler\\Stub\\Builder\\AssertionAware'); $left->setAssertion(Argument::type('Indigo\\Ruler\\Assertion'))->will(function ($args) use($left) { $left->getAssertion()->willReturn($args[0]); }); $rule->implement('Indigo\\Ruler\\Builder\\HasParameter'); $rule->beADoubleOf('Indigo\\Ruler\\Stub\\Builder\\ParameterAware'); $rule->beADoubleOf('Indigo\\Ruler\\Rule\\Logical'); $rule->setLeft($left)->shouldBeCalled(); $rule->setRight($right)->shouldBeCalled(); $rule->setParameter(1)->shouldBeCalled(); $ruleLibrary->getInstance('test')->willReturn($rule); $ruleLibrary->getInstance('left')->willReturn($left); $ruleLibrary->getInstance('right')->willReturn($right); $assertionLibrary->getInstance('test')->willReturn($assertion); $this->setRuleLibrary($ruleLibrary); $this->setAssertionLibrary($assertionLibrary); $rule = $this->buildRule($data); $rule->shouldHaveType('Indigo\\Ruler\\Rule'); }
function it_should_allow_to_be_valid(Rule $rule) { $rule->check(1)->shouldBeCalled()->willReturn(true); $this->setRule($rule); $this->isValid(1)->shouldReturn(true); }