本文整理汇总了PHP中PHPUnit_Util_Class::getObjectAttribute方法的典型用法代码示例。如果您正苦于以下问题:PHP PHPUnit_Util_Class::getObjectAttribute方法的具体用法?PHP PHPUnit_Util_Class::getObjectAttribute怎么用?PHP PHPUnit_Util_Class::getObjectAttribute使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PHPUnit_Util_Class
的用法示例。
在下文中一共展示了PHPUnit_Util_Class::getObjectAttribute方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testManufactureHandlers
/**
* @dataProvider handlerProvider
*/
public function testManufactureHandlers($types, $options)
{
$handler = HandlerFactory::createHandler($types, $options);
if (count($types) > 1) {
$handlerclass = $this->handlers['Composite'];
$h = \PHPUnit_Util_Class::getObjectAttribute($handler, 'drivers');
$handlers = array_combine($types, $h);
} else {
$handlerclass = $this->handlers[$types[0]];
$handlers = array($types[0] => $handler);
}
$this->assertInstanceOf($handlerclass, $handler);
foreach ($handlers as $subtype => $subhandler) {
$subhandlerclass = $this->handlers[$subtype];
$this->assertInstanceOf($subhandlerclass, $subhandler);
}
foreach ($types as $type) {
$defaults = isset($this->defaultSettings[$type]) ? $this->defaultSettings[$type] : array();
$options = array_merge($defaults, $options);
/* foreach($options as $optname => $optvalue) {
$this->assertAttributeEquals($optvalue, $optname, $handlers[$type]);
}
*/
}
}
示例2: testGetObjectAttributeCanHandleDynamicVariables
/**
* Test that if a dynamic variable is defined on a class then
* the $attribute variable will be NULL, but the variable defined
* will be a public one so we are safe to return it
*
* Currently $attribute is NULL but we try and call isPublic() on it.
* This breaks for php 5.2.10
*
* @covers PHPUnit_Util_Class::getObjectAttribute
*
* @return void
*/
public function testGetObjectAttributeCanHandleDynamicVariables()
{
$attributeName = '_variable';
$object = new stdClass();
$object->{$attributeName} = 'Test';
$actual = PHPUnit_Util_Class::getObjectAttribute($object, $attributeName);
$this->assertEquals('Test', $actual);
}
示例3: testSetThreshold
/**
* Test setThreshold method
*/
public function testSetThreshold()
{
$thresholdKey = \Magento\Framework\Profiler\Driver\Standard\Stat::TIME;
$this->_output->setThreshold($thresholdKey, 100);
$thresholds = class_exists('PHPUnit_Util_Class') ? \PHPUnit_Util_Class::getObjectAttribute($this->_output, '_thresholds') : \PHPUnit_Framework_Assert::readAttribute($this->_output, '_thresholds');
$this->assertArrayHasKey($thresholdKey, $thresholds);
$this->assertEquals(100, $thresholds[$thresholdKey]);
$this->_output->setThreshold($thresholdKey, null);
$this->assertArrayNotHasKey($thresholdKey, $this->_output->getThresholds());
}
示例4: readAttribute
/**
* Returns the value of an attribute of a class or an object.
* This also works for attributes that are declared protected or private.
*
* @param mixed $classOrObject
* @param string $attributeName
* @return mixed
* @throws PHPUnit_Framework_Exception
*/
public static function readAttribute($classOrObject, $attributeName)
{
if (!is_string($attributeName)) {
throw PHPUnit_Util_InvalidArgumentHelper::factory(2, 'string');
}
if (is_string($classOrObject)) {
if (!class_exists($classOrObject)) {
throw PHPUnit_Util_InvalidArgumentHelper::factory(1, 'class name');
}
return PHPUnit_Util_Class::getStaticAttribute($classOrObject, $attributeName);
} else {
if (is_object($classOrObject)) {
return PHPUnit_Util_Class::getObjectAttribute($classOrObject, $attributeName);
} else {
throw PHPUnit_Util_InvalidArgumentHelper::factory(1, 'class name or object');
}
}
}
示例5: testDefinedProperties
/**
* Tests access to data stored in {@link phpucAbstractAntTask::$properties}
*
* @covers phpucAbstractAntTask::__set
* @covers phpucAbstractAntTask::__get
* @covers phpucAbstractAntTask::__isset
*
* @return void
*/
public function testDefinedProperties()
{
$buildFile = $this->getMock('phpucBuildFile', array(), array(), '', false);
$exec = phpucAbstractAntTask::create($buildFile, 'exec');
$php = 'php5';
$exec->executable = $php;
$properties = PHPUnit_Util_Class::getObjectAttribute($exec, 'properties');
$this->assertEquals($php, $properties['executable']);
$this->assertEquals($php, $exec->executable);
$this->assertTrue(isset($exec->executable));
$this->assertFalse(isset($exec->foobar));
}
示例6: testTargetTasks
/**
* Tests that {@link phpucAbstractAntTask} are properly added to
* target tasks list
*
* @covers phpucBuildTarget::addTask
* @covers phpucBuildTarget::getTasks
*
* @return void
*/
public function testTargetTasks()
{
$buildFile = new phpucBuildFile($this->fileName, $this->projectName);
$target = $buildFile->createBuildTarget('phpuc');
$execTask = phpucAbstractAntTask::create($buildFile, 'exec');
$applyTask = phpucAbstractAntTask::create($buildFile, 'apply');
$target->addTask($execTask);
$target->addTask($applyTask);
$this->assertEquals(array($execTask, $applyTask), $target->getTasks());
$tasks = PHPUnit_Util_Class::getObjectAttribute($target, 'tasks');
$this->assertEquals(array($execTask, $applyTask), $tasks);
}