示例#1
0
 /**
  * @param string|null $typename
  */
 public static function setDefaultTypename($typename)
 {
     if (null !== $typename && !is_string($typename)) {
         $message = 'Invalid type for $typename: ' . Robo47_Core::getType($typename);
         throw new Robo47_Doctrine_Hydrator_Exception($message);
     }
     self::$_typename = $typename;
 }
示例#2
0
 /**
  * @covers Robo47_Core::getType
  * @dataProvider typeProvider
  */
 public function testGetType($var, $expectedType)
 {
     $this->assertEquals($expectedType, Robo47_Core::getType($var));
 }
 /**
  * @covers Robo47_Doctrine_Hydrator_PopoDriver::setDefaultContainerClassname
  * @covers Robo47_Doctrine_Hydrator_Exception
  */
 public function testsetDefaultContainerClassnameThrowsExceptionWithClassWhichNotImplementsArrayAccess()
 {
     $classname = 'stdClass';
     try {
         Robo47_Doctrine_Hydrator_PopoDriver::setDefaultContainerClassname($classname);
         $this->fail('No Exception thrown');
     } catch (Robo47_Doctrine_Hydrator_Exception $e) {
         $this->assertEquals('Type does not implement ArrayAccess: ' . Robo47_Core::getType(new stdClass()), $e->getMessage(), 'Wrong Exception message');
     }
 }
 /**
  * Returns an collection of items for a page.
  *
  * @param  integer $offset Page offset
  * @param  integer $itemCountPerPage Number of items per page
  * @return array
  */
 public function getItems($offset, $itemCountPerPage)
 {
     $data = $this->_query->limit($itemCountPerPage)->offset($offset)->execute();
     if ($data instanceof Doctrine_Collection) {
         return $data->getData();
     } elseif (is_array($data)) {
         return $data;
     } else {
         $message = sprintf('Unexpected datatype for getItems(): %s', Robo47_Core::getType($data));
         throw new Robo47_Paginator_Adapter_Exception($message);
     }
 }