예제 #1
0
 /**
  * Creates and instance of a mock Joomla\Cache\Item object.
  *
  * @return  object
  *
  * @since   1.0
  */
 public function createMockItem()
 {
     // Collect all the relevant methods in JDatabase.
     $methods = array('getKey', 'getValue', 'isHit', 'setValue');
     // Create the mock.
     $mockObject = $this->test->getMock('Joomla\\Cache\\Item', $methods, array(), '', false);
     TestHelper::assignMockCallbacks($mockObject, $this->test, array('getValue' => array(is_callable(array($this->test, 'mockCacheItemGetValue')) ? $this->test : $this, 'mockCacheItemGetValue'), 'isHit' => array(is_callable(array($this->test, 'mockCacheItemIsHit')) ? $this->test : $this, 'mockCacheItemIsHit')));
     return $mockObject;
 }
예제 #2
0
파일: Driver.php 프로젝트: jbanety/database
 /**
  * Creates and instance of the mock JDatabase object.
  *
  * @param   \PHPUnit_Framework_TestCase  $test        A test object.
  * @param   string                       $nullDate    A null date string for the driver.
  * @param   string                       $dateFormat  A date format for the driver.
  *
  * @return  object
  *
  * @since   1.0
  */
 public static function create(\PHPUnit_Framework_TestCase $test, $nullDate = '0000-00-00 00:00:00', $dateFormat = 'Y-m-d H:i:s')
 {
     // Collect all the relevant methods in JDatabase.
     $methods = array('connect', 'connected', 'disconnect', 'dropTable', 'escape', 'execute', 'fetchArray', 'fetchAssoc', 'fetchObject', 'freeResult', 'getAffectedRows', 'getCollation', 'getConnectors', 'getDateFormat', 'getInstance', 'getLog', 'getNullDate', 'getNumRows', 'getPrefix', 'getQuery', 'getTableColumns', 'getTableCreate', 'getTableKeys', 'getTableList', 'getUtfSupport', 'getVersion', 'insertId', 'insertObject', 'loadAssoc', 'loadAssocList', 'loadColumn', 'loadObject', 'loadObjectList', 'loadResult', 'loadRow', 'loadRowList', 'lockTable', 'query', 'quote', 'quoteName', 'renameTable', 'replacePrefix', 'select', 'setQuery', 'setUTF', 'splitSql', 'test', 'isSupported', 'transactionCommit', 'transactionRollback', 'transactionStart', 'unlockTables', 'updateObject');
     // Create the mock.
     $mockObject = $test->getMockBuilder('\\Joomla\\Database\\DatabaseDriver')->setConstructorArgs(array(array()))->setMethods($methods)->getMock();
     // Mock selected methods.
     TestHelper::assignMockReturns($mockObject, $test, array('getNullDate' => $nullDate, 'getDateFormat' => $dateFormat));
     TestHelper::assignMockCallbacks($mockObject, $test, array('escape' => array(is_callable(array($test, 'mockEscape')) ? $test : __CLASS__, 'mockEscape'), 'getQuery' => array(is_callable(array($test, 'mockGetQuery')) ? $test : __CLASS__, 'mockGetQuery'), 'quote' => array(is_callable(array($test, 'mockQuote')) ? $test : __CLASS__, 'mockQuote'), 'quoteName' => array(is_callable(array($test, 'mockQuoteName')) ? $test : __CLASS__, 'mockQuoteName'), 'setQuery' => array(is_callable(array($test, 'mockSetQuery')) ? $test : __CLASS__, 'mockSetQuery')));
     return $mockObject;
 }
예제 #3
0
 /**
  * Sets up the fixture, for example, opens a network connection.
  * This method is called before a test is executed.
  *
  * @return  void
  */
 protected function setUp()
 {
     parent::setUp();
     $this->dbo = Mock\Driver::create($this);
     // Mock the escape method to ensure the API is calling the DBO's escape method.
     TestHelper::assignMockCallbacks($this->dbo, $this, array('escape' => array($this, 'mockEscape')));
 }
예제 #4
0
 /**
  * Creates an instance of a mock Joomla\Input\Json object.
  *
  * @return  \PHPUnit_Framework_MockObject_MockObject
  *
  * @since   1.0
  */
 public function createInputJson()
 {
     $mockObject = $this->createInput(array('methods' => array('getRaw')));
     TestHelper::assignMockCallbacks($mockObject, $this->test, array('getRaw' => array(is_callable(array($this->test, 'mockInputGetRaw')) ? $this->test : $this, 'mockInputGetRaw')));
     return $mockObject;
 }