PhpMigration\Changes\AbstractIntroducedTest::testNewFunc PHP Method

testNewFunc() public method

public testNewFunc ( )
    public function testNewFunc()
    {
        // Not-new
        $code = 'function not_new() {}';
        $this->assertNotSpot($code);
        $table = TestHelper::fetchProperty($this->change, 'funcTable');
        if (is_null($table)) {
            return;
        }
        foreach ($table as $name => $dummy) {
            // Normal name
            $code = sprintf('function %s() {}', $name);
            $this->assertHasSpot($code);
            // Case Insensitive name
            $code = sprintf('function %s() {}', strtoupper($name));
            $this->assertHasSpot($code);
            // Namespaced
            $code = sprintf('namespace Dummy; function %s() {}', $name);
            $this->assertNotSpot($code);
            // Conditional name
            $code = sprintf("if (!function_exists('%s')) { function %s() {} }", $name, $name);
            $this->assertNotSpot($code);
        }
        // Error-conditional name
        $code = sprintf("if (!function_exists('nothing')) { function %s() {} }", $name);
        $this->assertHasSpot($code);
    }