Exemplo n.º 1
0
 /**
  * Sets up the fixture, for example, open a network connection.
  * This method is called before a test is executed.
  */
 protected function setUp()
 {
     parent::setUp();
     $this->connection = Connection::get();
     $this->roleBook = new RoleBook($this->connection);
     for ($k = 0; $k < 10; $k++) {
         $role = new Role();
         $role->setName(RandomBook::getRandomString());
         $this->roleList[] = $role;
     }
 }
Exemplo n.º 2
0
 /**
  * @param int|null $userId
  * @return array
  * @throws \Exception
  */
 public function get($userId = null)
 {
     MDataType::mustBeNullableInt($userId);
     $toReturn = array();
     $sql = "CALL mt_role_get(?);";
     $query = new MPDOQuery($sql, $this->connection);
     $query->bindValue($userId);
     $queryResult = $query->exec();
     if ($queryResult == false || $query->getResult()->rowCount() <= 0) {
         return $toReturn;
     }
     foreach ($query->getResult() as $row) {
         $role = new Role();
         $role->setId($row['id'])->setName($row['name']);
         $toReturn[] = $role;
     }
     return $toReturn;
 }