Example #1
0
 /**
  * @testdox      isValid() returns true only if an email is set and the privacy policy is accepted. In any other case, it sets the appropriate error messages.
  * @dataProvider provideIsValidTestData
  *
  * @param ApplicationInterface $value
  * @param bool                 $expectedResult
  * @param null|string          $expectedErrorKey
  */
 public function testIsValidReturnsOnlyTrueIfEmailAndPrivacyPolicyIsSet($value, $expectedResult, $expectedErrorKey = null)
 {
     $expectedErrors = array();
     if (null !== $expectedErrorKey) {
         $expectedErrorKey = explode(',', $expectedErrorKey);
         foreach ($expectedErrorKey as $key) {
             $expectedErrors[$key] = null;
         }
     }
     $assertMethod = 'assert' . ($expectedResult ? 'True' : 'False');
     $this->{$assertMethod}($this->target->isValid($value));
     $this->assertEquals($expectedErrors, $this->target->getOption('messages'));
 }