/** * 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; }
/** * Test * * @return void */ public function testFromArray() { $this->assertInstanceOf('Gc\\User\\Role\\Model', Model::fromArray($this->object->getData())); }
/** * 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(); }