fromArray() public static method

Initiliaze from array
public static fromArray ( array $array ) : Model
$array array Data
return Model
Beispiel #1
0
 /**
  * Get Roles
  *
  * @param boolean $forceReload Force reload
  *
  * @return array \Gc\User\Role\Model
  */
 public function getRoles($forceReload = false)
 {
     if (empty($this->roles) or $forceReload === true) {
         $rows = $this->fetchAll($this->select(function (Select $select) {
             $select->order('name');
         }));
         $roles = array();
         foreach ($rows as $row) {
             $roles[] = Model::fromArray((array) $row);
         }
         $this->roles = $roles;
     }
     return $this->roles;
 }
Beispiel #2
0
 /**
  * Test
  *
  * @return void
  */
 public function testFromArray()
 {
     $this->assertInstanceOf('Gc\\User\\Role\\Model', Model::fromArray($this->object->getData()));
 }
Beispiel #3
0
 /**
  * Test
  *
  * @return void
  */
 public function testEditActionWithWrongPostData()
 {
     $roleModel = RoleModel::fromArray(array('name' => 'RoleTest', 'description' => 'Description'));
     $roleModel->save();
     $this->dispatch('/admin/config/user/role/edit/' . $roleModel->getId(), 'POST', array());
     $this->assertResponseStatusCode(200);
     $this->assertModuleName('GcConfig');
     $this->assertControllerName('RoleController');
     $this->assertControllerClass('RoleController');
     $this->assertMatchedRouteName('config/user/role/edit');
     $roleModel->delete();
 }