Пример #1
0
 public function testToArray()
 {
     $model = new FileModel();
     $result = $model->toArray();
     $attributes = ['Id' => 111, 'Name' => 'Имя'];
     $model->setAttributes($attributes);
     $reflectionClass = new ReflectionClass('FileModel');
     $properties = $reflectionClass->getProperties();
     /**
      * @var $property ReflectionProperty
      */
     foreach ($properties as $property) {
         $name = $property->getName();
         $value = $model->{$name};
         if (array_key_exists($name, $attributes)) {
             $this->assertEquals($attributes[$name], $value);
         } else {
             $this->assertNotContains($name, $result);
         }
     }
 }