コード例 #1
0
 /**
  * @covers ::__construct
  * @covers ::getSubject
  * @covers ::getErrors
  */
 public function testSubject()
 {
     $previous = new Exception();
     $model = new Model();
     $this->assertFalse($model->validate());
     $exception = new InvalidException($model, $model->getErrors(), 123, $previous);
     $this->assertSame($previous, $exception->getPrevious());
     $this->assertSame(123, $exception->getCode());
     $this->assertSame($model, $exception->getSubject());
     $this->assertSame($model->getErrors(), $exception->getErrors());
 }
コード例 #2
0
ファイル: ValidateTraitTest.php プロジェクト: clippings/carpo
 /**
  * @covers ::assertValid
  */
 public function testAssertValid()
 {
     $model = new Model();
     $model->test = '!!!!';
     $model->assertValid();
     $model->test = null;
     try {
         $model->assertValid();
         $this->fail('Should Throw an exception');
     } catch (InvalidException $exception) {
         $this->assertEquals('Has errors: test must be present', $exception->getMessage());
         $this->assertSame($model, $exception->getSubject());
     }
 }