zf-fr / zfr-oauth2-server

PHP library for creating an OAuth 2 server (currently proof of concept)
BSD 3-Clause "New" or "Revised" License
36 stars 13 forks source link

phpunit improvements #60

Closed basz closed 8 years ago

basz commented 8 years ago

fix these warning

PHPUnit_Framework_TestCase::getMock() is deprecated

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

prolic commented 8 years ago

Do not replace $this->assert with static::assert for reasons explained here: https://github.com/sebastianbergmann/phpunit/issues/1914#issuecomment-148407321

basz commented 8 years ago

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

prolic commented 8 years ago

like what?

basz commented 8 years ago

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

prolic commented 8 years ago

same, use $this here

hopeseekr commented 5 years ago

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.