3

I have the following Selenium test in PHP:

<?php

require_once('PHPUnit/Extensions/SeleniumTestCase.php');

class Example extends PHPUnit_Extensions_SeleniumTestCase
{
  protected function setUp()
  {
    $this->setBrowser("*chrome");
    $this->setBrowserUrl("http://change-this-to-the-site-you-are-testing/");
  }

  public function testMyTestCase()
  {
    $this->open("/frontend_dev.php");
    try {
        $this->assertTrue($this->isTextPresent("Local Coupons"));
    } catch (PHPUnit_Framework_AssertionFailedError $e) {
        array_push($this->verificationErrors, $e->toString());
    }
  }
}

When I try to run it (by running "php filename.php") I get the error:

PHP Fatal error:  Class 'PHPUnit_Framework_TestCase' not found in /usr/share/php/PHPUnit/Extensions/SeleniumTestCase.php on line 60

Which makes sense because the class isn't defined anywhere, but why not? I installed PHPUnit. It seems a little weird that a class called PHPUnit_Framework_TestCase wouldn't be included with PHPUnit. Any ideas?

1 Answer 1

3

You should read the docs for PHPUnit for the command line test runner. You can also just run 'phpunit --help' from the command line. I believe you'll find that you need to instead run something like

phpunit path/to/filename.php
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.