Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tearDown() is called despite unmet requirements #1374

Closed
sun opened this issue Jul 31, 2014 · 2 comments
Closed

tearDown() is called despite unmet requirements #1374

sun opened this issue Jul 31, 2014 · 2 comments

Comments

@sun
Copy link
Contributor

sun commented Jul 31, 2014

For a test with unmet requirements, setUp() is not called, but tearDown() is.

/**
 * @requires extension apc
 */
class ApcTest extends \PHPUnit_Framework_TestCase
  private $backend;
  protected function setUp() {
    parent::setUp();
    echo "IN SETUP", "\n";
    $this->backend = new ApcuBackend($bin, $this->databasePrefix);
  }
  protected function tearDown() {
    parent::tearDown();
    echo "IN TEARDOWN", "\n";
    $this->backend->removeBin();
  }
$ phpunit ApcTest ApcTest.php
IN TEARDOWN
Fatal error: Call to a member function removeBin() on a non-object in ApcTest.php

Call Stack:
0.0009 306224 1. {main}() -:0
0.0094 981208 2. __phpunit_run_isolated_test() -:705
0.0439 4311360 5. PHPUnit_Framework_TestResult->run() vendor/phpunit/phpunit/src/Framework/TestCase.php:753
0.0452 4394192 6. PHPUnit_Framework_TestCase->runBare() vendor/phpunit/phpunit/src/Framework/TestResult.php:686
0.0501 4511344 7. ApcTest->tearDown() vendor/phpunit/phpunit/src/Framework/TestCase.php:842
@whatthejeff
Copy link
Contributor

Nice catch. I'll look into this shortly if no one gets to it first.

@sun
Copy link
Contributor Author

sun commented Jul 31, 2014

Oh, sorry, totally planned to work on this. The interim workaround was too easy for now; just wanted to ensure to file a bug report while looking into gazillions of other failures, so I don't forget 😉

(Coincidentally, that approach also happens to ensure a separate issue vs. PR… 😉)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants