Example #1
0
 /**
  * test collectValidationErrors() method
  *
  * @test
  */
 public function collectValidationErrors()
 {
     $this->generateComponent();
     $model1 = $this->getMockBuilder('Model')->setConstructorArgs([['alias' => 'Model1', 'table' => false]])->getMock();
     $model2 = $this->getMockBuilder('Model')->setConstructorArgs([['alias' => 'Model2', 'table' => false]])->getMock();
     $model1->Model2 = $model2;
     $model1->validationErrors = ['name' => ['maxLength']];
     $model2->validationErrors = ['number' => ['numeric']];
     $model1->validationErrors['Model2'] = $model2->validationErrors;
     $result = $this->Api->collectValidationErrors('Model1');
     $this->assertSame(['Model1' => ['name' => ['maxLength']], 'Model2' => ['number' => ['numeric']]], $result);
 }