/** * Creates and instance of the mock JApplicationCli object. * * @param FOFTestCase $test A test object. * @param array $options A set of options to configure the mock. * * @return \PHPUnit_Framework_MockObject_MockObject * * @since 12.2 */ public static function create($test, $options = array()) { // Collect all the relevant methods in JApplicationCli. $methods = self::getMethods(); // Create the mock. $mockObject = $test->getMock('\\JApplicationCli', $methods, array(), '', true); $mockObject = self::addBehaviours($test, $mockObject, $options); return $mockObject; }
/** * Creates and instance of the mock JLanguage object. * * @param FOFTestCase $test A test object. * * @return \PHPUnit_Framework_MockObject_MockObject * * @since 11.3 */ public static function create($test) { // Collect all the relevant methods in JDatabase. $methods = array('parse', 'render', 'test'); // Create the mock. $mockObject = $test->getMock('\\JDocument', $methods, array(), '', false); // Mock selected methods. $test->assignMockReturns($mockObject, array('parse' => $mockObject, 'test' => 'ok')); return $mockObject; }
/** * Creates and instance of the mock JLanguage object. * * @param FOFTestCase $test A test object. * * @return \PHPUnit_Framework_MockObject_MockObject * * @since 11.3 */ public static function create($test) { // Collect all the relevant methods in JDatabase. $methods = static::getMethods(); // Create the mock. $mockObject = $test->getMock('\\JLanguage', $methods, array(), '', false); // Mock selected methods. $test->assignMockReturns($mockObject, array('getInstance' => $mockObject, 'getTag' => 'en-GB', 'test' => 'ok')); $test->assignMockCallbacks($mockObject, array('_' => array(get_called_class(), 'mock_'), 'load' => array(get_called_class(), 'mockload'))); return $mockObject; }
/** * Creates and instance of the mock JApplicationBase object. * * @param FOFTestCase $test A test object. * @param array $options A set of options to configure the mock. * * @return \PHPUnit_Framework_MockObject_MockObject * * @since 11.3 */ public static function create($test, $options = array()) { // Set expected server variables. if (!isset($_SERVER['HTTP_HOST'])) { $_SERVER['HTTP_HOST'] = 'localhost'; } // Collect all the relevant methods in JApplicationBase. $methods = self::getMethods(); // Create the mock. $mockObject = $test->getMock('\\JApplicationBase', $methods, array(), '', true); $mockObject = self::addBehaviours($test, $mockObject, $options); return $mockObject; }
/** * Creates and instance of the mock JApplicationCms object. * * The test can implement the following overrides: * - mockAppendBody * - mockGetBody * - mockPrepentBody * - mockSetBody * * If any *Body methods are implemented in the test class, all should be implemented otherwise behaviour will be unreliable. * * @param FOFTestCase $test A test object. * @param array $options A set of options to configure the mock. * @param array $constructor An array containing constructor arguments to inject into the mock. * * @return \PHPUnit_Framework_MockObject_MockObject * * @since 3.2 */ public static function create($test, $options = array(), $constructor = array()) { // Set expected server variables. if (!isset($_SERVER['HTTP_HOST'])) { $_SERVER['HTTP_HOST'] = 'localhost'; } $methods = self::getMethods(); if (isset($options)) { // Create the mock. $mockObject = $test->getMock('\\JApplicationCms', $methods, $constructor, '', true); } $mockObject = self::addBehaviours($test, $mockObject, $options); return $mockObject; }
/** * Creates an instance of the mock JSession object. * * @param FOFTestCase $test A test object. * @param array $options An array of optional configuration values. * getId : the value to be returned by the mock getId method * get.user.id : the value to assign to the user object id returned by get('user') * get.user.name : the value to assign to the user object name returned by get('user') * get.user.username : the value to assign to the user object username returned by get('user') * * @return \PHPUnit_Framework_MockObject_MockObject * * @since 11.3 */ public static function create($test, $options = array()) { if (is_array($options)) { self::$options = $options; } // Mock all the public methods. $methods = array('clear', 'close', 'destroy', 'fork', 'get', 'getExpire', 'getFormToken', 'getId', 'getInstance', 'getName', 'getState', 'getStores', 'getToken', 'has', 'hasToken', 'getPrefix', 'isNew', 'restart', 'set'); // Create the mock. $mockObject = $test->getMock('\\JSession', $methods, array(), '', false); // Mock selected methods. $test->assignMockReturns($mockObject, array('getId' => self::getOption('getId'))); $test->assignMockCallbacks($mockObject, array('get' => array(get_called_class(), 'mockGet'))); return $mockObject; }
public function tearDown() { // Make sure the #__foobar_example table does not exist after running the tests $db = static::$container->db; $db->dropTable('#__foobar_example', true); parent::tearDown(); }
protected function tearDown() { parent::tearDown(); if (isset($_SERVER['HTTP_HOST'])) { unset($_SERVER['HTTP_HOST']); } }
/** * Creates an instance of the mock JMenu object. * * @param FOFTestCase $test A test object. * * @return \PHPUnit_Framework_MockObject_MockObject * * @since 3.4 */ public static function create(FOFTestCase $test, $setDefault = true, $setActive = false) { // Collect all the relevant methods in JMenu (work in progress). $methods = array('getItem', 'setDefault', 'getDefault', 'setActive', 'getActive', 'getItems', 'getParams', 'getMenu', 'authorise', 'load'); // Create the mock. $mockObject = $test->getMock('\\JMenu', $methods, array(), '', false); self::createMenuSampleData(); $mockObject->expects($test->any())->method('getItem')->will($test->returnValueMap(self::prepareGetItemData())); $mockObject->expects($test->any())->method('getMenu')->will($test->returnValue(self::$data)); if ($setDefault) { $mockObject->expects($test->any())->method('getDefault')->will($test->returnValueMap(self::prepareDefaultData())); } if ($setActive) { $mockObject->expects($test->any())->method('getActive')->will($test->returnValue(self::$data[$setActive])); } return $mockObject; }
public static function tearDownAfterClass() { global $fofTest_FakeFopen_Active; $fofTest_FakeFopen_Active = false; parent::tearDownAfterClass(); }
protected function tearDown() { $this->restoreFactoryState(); MockSession::$user = null; parent::tearDown(); }
protected function setUp() { parent::setUp(); $this->auth = new TransparentAuthentication(static::$container); $this->auth->setAuthenticationMethods(array(1, 2, 3, 4, 5)); $this->auth->setBasicAuthUsername('FOF30user'); $this->auth->setQueryParam('testAuth'); $this->auth->setQueryParamPassword('FOF30Password'); $this->auth->setQueryParamUsername('FOF30Username'); $this->auth->setTimeStep(30); $this->auth->setTotpKey(self::$totpKey); }
/** * Tears down the fixture, for example, closes a network connection. * This method is called after a test is executed. */ protected function tearDown() { $this->restoreFactoryState(); parent::tearDown(); }
/** * Tears down the fixture, for example, closes a network connection. * This method is called after a test is executed. */ public static function tearDownAfterClass() { parent::tearDownAfterClass(); // Remove the fake template JFolder::delete(JPATH_THEMES . '/fake_test_template'); }