Esempio n. 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());
 }
Esempio n. 2
0
 /**
  * @covers ::getErrors
  * @covers ::isEmptyErrors
  * @covers ::validate
  */
 public function testTrait()
 {
     $model = new Model();
     $errors = $model->getErrors();
     $this->assertInstanceOf('Harp\\Validate\\Errors', $errors);
     $this->assertTrue($errors->isEmpty());
     $this->assertTrue($model->isEmptyErrors());
     $model->validate();
     $errors = $model->getErrors();
     $this->assertInstanceOf('Harp\\Validate\\Errors', $errors);
     $this->assertFalse($errors->isEmpty());
     $this->assertCount(1, $errors);
     $this->assertFalse($model->isEmptyErrors());
     $this->assertEquals(new Error(new Present('test')), $errors->getFirst());
     $this->setExpectedException('Harp\\Validate\\InvalidException', 'Has errors: test must be present');
     $model->assertValid();
 }