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

phpunit improvements #60

Closed
basz opened this issue Oct 25, 2016 · 6 comments
Closed

phpunit improvements #60

basz opened this issue Oct 25, 2016 · 6 comments

Comments

@basz
Copy link
Collaborator

basz commented Oct 25, 2016

fix these warning

PHPUnit_Framework_TestCase::getMock() is deprecated

$this->assert should also be replaced with static::assert

@prolic
Copy link
Collaborator

prolic commented Oct 26, 2016

Do not replace $this->assert with static::assert for reasons explained here: sebastianbergmann/phpunit#1914 (comment)

@basz
Copy link
Collaborator Author

basz commented Oct 26, 2016

sigh, awesome.
Is that true for any static::phpunitMethod or only the assert* methods?

@prolic
Copy link
Collaborator

prolic commented Oct 26, 2016

like what?

@basz
Copy link
Collaborator Author

basz commented Oct 26, 2016

static::at(0), static::returnValue(...)

@prolic
Copy link
Collaborator

prolic commented Oct 26, 2016

same, use $this here

@basz basz closed this as completed Oct 26, 2016
@hopeseekr
Copy link

The PHPUnit maintainer is simply wrong on this issue. I have thoroughly analyzed PHPUnit's code, and unless we are going to declare willfully disregarding the static method calls are OK, then such an important code quality tool as PHPUnit should have code written for it using self::assertEquals() vs. the contextually ambiguous $this->assertEquals().

Or, PHPUnit needs to have a third class that does something like

// Expose static assert methods for people who need them.
class Assert
{
    public static function assertEquals($expected, $actual, $memo='')
    {
        return (new AssertLogic())->assertEquals($expected, $actual, $memo);
    }
}

Then extend TestCase against AssertLogic. Then literally everyone can be happy, at probably minimal overhead. (if the news are too much, then private static $asserter.

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