本文整理汇总了PHP中TestReflection::invoke方法的典型用法代码示例。如果您正苦于以下问题:PHP TestReflection::invoke方法的具体用法?PHP TestReflection::invoke怎么用?PHP TestReflection::invoke使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TestReflection
的用法示例。
在下文中一共展示了TestReflection::invoke方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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');
}
示例2: 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');
}
示例3: 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');
}
示例4: testExtractCustom
/**
* Tests the extractCustom Method.
*
* @return void
*/
public function testExtractCustom()
{
if (!JArchiveZip::isSupported()) {
$this->markTestSkipped('ZIP files can not be extracted.');
return;
}
TestReflection::invoke($this->object, 'extractCustom', __DIR__ . '/logo.zip', static::$outputPath);
$this->assertTrue(is_file(static::$outputPath . '/logo-zip.png'));
if (is_file(static::$outputPath . '/logo-zip.png')) {
unlink(static::$outputPath . '/logo-zip.png');
}
}
示例5: testGetInput
/**
* Test the getInput method where there is no value from the element
* and no checked attribute.
*
* @param string $element @todo
* @param array $data @todo
* @param string $expected @todo
*
* @return void
*
* @since 12.2
*
* @dataProvider getInputData
*/
public function testGetInput($element, $data, $expected)
{
$formField = new JFormFieldRadio();
TestReflection::setValue($formField, 'element', simplexml_load_string($element));
foreach ($data as $attr => $value) {
TestReflection::setValue($formField, $attr, $value);
}
// Get the result once, we may perform multiple tests
$result = TestReflection::invoke($formField, 'getInput');
// Test that the tag exists
$matcher = array('id' => 'myTestId');
$this->assertTag($matcher, $result, 'The tag did not have the correct id.');
}
示例6: testAdd
/**
* Tests the add method
*
* @param mixed $recipient Either a string or array of strings [email address(es)]
* @param mixed $name Either a string or array of strings [name(s)]
* @param string $method The parent method's name.
* @param array $expected The expected array.
*
* @covers JMail::add
* @dataProvider seedTestAdd
*
* @return void
*/
public function testAdd($recipient, $name, $method, $expected)
{
TestReflection::invoke($this->object, 'add', $recipient, $name, $method);
switch ($method) {
case 'AddAddress':
$type = 'to';
break;
case 'AddCC':
$type = 'cc';
break;
case 'AddBCC':
$type = 'bcc';
break;
case 'AddReplyTo':
$type = 'ReplyTo';
break;
}
$this->assertThat($expected, $this->equalTo(TestReflection::getValue($this->object, $type)));
}
示例7: testSerialize
/**
* Test the JInput::serialize method.
*
* @return void
*
* @since 12.1
*/
public function testSerialize()
{
// Load the inputs so that the static $loaded is set to true.
TestReflection::invoke($this->class, 'loadAllInputs');
// Adjust the values so they are easier to handle.
TestReflection::setValue($this->class, 'inputs', array('server' => 'remove', 'env' => 'remove', 'request' => 'keep'));
TestReflection::setValue($this->class, 'options', 'options');
TestReflection::setValue($this->class, 'data', 'data');
$this->assertThat($this->class->serialize(), $this->equalTo('a:3:{i:0;s:7:"options";i:1;s:4:"data";i:2;a:1:{s:7:"request";s:4:"keep";}}'));
}
示例8: testGetOptions
/**
* Test the getOptions method.
*
* @since 12.2
*
* @return void
*/
public function testGetOptions()
{
$formFieldCheckboxes = new JFormFieldCheckboxes();
$option1 = new stdClass();
$option1->value = 'yellow';
$option1->text = 'yellow';
$option1->disable = true;
$option1->class = '';
$option1->onclick = '';
$option1->checked = false;
$option1->onchange = '';
$option2 = new stdClass();
$option2->value = 'green';
$option2->text = 'green';
$option2->disable = false;
$option2->class = '';
$option2->onclick = '';
$option2->checked = true;
$option2->onchange = '';
$optionsExpected = array($option1, $option2);
// Test with two values checked, no checked element
TestReflection::setValue($formFieldCheckboxes, 'element', simplexml_load_string('<field name="color" type="checkboxes">
<option value="yellow" disabled="true">yellow</option>
<option value="green" checked="true">green</option>
</field>'));
$this->assertEquals($optionsExpected, TestReflection::invoke($formFieldCheckboxes, 'getOptions'), 'The field with two values did not produce the right options');
}
示例9: testMethodInPostRequest
/**
* Tests the setMethodInPostRequest and isMethodInPostRequest.
*
* @return void
*
* @covers JApplicationWebRouterRest::setMethodInPostRequest
* @covers JApplicationWebRouterRest::isMethodInPostRequest
* @since 12.3
*/
public function testMethodInPostRequest()
{
// Check the defaults
$this->assertEquals(false, TestReflection::invoke($this->_instance, 'isMethodInPostRequest'));
// Check setting true
TestReflection::invoke($this->_instance, 'setMethodInPostRequest', true);
$this->assertEquals(true, TestReflection::invoke($this->_instance, 'isMethodInPostRequest'));
// Check setting false
TestReflection::invoke($this->_instance, 'setMethodInPostRequest', false);
$this->assertEquals(false, TestReflection::invoke($this->_instance, 'isMethodInPostRequest'));
}
示例10: testParseRoute
/**
* Tests the JApplicationWebRouterBase::parseRoute method.
*
* @param string $r The route to parse.
* @param boolean $e True if an exception is expected.
* @param string $c The expected controller name.
* @param array $i The expected input object data.
* @param integer $m The map set to use for setting up the router.
*
* @return void
*
* @covers JApplicationWebRouterBase::parseRoute
* @dataProvider getParseRouteData
* @since 12.3
*/
public function testParseRoute($r, $e, $c, $i, $m)
{
// Setup the router maps.
$mapSetup = 'setMaps' . $m;
$this->$mapSetup();
// If we should expect an exception set that up.
if ($e)
{
$this->setExpectedException('InvalidArgumentException');
}
// Execute the route parsing.
$actual = TestReflection::invoke($this->_instance, 'parseRoute', $r);
// Test the assertions.
$this->assertEquals($c, $actual, 'Incorrect controller name found.');
$this->assertAttributeEquals($i, 'data', $this->_input, 'The input data is incorrect.');
}
示例11: testRender
/**
* Tests the JApplicationWeb::render method.
*
* @return void
*
* @since 11.3
*/
public function testRender()
{
$document = $this->getMockDocument();
$this->assignMockReturns($document, array('render' => 'JWeb Body'));
// Manually inject the document.
TestReflection::setValue($this->class, 'document', $document);
TestReflection::invoke($this->class, 'render');
$this->assertEquals(array('JWeb Body'), TestReflection::getValue($this->class, 'response')->body);
}
示例12: test_runQuery
/**
* Tests the `_runQuery` method.
*
* @return void
*
* @since 12.1
*/
public function test_runQuery()
{
// Just run a valid query and then check for an exception case.
TestReflection::invoke($this->class, '_runQuery', 'SELECT * FROM #__categories', 'foo');
try {
// We need to confirm the locking is called, so we create a mock.
$class = $this->getMock('NestedTable', array('_unlock'), array(self::$driver));
// Then override the _unlock method so we can test that it was called.
$this->assignMockCallbacks($class, array('_unlock' => array('NestedTable', 'mockUnlock')));
// Reset the value to detect the change.
NestedTable::$unlocked = false;
TestReflection::invoke($class, '_runQuery', 'SELECT foo FROM #__categories', 'foo');
$this->fail('A RuntimeException was expected.');
} catch (RuntimeException $e) {
$this->assertTrue(NestedTable::$unlocked);
}
}
示例13: test_addPath
/**
* Test JViewLegacy::_addPath()
*
* @since 11.3
*
* @return void
*/
public function test_addPath()
{
$ds = DIRECTORY_SEPARATOR;
// Reset the internal _path property so we can track it more easily.
TestReflection::setValue($this->class, '_path', array('helper' => array(), 'template' => array()));
TestReflection::invoke($this->class, '_addPath', 'template', JPATH_ROOT . $ds . 'libraries');
$this->assertAttributeEquals(array('helper' => array(), 'template' => array(realpath(JPATH_ROOT . $ds . 'libraries') . $ds)), '_path', $this->class);
TestReflection::invoke($this->class, '_addPath', 'helper', realpath(JPATH_ROOT . $ds . 'tests'));
$this->assertAttributeEquals(array('helper' => array(realpath(JPATH_ROOT . $ds . 'tests') . $ds), 'template' => array(realpath(JPATH_ROOT . $ds . 'libraries') . $ds)), '_path', $this->class);
TestReflection::invoke($this->class, '_addPath', 'template', realpath(JPATH_ROOT . $ds . 'tests'));
$this->assertAttributeEquals(array('helper' => array(realpath(JPATH_ROOT . $ds . 'tests') . $ds), 'template' => array(realpath(JPATH_ROOT . $ds . 'tests') . $ds, realpath(JPATH_ROOT . $ds . 'libraries') . $ds)), '_path', $this->class);
TestReflection::invoke($this->class, '_addPath', 'helper', realpath(JPATH_ROOT . $ds . 'libraries'));
$this->assertAttributeEquals(array('helper' => array(realpath(JPATH_ROOT . $ds . 'libraries') . $ds, realpath(JPATH_ROOT . $ds . 'tests') . $ds), 'template' => array(realpath(JPATH_ROOT . $ds . 'tests') . $ds, realpath(JPATH_ROOT . $ds . 'libraries') . $ds)), '_path', $this->class);
}
示例14: test_fetchFeedParserWithInvalidTag
/**
* Tests JFeedFactory::_fetchFeedParser()
*
* @return void
*
* @expectedException LogicException
* @since 12.3
*/
public function test_fetchFeedParserWithInvalidTag()
{
TestReflection::invoke($this->_instance, '_fetchFeedParser', 'foobar', new XMLReader());
}
示例15: testLoadPaths
/**
* Tests the loadPaths method.
*
* @return void
*
* @covers JViewHtml::loadPaths
* @since 12.1
*/
public function testLoadPaths()
{
$this->assertEquals(new SplPriorityQueue(), TestReflection::invoke($this->_instance, 'loadPaths'));
}