本文整理汇总了PHP中TestReflection类的典型用法代码示例。如果您正苦于以下问题:PHP TestReflection类的具体用法?PHP TestReflection怎么用?PHP TestReflection使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了TestReflection类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testConstructorAppliesDefaultConfiguration
/**
* Test JModelAdmin::__construct
*
* @since 3.4
*
* @return void
*
* @testdox Constructor applies default configuration
*/
public function testConstructorAppliesDefaultConfiguration()
{
$config = array('event_after_delete' => 'onContentAfterDelete', 'event_after_save' => 'onContentAfterSave', 'event_before_delete' => 'onContentBeforeDelete', 'event_before_save' => 'onContentBeforeSave', 'event_change_state' => 'onContentChangeState', 'text_prefix' => 'COM_MOCK_J');
foreach ($config as $key => $value) {
$this->assertEquals($value, TestReflection::getValue($this->object, $key));
}
}
示例2: testGetInstance
/**
* Test JPathway::getInstance().
*
* @return void
*/
public function testGetInstance()
{
$current = TestReflection::getValue('JApplicationHelper', '_clients');
// Test Client
$obj = new stdClass();
$obj->id = 0;
$obj->name = 'inspector';
$obj->path = JPATH_TESTS;
$obj2 = new stdClass();
$obj2->id = 1;
$obj2->name = 'inspector2';
$obj2->path = __DIR__ . '/stubs';
TestReflection::setValue('JApplicationHelper', '_clients', array($obj, $obj2));
$pathway = JPathway::getInstance('Inspector');
$this->assertThat(get_class($pathway), $this->equalTo('JPathwayInspector'));
$this->assertThat(JPathway::getInstance('Inspector'), $this->equalTo($pathway));
$pathway = JPathway::getInstance('Inspector2');
$this->assertThat(get_class($pathway), $this->equalTo('JPathwayInspector2'));
$ret = true;
try {
JPathway::getInstance('Error');
} catch (Exception $e) {
$ret = false;
}
if ($ret) {
$this->fail('JPathway did not throw proper exception upon false client.');
}
TestReflection::setValue('JApplicationHelper', '_clients', $current);
}
示例3: tearDown
/**
* Tears down the fixture, for example, closes a network connection.
* This method is called after a test is executed.
*
* @return void
*
* @since 3.0
*/
protected function tearDown()
{
TestReflection::setValue('JComponentHelper', 'components', array());
// Restore the state
$this->restoreFactoryState();
parent::tearDown();
}
示例4: testConstructor
/**
* Tests the JImage::__construct method.
*
* @return void
*
* @since 11.4
*/
public function testConstructor()
{
// Create a image handle of the correct size.
$imageHandle = imagecreatetruecolor(100, 100);
$filter = new JImageFilterBrightness($imageHandle);
$this->assertEquals(TestReflection::getValue($filter, 'handle'), $imageHandle);
}
示例5: test_parseArguments
/**
* Test the JInput::parseArguments method.
*
* @dataProvider provider_parseArguments
*/
public function test_parseArguments($inputArgv, $expectedData, $expectedArgs)
{
$_SERVER['argv'] = $inputArgv;
$this->inspector = new JInputCLI(null, array('filter' => new JFilterInputMock()));
$this->assertThat(TestReflection::getValue($this->inspector, 'data'), $this->identicalTo($expectedData));
$this->assertThat(TestReflection::getValue($this->inspector, 'args'), $this->identicalTo($expectedArgs));
}
示例6: tearDown
/**
* Overrides the parent tearDown method.
*
* @return void
*
* @see PHPUnit_Framework_TestCase::tearDown()
* @since 11.1
*/
protected function tearDown()
{
// Reset the dispatcher instance.
TestReflection::setValue('JEventDispatcher', 'instance', null);
TestReflection::setValue('JPluginHelper', 'plugins', null);
parent::tearDown();
}
示例7: create
/**
* Creates and instance of the mock JController object.
*
* @param object $test A test object.
*
* @return object
*
* @since 12.1
*/
public static function create($test)
{
// Collect all the relevant methods in JController.
$methods = array(
'execute',
'getApplication',
'getInput',
'serialize',
'unserialize',
);
// Create the mock.
$mockObject = $test->getMock(
'JControllerBase',
$methods,
// Constructor arguments.
array(),
// Mock class name.
'',
// Call original constructor.
false
);
// TODO Mock the input.
TestReflection::setValue($mockObject, 'input', new JInput);
return $mockObject;
}
示例8: tearDown
/**
* Overrides the parent tearDown method.
*
* @return void
*
* @see PHPUnit_Framework_TestCase::tearDown()
* @since 11.1
*/
protected function tearDown()
{
$this->restoreFactoryState();
// Reset the dispatcher instance.
TestReflection::setValue('JPluginHelper', 'plugins', null);
parent::tearDown();
}
示例9: tearDown
/**
* Overrides the parent tearDown method.
*
* @return void
*
* @see PHPUnit_Framework_TestCase::tearDown()
* @since 11.1
*/
protected function tearDown()
{
// Reset the loaded plugins.
TestReflection::setValue('JPluginHelper', 'plugins', null);
$this->restoreFactoryState();
$_SERVER = $this->backupServer;
parent::tearDown();
}
示例10: testExtractCustom
/**
* Tests the extractCustom Method.
*
* @return void
*/
public function testExtractCustom()
{
if (!JArchiveZip::isSupported()) {
$this->markTestSkipped('ZIP files can not be extracted.');
}
TestReflection::invoke($this->object, 'extractCustom', __DIR__ . '/logo.zip', $this->outputPath);
$this->assertFileExists($this->outputPath . '/logo-zip.png');
}
示例11: tearDown
/**
* Overrides the parent tearDown method.
*
* @return void
*
* @see PHPUnit_Framework_TestCase::tearDown()
* @since 3.6
*/
protected function tearDown()
{
// Reset the dispatcher instance.
TestReflection::setValue('JEventDispatcher', 'instance', null);
$_SERVER = $this->backupServer;
$this->restoreFactoryState();
parent::tearDown();
}
示例12: testGetInput
/**
* Test the getInput method where there is no value from the element
* and no checked attribute.
*
* @param array $data @todo
* @param string $expected @todo
*
* @return void
*
* @since 12.2
*
* @dataProvider getInputData
*/
public function testGetInput($data, $expected)
{
$formField = new JFormFieldEmail();
foreach ($data as $attr => $value) {
TestReflection::setValue($formField, $attr, $value);
}
$this->assertEquals($expected, TestReflection::invoke($formField, 'getInput'), 'Line:' . __LINE__ . ' The field with no value and no checked attribute did not produce the right html');
}
示例13: testCacheTimeout
/**
* Overrides TestCaseCache::testCacheTimeout to deal with the adapter's stored time values in this test
*
* @testdox The cache handler correctly handles expired cache data
*
* @medium
*/
public function testCacheTimeout()
{
/** @var Cache_Lite $cacheLiteInstance */
$cacheLiteInstance = TestReflection::getValue('JCacheStorageCachelite', 'CacheLiteInstance');
$cacheLiteInstance->_lifeTime = 0.1;
// For parent class
$this->handler->_lifetime =& $cacheLiteInstance->_lifeTime;
parent::testCacheTimeout();
}
示例14: tearDown
/**
* Overrides the parent tearDown method.
*
* @return void
*
* @see PHPUnit_Framework_TestCase::tearDown()
* @since 11.1
*/
protected function tearDown()
{
// Reset the dispatcher instance.
TestReflection::setValue('JEventDispatcher', 'instance', null);
// Reset the loaded plugins.
TestReflection::setValue('JPluginHelper', 'plugins', null);
$_SERVER = $this->backupServer;
parent::tearDown();
}
示例15: testGetInput
/**
* Test the getInput method where there is no value from the element.
*
* @param array $data @todo
* @param string $expected @todo
*
* @return void
*
* @since 12.2
*
* @dataProvider getInputData
*/
public function testGetInput($data, $expected)
{
$formField = new JFormFieldTel();
TestReflection::setValue($formField, 'element', simplexml_load_string('<field type="tel" />'));
foreach ($data as $attr => $value) {
TestReflection::setValue($formField, $attr, $value);
}
$this->assertEquals($expected, TestReflection::invoke($formField, 'getInput'), 'Line:' . __LINE__ . ' The field did not produce the right html');
}