function _isTest($method) { if (strtolower(substr($method, 0, 2)) == 'it' || strtolower(substr($method, 0, 6)) == 'should') { return !SimpleTestCompatibility::isA($this, strtolower($method)); } return false; }
/** * 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); }
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')); }
function testIsA() { $this->assertTrue(SimpleTestCompatibility::isA( new RandomCompatibilityClass(), 'RandomCompatibilityClass')); $this->assertFalse(SimpleTestCompatibility::isA( new RandomCompatibilityClass(), 'RandomCompatibilitySubclass')); $this->assertTrue(SimpleTestCompatibility::isA( new RandomCompatibilitySubclass(), 'RandomCompatibilityClass')); }
/** * 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); } }
/** * Creates an equality expectation if the * object/value is not already some type * of expectation. * @param mixed $expected Expected value. * @return SimpleExpectation Expectation object. * @access private */ function _coerceExpectation($expected) { if ($expected == false) { return new TrueExpectation(); } if (SimpleTestCompatibility::isA($expected, 'SimpleExpectation')) { return $expected; } return new EqualExpectation(is_string($expected) ? str_replace('%', '%%', $expected) : $expected); }
/** * Tests to see if the method is a test that should * be run. Currently any method that starts with 'test' * 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, 4)) == 'test') { return ! SimpleTestCompatibility::isA($this, strtolower($method)); } return false; }
/** * 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; }
/** * 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)); }
/** * 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; } }
/** * IsTest method * * Prevent intensive W3 test, and the build tests (used to generate the testSection tests) unless * explicitly specified * * @param mixed $method * @return void */ protected function _isTest($method) { if (strtolower($method) === 'testaction') { return false; } $buildTests = ['testw3validity', 'testbuildregex', 'testbuildtest']; if (in_array(strtolower($method), $buildTests)) { return !$this->skipSetupTests; } if (strtolower(substr($method, 0, 4)) === 'test') { if (!$this->skipSetupTests) { return false; } return !SimpleTestCompatibility::isA($this, strtolower($method)); } return false; }
function testIsA() { $this->assertTrue(SimpleTestCompatibility::isA(new ComparisonClass(), 'ComparisonClass')); $this->assertFalse(SimpleTestCompatibility::isA(new ComparisonClass(), 'ComparisonSubclass')); $this->assertTrue(SimpleTestCompatibility::isA(new ComparisonSubclass(), 'ComparisonClass')); }
function testInteraceComparison() { $object = new ComparisonClassWithInterface(); $this->assertFalse(SimpleTestCompatibility::isA(new ComparisonClass(), 'ComparisonInterface')); $this->assertTrue(SimpleTestCompatibility::isA(new ComparisonClassWithInterface(), 'ComparisonInterface')); }
/** * 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 { return strtolower(gettype($compare)) == $this->_canonicalType($this->_type); } }
/** * Creates an equality expectation if the * object/value is not already some type * of expectation. * @param mixed $expected Expected value. * @return SimpleExpectation Expectation object. * @access private */ function _coerceToExpectation($expected) { if (SimpleTestCompatibility::isA($expected, 'SimpleExpectation')) { return $expected; } return new EqualExpectation($expected); }
/** * Adds a checkbox, making it a group on a repeated name. * @param SimpleCheckboxTag $tag Incoming form control. * @access private */ protected function addCheckbox($tag) { if (!isset($this->checkboxes[$tag->getName()])) { $this->widgets[] = $tag; $this->checkboxes[$tag->getName()] = count($this->widgets) - 1; } else { $index = $this->checkboxes[$tag->getName()]; if (!SimpleTestCompatibility::isA($this->widgets[$index], 'SimpleCheckboxGroup')) { $previous = $this->widgets[$index]; $this->widgets[$index] = new SimpleCheckboxGroup(); $this->widgets[$index]->addWidget($previous); } $this->widgets[$index]->addWidget($tag); } }
/** * Tests to see if the method is a test that should * be run. Currently any method that starts with 'test' * 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, 4)) == 'test') { if (count($this->_methods_filter) && !in_array(strtolower($method), $this->_methods_filter)) { return false; } return !SimpleTestCompatibility::isA($this, strtolower($method)); } return false; }