Пример #1
0
 /**
  * initUser
  *
  * @return  void
  */
 protected function initUser()
 {
     $mapper = new DataMapper('#__users');
     $users = $mapper->findOne();
     if ($users->notNull()) {
         return;
     }
     $helper = new TableHelper('#__users');
     $helper->initRow(mt_rand(50, 150));
 }
Пример #2
0
 /**
  * Get the columns from database table.
  *
  * @return  mixed  An array of the field names, or false if an error occurs.
  *
  * @since   11.1
  * @throws  \UnexpectedValueException
  */
 public function getFields()
 {
     return TableHelper::getFields($this);
 }
 /**
  * Method to test initRow().
  *
  * @param string $tableName
  * @param string $pk
  * @param int    $initId
  * @param int    $expectCount
  *
  * @covers       Windwalker\Table\TableHelper::initRow
  * @dataProvider initRowDataProvider
  */
 public function testInitRow($tableName, $pk, $initId, $expectCount)
 {
     $helper = new TableHelper($tableName, null, $pk);
     $db = \JFactory::getDbo();
     $idQuery = $db->getQuery(true);
     $countQuery = $db->getQuery(true);
     $idQuery->select($pk)->from($tableName)->where("{$pk} = {$initId}");
     $countQuery->select('COUNT(*)')->from($tableName);
     $this->assertEquals($initId, $helper->initRow($initId));
     $actualId = $db->setQuery($idQuery)->loadResult();
     $actualCount = $db->setQuery($countQuery)->loadResult();
     $this->assertEquals($initId, $actualId, 'Check init new id');
     $this->assertEquals($expectCount, $actualCount, 'Check row count after init new id');
 }