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

Annotation beforeClass with setUpBeforeClass #1794

Closed
Rey8d01 opened this issue Jul 16, 2015 · 1 comment
Closed

Annotation beforeClass with setUpBeforeClass #1794

Rey8d01 opened this issue Jul 16, 2015 · 1 comment

Comments

@Rey8d01
Copy link

Rey8d01 commented Jul 16, 2015

Hello. It may not be a problem, but it is there

<?
Yii::import('system.test.CTestCase');

abstract class ExampleTestCase extends CDbTestCase implements IConstTest
{

    public static function setUpFixtures() {
        var_dump(__METHOD__);
    }

    /**
     * @beforeClass
     */
    public static function setUpBeforeClass() {
        var_dump(__METHOD__);
        parent::setUpBeforeClass();
        static::setUpFixtures();
    }

    /**
     * @before
     */
    public function setUp() {
        var_dump(__METHOD__);
        parent::setUp();
    }
}

class ExampleTest extends ExampleTestCase
{

    /**
     * @beforeClass
     */
    public static function beforeClass1() {
        var_dump(__METHOD__);
    }

    /**
     * @beforeClass
     */
    public static function beforeClass2() {
        var_dump(__METHOD__);
    }

    public function testMethod() {
        var_dump(42);die;
    }
}

result via PHPUnit 4.7.5

PHPUnit 4.7.5 by Sebastian Bergmann and contributors.

string(33) "ExampleTestCase::setUpBeforeClass"
string(30) "ExampleTestCase::setUpFixtures"
string(25) "ExampleTest::beforeClass1"
string(25) "ExampleTest::beforeClass2"
string(22) "ExampleTestCase::setUp"
int(42)

Process finished with exit code 0

result via PHPUnit 4.7.6

duplicated call methods setUpFixtures and setUp becose it used annotation beforeClass and before

PHPUnit 4.7.6 by Sebastian Bergmann and contributors.

string(33) "ExampleTestCase::setUpBeforeClass"
string(30) "ExampleTestCase::setUpFixtures"
string(25) "ExampleTest::beforeClass1"
string(25) "ExampleTest::beforeClass2"
string(33) "ExampleTestCase::setUpBeforeClass"
string(30) "ExampleTestCase::setUpFixtures"
string(22) "ExampleTestCase::setUp"
string(22) "ExampleTestCase::setUp"
int(42)

Process finished with exit code 0

I think that it is related with the task #1763 - where is the error?

@GrahamCampbell
Copy link
Contributor

Yes the behaviour was changed so that they are now inherited.

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

3 participants