Extends
lithium\test\Unit
Tests getting static and non-static properties from various types of classes.
Returns
voidSource
public function testGetClassProperties() {
$result = array_map(
function($property) { return $property['name']; },
Inspector::properties(__CLASS__)
);
$expected = array('test', 'test2');
$this->assertEqual($expected, $result);
$result = array_map(
function($property) { return $property['name']; },
Inspector::properties(__CLASS__, array('public' => false))
);
$expected = array('test', 'test2', '_test');
$this->assertEqual($expected, $result);
$result = Inspector::properties(__CLASS__);
$expected = array(
array(
'modifiers' => array('public'),
'docComment' => false,
'name' => 'test',
'value' => null
),
array(
'modifiers' => array('public', 'static'),
'docComment' => false,
'name' => 'test2',
'value' => 'bar'
)
);
$this->assertEqual($expected, $result);
$result = array_map(
function($property) { return $property['name']; },
Inspector::properties('lithium\action\Controller')
);
$this->assertTrue(in_array('request', $result));
$this->assertTrue(in_array('response', $result));
$this->assertFalse(in_array('_render', $result));
$this->assertFalse(in_array('_classes', $result));
$result = array_map(
function($property) { return $property['name']; },
Inspector::properties('lithium\action\Controller', array('public' => false))
);
$this->assertTrue(in_array('request', $result));
$this->assertTrue(in_array('response', $result));
$this->assertTrue(in_array('_render', $result));
$this->assertTrue(in_array('_classes', $result));
$this->assertNull(Inspector::properties('\lithium\core\Foo'));
}