本文整理汇总了PHP中SimpleTestCompatibility类的典型用法代码示例。如果您正苦于以下问题:PHP SimpleTestCompatibility类的具体用法?PHP SimpleTestCompatibility怎么用?PHP SimpleTestCompatibility使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了SimpleTestCompatibility类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _isTest
/**
* Tests to see if the method is a test that should
* be run, override default by searching methods that starts with 'it'
* is a candidate unless it is the constructor.
* @param string $method Method name to try.
* @return boolean True if test method.
* @access protected
*/
function _isTest($method)
{
if (strtolower(substr($method, 0, 2)) == 'it') {
return !SimpleTestCompatibility::isA($this, strtolower($method));
}
return parent::_isTest($method);
}
示例2: testInteraceComparison
function testInteraceComparison()
{
if (version_compare(phpversion(), '5', '<')) {
return;
}
$object = new ComparisonClassWithInterface();
$this->assertFalse(SimpleTestCompatibility::isA(new ComparisonClass(), 'ComparisonInterface'));
$this->assertTrue(SimpleTestCompatibility::isA(new ComparisonClassWithInterface(), 'ComparisonInterface'));
}
示例3: SimpleSocket
function SimpleSocket($host, $port, $timeout, $block_size = 255)
{
$this->SimpleStickyError();
if (!($this->_handle = $this->_openSocket($host, $port, $error_number, $error, $timeout))) {
$this->_setError("Cannot open [{$host}:{$port}] with [{$error}] within [{$timeout}] seconds");
return;
}
$this->_is_open = true;
$this->_block_size = $block_size;
SimpleTestCompatibility::setTimeout($this->_handle, $timeout);
}
示例4: testObjectReferences
public function testObjectReferences()
{
$object = new ComparisonClass();
$object_reference = $object;
$object_copy = new ComparisonClass();
$object_assignment = $object;
$this->assertTrue(SimpleTestCompatibility::isReference($object, $object));
$this->assertTrue(SimpleTestCompatibility::isReference($object, $object_reference));
$this->assertFalse(SimpleTestCompatibility::isReference($object, $object_copy));
$this->assertTrue(SimpleTestCompatibility::isReference($object, $object_assignment));
}
示例5: testIsA
function testIsA() {
$this->assertTrue(SimpleTestCompatibility::isA(
new RandomCompatibilityClass(),
'RandomCompatibilityClass'));
$this->assertFalse(SimpleTestCompatibility::isA(
new RandomCompatibilityClass(),
'RandomCompatibilitySubclass'));
$this->assertTrue(SimpleTestCompatibility::isA(
new RandomCompatibilitySubclass(),
'RandomCompatibilityClass'));
}
示例6: isArrayOfIdenticalTypes
/**
* Recursive type test for each element of an array.
* @param mixed $first Test subject.
* @param mixed $second Comparison object.
* @return boolean True if identical.
* @access private
*/
protected static function isArrayOfIdenticalTypes($first, $second)
{
if (array_keys($first) != array_keys($second)) {
return false;
}
foreach (array_keys($first) as $key) {
$is_identical = SimpleTestCompatibility::isIdenticalType($first[$key], $second[$key]);
if (!$is_identical) {
return false;
}
}
return true;
}
示例7: testObjectReferences
function testObjectReferences()
{
$object = new ComparisonClass();
$object_reference =& $object;
$object_copy = new ComparisonClass();
$object_assignment = $object;
$this->assertTrue(SimpleTestCompatibility::isReference($object, $object));
$this->assertTrue(SimpleTestCompatibility::isReference($object, $object_reference));
$this->assertFalse(SimpleTestCompatibility::isReference($object, $object_copy));
if (version_compare(phpversion(), '5', '>=')) {
$this->assertTrue(SimpleTestCompatibility::isReference($object, $object_assignment));
} else {
$this->assertFalse(SimpleTestCompatibility::isReference($object, $object_assignment));
}
}
示例8: testAddTwice
function testAddTwice()
{
$parent = $this->generateSection(0);
$section1 = $this->generateSection(0);
$fakeSection1 = $this->generateSection(0);
//will generate with the
//same data as the section above
$this->assertFalse(SimpleTestCompatibility::isReference($section1, $fakeSection1));
//add once
$parent->add($section1);
$resultSection =& $parent->get($section1->getId());
$this->assertNotNull($resultSection);
$this->assertSectionsEqual($section1, $resultSection);
//add again
$result = $parent->add($section1);
$this->assertTrue(PEAR::isError($result));
$this->assertNotNull($parent->get($section1->getId()));
//add other
$result = $parent->add($fakeSection1);
$this->assertTrue(PEAR::isError($result));
}
示例9: getAssertionLine
function getAssertionLine($format = '%d', $stack = false)
{
if ($stack === false) {
$stack = SimpleTestCompatibility::getStackTrace();
}
return SimpleDumper::getFormattedAssertionLine($stack, $format);
}
示例10: array
/**
* Retrieves 'preferred' objects from global pool. Class filter
* can be applied in order to retrieve the object of the specific
* class
* @param array|string $classes Allowed classes or interfaces.
* @static
* @access public
* @return array|object|null
* @see prefer()
*/
function &preferred($classes)
{
if (!is_array($classes)) {
$classes = array($classes);
}
$registry =& SimpleTest::_getRegistry();
for ($i = count($registry['Preferred']) - 1; $i >= 0; $i--) {
foreach ($classes as $class) {
if (SimpleTestCompatibility::isA($registry['Preferred'][$i], $class)) {
return $registry['Preferred'][$i];
}
}
}
return null;
}
示例11: isIdentical
/**
* Identity test. Drops back to equality for PHP5
* objects as the === operator counts as the
* stronger reference constraint.
* @param mixed $first Test subject.
* @param mixed $second Comparison object.
* @access public
* @static
*/
function isIdentical($first, $second)
{
if (version_compare(phpversion(), '5') >= 0) {
if (gettype($first) != gettype($second)) {
return false;
}
if ($first != $second) {
return false;
}
if (is_object($first) && is_object($second)) {
return get_class($first) == get_class($second);
}
if (is_array($first) && is_array($second)) {
if (array_keys($first) != array_keys($second)) {
return false;
}
foreach (array_keys($first) as $key) {
if (!SimpleTestCompatibility::isIdentical($first[$key], $second[$key])) {
return false;
}
}
}
return true;
}
return $first === $second;
}
示例12: _isConstructor
/**
* Tests to see if the method is the constructor and
* so should be ignored.
* @param string $method Method name to try.
* @return boolean True if constructor.
* @access protected
*/
function _isConstructor($method)
{
return SimpleTestCompatibility::isA($this->_test_case, strtolower($method));
}
示例13: test
/**
* Tests the expectation. True if the type or
* class matches the string value.
* @param string $compare Comparison value.
* @return boolean True if correct.
* @access public
*/
function test($compare)
{
if (is_object($compare)) {
return SimpleTestCompatibility::isA($compare, $this->type);
} else {
$function = 'is_' . $this->canonicalType($this->type);
if (is_callable($function)) {
return $function($compare);
}
return false;
}
}
示例14: testInteraceComparison
function testInteraceComparison()
{
$object = new ComparisonClassWithInterface();
$this->assertFalse(SimpleTestCompatibility::isA(new ComparisonClass(), 'ComparisonInterface'));
$this->assertTrue(SimpleTestCompatibility::isA(new ComparisonClassWithInterface(), 'ComparisonInterface'));
}
示例15: _addCheckbox
/**
* Adds a checkbox, making it a group on a repeated name.
* @param SimpleCheckboxTag $tag Incoming form control.
* @access private
*/
function _addCheckbox($tag) {
if (! isset($this->_widgets[$tag->getName()])) {
$this->_widgets[$tag->getName()] = &$tag;
} elseif (! SimpleTestCompatibility::isA($this->_widgets[$tag->getName()], 'SimpleCheckboxGroup')) {
$previous = &$this->_widgets[$tag->getName()];
$this->_widgets[$tag->getName()] = &new SimpleCheckboxGroup();
$this->_widgets[$tag->getName()]->addWidget($previous);
$this->_widgets[$tag->getName()]->addWidget($tag);
} else {
$this->_widgets[$tag->getName()]->addWidget($tag);
}
}