1

I have the following PHP unit test case.

For checking purposes I commented out the actual test (even with the ->url() call it does not work)

<?php

class BasicTest extends \PHPUnit_Extensions_Selenium2TestCase
{
    static $browsers = array(
        'chrome28win7' =>
            array(
                'browserName' => 'chrome',
                'desiredCapabilities' => array(
                    'version' => '28',
                    'os' => 'Windows',
                    'os_version' => '7',
                    'resolution' => '1280x1024',
                ),
            ),

    );

    /**
     * @dataProvider urlDataProvider
     * @param $path
     */
    public function testUrlScreenshot($path)
    {
        return; // for checking
        $this->url(env('BROWSER_BASE') . $path);
    }

    public static function urlDataProvider()
    {
        $list = <<<EOL
datenschutz.html
impressum.html
EOL;
        $plainArray = explode("\n", $list);

        $result = array();

        foreach($plainArray as $entry) {
            $result = array($entry);
        }
        return $result;
    }
}

I am getting the following exception:

/usr/bin/php /home/example/local-workspace/example/vendor/phpunit/phpunit/phpunit --configuration /home/example/local-workspace/example/phpunit.xml --filter "/::testUrlScreenshot( .*)?$/" BasicTest /home/example/local-workspace/example/tests/frontend/BasicTest.php --teamcity
Testing started at 10:18 ...
PHP Fatal error:  Call to undefined method PHPUnit_Framework_WarningTestCase::setupSpecificBrowser() in /home/example/local-workspace/example/vendor/phpunit/phpunit-selenium/PHPUnit/Extensions/SeleniumBrowserSuite.php on line 95
PHP Stack trace:
PHP   1. {main}() /home/example/local-workspace/example/vendor/phpunit/phpunit/phpunit:0
PHP   2. PHPUnit_TextUI_Command::main() /home/example/local-workspace/example/vendor/phpunit/phpunit/phpunit:47
PHP   3. PHPUnit_TextUI_Command->run() /home/example/local-workspace/example/vendor/phpunit/phpunit/src/TextUI/Command.php:110
PHP   4. PHPUnit_Runner_BaseTestRunner->getTest() /home/example/local-workspace/example/vendor/phpunit/phpunit/src/TextUI/Command.php:133
PHP   5. ReflectionMethod->invoke() /home/example/local-workspace/example/vendor/phpunit/phpunit/src/Runner/BaseTestRunner.php:87
PHP   6. PHPUnit_Extensions_Selenium2TestCase::suite() /home/example/local-workspace/example/vendor/phpunit/phpunit/src/Runner/BaseTestRunner.php:87
PHP   7. PHPUnit_Extensions_SeleniumTestSuite::fromTestCaseClass() /home/example/local-workspace/example/vendor/phpunit/phpunit-selenium/PHPUnit/Extensions/Selenium2TestCase.php:371
PHP   8. PHPUnit_Extensions_SeleniumBrowserSuite->setupSpecificBrowser() /home/example/local-workspace/example/vendor/phpunit/phpunit-selenium/PHPUnit/Extensions/SeleniumTestSuite.php:142
PHP   9. PHPUnit_Extensions_SeleniumBrowserSuite->browserOnAllTests() /home/example/local-workspace/example/vendor/phpunit/phpunit-selenium/PHPUnit/Extensions/SeleniumBrowserSuite.php:86
PHP  10. PHPUnit_Extensions_SeleniumBrowserSuite->browserOnAllTests() /home/example/local-workspace/example/vendor/phpunit/phpunit-selenium/PHPUnit/Extensions/SeleniumBrowserSuite.php:93

if I do not use the dataProvider annotation, I can run tests. Why is that? Is `@dataProvider

1 Answer 1

1

The exception actually covered up another error.

Debugging revealed this:

enter image description here

So PHP Unit raised an error because my dataset was invalid (dataset needs to be an array of arrays), which somehow made PHPUnit trying to call setupSpecificBrowser() on the exception class.

Fixing the dataset fixed the error.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.