Пример #1
0
 /**
  * @dataProvider compileDataProvider
  */
 public function testCompile($message, $expected)
 {
     if ($message !== null) {
         $this->condition->setMessage($message);
     }
     $actual = $this->condition->compile('$factory');
     $this->assertEquals($expected, $actual);
 }
Пример #2
0
 public function testEvaluateWithErrors()
 {
     $currentConditionError = 'Current condition error';
     $nestedConditionError = 'Nested condition error';
     $this->condition->setMessage($currentConditionError);
     $falseConditionWithError = new Condition\False();
     $falseConditionWithError->setMessage($nestedConditionError);
     $errors = new ArrayCollection();
     $this->condition->initialize([$falseConditionWithError]);
     $this->assertTrue($this->condition->evaluate('anything', $errors));
     $this->assertCount(1, $errors);
     $this->assertEquals(['message' => $nestedConditionError, 'parameters' => []], $errors->get(0));
     $trueConditionWithError = new Condition\True();
     $trueConditionWithError->setMessage($nestedConditionError);
     $errors = new ArrayCollection();
     $this->condition->initialize([$trueConditionWithError]);
     $this->assertFalse($this->condition->evaluate('anything', $errors));
     $this->assertCount(1, $errors);
     $this->assertEquals(['message' => $currentConditionError, 'parameters' => []], $errors->get(0));
 }