diff --git a/.gitignore b/.gitignore index 43d7f43e..ed2e1197 100644 --- a/.gitignore +++ b/.gitignore @@ -7,6 +7,7 @@ *.DS_Store .*.swp *.out +*.cache Thumbs.db .project .buildpath diff --git a/composer.json b/composer.json index cd29953f..dcfa3e82 100644 --- a/composer.json +++ b/composer.json @@ -39,8 +39,9 @@ "twig/twig": "~2.6.0" }, "require-dev": { + "dms/phpunit-arraysubset-asserts": "^0.1.0", "filp/whoops": "^2.1", - "phpunit/phpunit": "^6.3", + "phpunit/phpunit": "^8.1", "symfony/var-dumper": "^3.3" }, "autoload": { diff --git a/src/Database/Migration/Migration.php b/src/Database/Migration/Migration.php index fcc57b82..586cfcff 100644 --- a/src/Database/Migration/Migration.php +++ b/src/Database/Migration/Migration.php @@ -9,6 +9,11 @@ abstract class Migration /** @var SchemaBuilder */ protected $schema; + /** + * Migration constructor. + * + * @param SchemaBuilder $schemaBuilder + */ public function __construct(SchemaBuilder $schemaBuilder) { $this->schema = $schemaBuilder; diff --git a/tests/Feature/ApplicationFeatureTest.php b/tests/Feature/ApplicationFeatureTest.php index fc6216f1..3cd8b376 100644 --- a/tests/Feature/ApplicationFeatureTest.php +++ b/tests/Feature/ApplicationFeatureTest.php @@ -6,7 +6,7 @@ use PHPUnit\Framework\TestCase; abstract class ApplicationFeatureTest extends TestCase { - public static function setUpBeforeClass() + public static function setUpBeforeClass(): void { $_SERVER['HTTP_HOST'] = 'foo.bar'; require_once __DIR__ . '/../../includes/engelsystem.php'; diff --git a/tests/Feature/Database/DatabaseServiceProviderTest.php b/tests/Feature/Database/DatabaseServiceProviderTest.php index d5fdd108..d66ed25c 100644 --- a/tests/Feature/Database/DatabaseServiceProviderTest.php +++ b/tests/Feature/Database/DatabaseServiceProviderTest.php @@ -5,7 +5,7 @@ namespace Engelsystem\Test\Feature\Database; use Engelsystem\Application; use Engelsystem\Config\Config; use Engelsystem\Database\DatabaseServiceProvider; -use PHPUnit_Framework_MockObject_MockObject as MockObject; +use PHPUnit\Framework\MockObject\MockObject; class DatabaseServiceProviderTest extends DatabaseTest { @@ -14,11 +14,11 @@ class DatabaseServiceProviderTest extends DatabaseTest */ public function testRegister() { - /** @var MockObject|Config $config */ + /** @var Config|MockObject $config */ $config = $this->getMockBuilder(Config::class) ->getMock(); - /** @var MockObject|Application $app */ + /** @var Application|MockObject $app */ $app = $this->getMockBuilder(Application::class) ->setMethods(['get']) ->getMock(); diff --git a/tests/Feature/Logger/EngelsystemLoggerTest.php b/tests/Feature/Logger/EngelsystemLoggerTest.php index 9ec078a3..cb7e18f3 100644 --- a/tests/Feature/Logger/EngelsystemLoggerTest.php +++ b/tests/Feature/Logger/EngelsystemLoggerTest.php @@ -8,10 +8,12 @@ use Engelsystem\Test\Feature\ApplicationFeatureTest; use Psr\Log\InvalidArgumentException; use Psr\Log\LoggerInterface; use Psr\Log\LogLevel; +use stdClass; class EngelsystemLoggerTest extends ApplicationFeatureTest { /** + * @covers \Engelsystem\Logger\EngelsystemLogger::__construct * @return LoggerInterface */ public function getLogger() @@ -20,6 +22,9 @@ class EngelsystemLoggerTest extends ApplicationFeatureTest return new EngelsystemLogger($logEntry); } + /** + * @covers \Engelsystem\Logger\EngelsystemLogger::__construct + */ public function testImplements() { $this->assertInstanceOf(LoggerInterface::class, $this->getLogger()); @@ -43,6 +48,7 @@ class EngelsystemLoggerTest extends ApplicationFeatureTest } /** + * @covers \Engelsystem\Models\LogEntry * @dataProvider provideLogLevels * @param string $level */ @@ -58,6 +64,9 @@ class EngelsystemLoggerTest extends ApplicationFeatureTest $this->assertCount(2, $entries); } + /** + * @covers \Engelsystem\Logger\EngelsystemLogger::log + */ public function testContextReplacement() { LogEntry::query()->truncate(); @@ -78,12 +87,13 @@ class EngelsystemLoggerTest extends ApplicationFeatureTest return [ ['Data and {context}', [], 'Data and {context}'], ['Data and {context}', ['context' => null], 'Data and '], - ['Data and {context}', ['context' => new \stdClass()], 'Data and {context}'], + ['Data and {context}', ['context' => new stdClass()], 'Data and {context}'], ['Some user asked: {question}', ['question' => 'Foo?'], 'Some user asked: Foo?'], ]; } /** + * @covers \Engelsystem\Logger\EngelsystemLogger::log * @dataProvider provideContextReplaceValues * * @param string $message @@ -99,6 +109,9 @@ class EngelsystemLoggerTest extends ApplicationFeatureTest $this->assertEquals($expected, $entry['message']); } + /** + * @covers \Engelsystem\Logger\EngelsystemLogger::log + */ public function testContextToString() { LogEntry::query()->truncate(); @@ -119,19 +132,20 @@ class EngelsystemLoggerTest extends ApplicationFeatureTest } /** - * @expectedException InvalidArgumentException + * @covers \Engelsystem\Logger\EngelsystemLogger::log */ public function testThrowExceptionOnInvalidLevel() { $logger = $this->getLogger(); + $this->expectException(InvalidArgumentException::class); $logger->log('This log level should never be defined', 'Some message'); } /** * @return array */ - public function getLastEntry() + protected function getLastEntry() { $entries = LogEntry::all(); $entry = $entries->last(); @@ -139,7 +153,10 @@ class EngelsystemLoggerTest extends ApplicationFeatureTest return $entry; } - public function tearDown() + /** + * Cleanup + */ + protected function tearDown(): void { LogEntry::query()->truncate(); } diff --git a/tests/Feature/Model/LogEntryTest.php b/tests/Feature/Model/LogEntryTest.php index 25b35676..7fad8232 100644 --- a/tests/Feature/Model/LogEntryTest.php +++ b/tests/Feature/Model/LogEntryTest.php @@ -49,7 +49,7 @@ class LogEntryTest extends TestCase /** * This method is called before a test is executed. */ - public function setUp() + protected function setUp(): void { LogEntry::query()->truncate(); } diff --git a/tests/Feature/Model/RoomModelTest.php b/tests/Feature/Model/RoomModelTest.php index 216c87da..9908082a 100644 --- a/tests/Feature/Model/RoomModelTest.php +++ b/tests/Feature/Model/RoomModelTest.php @@ -8,11 +8,17 @@ class RoomModelTest extends TestCase { private $room_id = null; + /** + * @covers \Room_create + */ public function createRoom() { $this->room_id = Room_create('test', false, null, null); } + /** + * @covers \Room + */ public function testRoom() { $this->createRoom(); @@ -26,7 +32,10 @@ class RoomModelTest extends TestCase $this->assertEmpty(Room(-1)); } - public function tearDown() + /** + * Cleanup + */ + protected function tearDown(): void { if ($this->room_id != null) { Room_delete($this->room_id); diff --git a/tests/Unit/ApplicationTest.php b/tests/Unit/ApplicationTest.php index 3fffe5ea..a57488d0 100644 --- a/tests/Unit/ApplicationTest.php +++ b/tests/Unit/ApplicationTest.php @@ -6,8 +6,8 @@ use Engelsystem\Application; use Engelsystem\Config\Config; use Engelsystem\Container\Container; use Engelsystem\Container\ServiceProvider; +use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; -use PHPUnit_Framework_MockObject_MockObject; use Psr\Container\ContainerInterface; use Psr\Http\Server\MiddlewareInterface; use ReflectionClass; @@ -130,7 +130,7 @@ class ApplicationTest extends TestCase */ public function testBootstrap() { - /** @var PHPUnit_Framework_MockObject_MockObject|Application $app */ + /** @var Application|MockObject $app */ $app = $this->getMockBuilder(Application::class) ->setMethods(['register']) ->getMock(); @@ -143,6 +143,7 @@ class ApplicationTest extends TestCase ->method('register') ->with($serviceProvider); + /** @var Config|MockObject $config */ $config = $this->getMockBuilder(Config::class) ->getMock(); @@ -168,7 +169,7 @@ class ApplicationTest extends TestCase /** * @param Application $app * @param array $methods - * @return PHPUnit_Framework_MockObject_MockObject|ServiceProvider + * @return ServiceProvider|MockObject */ protected function mockServiceProvider(Application $app, $methods = []) { diff --git a/tests/Unit/Config/ConfigServiceProviderTest.php b/tests/Unit/Config/ConfigServiceProviderTest.php index b93e1b97..895496b8 100644 --- a/tests/Unit/Config/ConfigServiceProviderTest.php +++ b/tests/Unit/Config/ConfigServiceProviderTest.php @@ -2,6 +2,7 @@ namespace Engelsystem\Test\Unit\Config; +use DMS\PHPUnitExtensions\ArraySubset\ArraySubsetAsserts; use Engelsystem\Application; use Engelsystem\Config\Config; use Engelsystem\Config\ConfigServiceProvider; @@ -14,13 +15,15 @@ use PHPUnit\Framework\MockObject\MockObject; class ConfigServiceProviderTest extends ServiceProviderTest { + use ArraySubsetAsserts; + /** * @covers \Engelsystem\Config\ConfigServiceProvider::register * @covers \Engelsystem\Config\ConfigServiceProvider::getConfigPath */ public function testRegister() { - /** @var MockObject|Config $config */ + /** @var Config|MockObject $config */ $config = $this->getMockBuilder(Config::class) ->getMock(); @@ -61,7 +64,7 @@ class ConfigServiceProviderTest extends ServiceProviderTest */ public function testRegisterException() { - /** @var MockObject|Config $config */ + /** @var Config|MockObject $config */ $config = $this->getMockBuilder(Config::class) ->getMock(); diff --git a/tests/Unit/Database/DatabaseServiceProviderTest.php b/tests/Unit/Database/DatabaseServiceProviderTest.php index 7dae065f..c9c6f9e3 100644 --- a/tests/Unit/Database/DatabaseServiceProviderTest.php +++ b/tests/Unit/Database/DatabaseServiceProviderTest.php @@ -13,7 +13,7 @@ use Illuminate\Database\Capsule\Manager as CapsuleManager; use Illuminate\Database\Connection; use PDO; use PDOException; -use PHPUnit_Framework_MockObject_MockObject as MockObject; +use PHPUnit\Framework\MockObject\MockObject; class DatabaseServiceProviderTest extends ServiceProviderTest { @@ -78,13 +78,13 @@ class DatabaseServiceProviderTest extends ServiceProviderTest */ protected function prepare($dbConfigData, $getPdoThrowException = false) { - /** @var MockObject|Config $config */ + /** @var Config|MockObject $config */ $config = $this->getMockBuilder(Config::class) ->getMock(); - /** @var MockObject|CapsuleManager $config */ + /** @var CapsuleManager|MockObject $config */ $dbManager = $this->getMockBuilder(CapsuleManager::class) ->getMock(); - /** @var MockObject|Connection $connection */ + /** @var Connection|MockObject $connection */ $connection = $this->getMockBuilder(Connection::class) ->disableOriginalConstructor() ->getMock(); diff --git a/tests/Unit/Database/DatabaseTest.php b/tests/Unit/Database/DatabaseTest.php index 91d6a6c7..7aef51c3 100644 --- a/tests/Unit/Database/DatabaseTest.php +++ b/tests/Unit/Database/DatabaseTest.php @@ -6,8 +6,8 @@ use Engelsystem\Database\Database; use Illuminate\Database\Capsule\Manager as CapsuleManager; use Illuminate\Database\Connection as DatabaseConnection; use PDO; +use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; -use PHPUnit_Framework_MockObject_MockObject as MockObject; class DatabaseTest extends TestCase { @@ -69,7 +69,7 @@ class DatabaseTest extends TestCase $this->assertEmpty($return); $return = $db->selectOne('SELECT * FROM test_data WHERE id = ?', [3]); - $this->assertTrue(!is_array($return)); + $this->assertIsNotArray($return); } /** @@ -114,7 +114,7 @@ class DatabaseTest extends TestCase /** * Setup in memory database */ - protected function setUp() + protected function setUp(): void { $dbManager = new CapsuleManager(); $dbManager->addConnection(['driver' => 'sqlite', 'database' => ':memory:']); diff --git a/tests/Unit/Database/DbTest.php b/tests/Unit/Database/DbTest.php index ca6ac52c..a408f78f 100644 --- a/tests/Unit/Database/DbTest.php +++ b/tests/Unit/Database/DbTest.php @@ -6,8 +6,8 @@ use Engelsystem\Database\Db; use Illuminate\Database\Capsule\Manager as CapsuleManager; use Illuminate\Database\Connection as DatabaseConnection; use PDO; +use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; -use PHPUnit_Framework_MockObject_MockObject as MockObject; class DbTest extends TestCase { @@ -17,15 +17,15 @@ class DbTest extends TestCase */ public function testSetDbManager() { - /** @var MockObject|Pdo $pdo */ + /** @var Pdo|MockObject $pdo */ $pdo = $this->getMockBuilder(Pdo::class) ->disableOriginalConstructor() ->getMock(); - /** @var MockObject|CapsuleManager $dbManager */ + /** @var CapsuleManager|MockObject $dbManager */ $dbManager = $this->getMockBuilder(CapsuleManager::class) ->disableOriginalConstructor() ->getMock(); - /** @var MockObject|DatabaseConnection $dbManager */ + /** @var DatabaseConnection|MockObject $dbManager */ $databaseConnection = $this->getMockBuilder(DatabaseConnection::class) ->disableOriginalConstructor() ->getMock(); @@ -69,7 +69,7 @@ class DbTest extends TestCase $return = Db::selectOne('SELECT * FROM test_data WHERE id = ?', [3]); $return = array_pop($return); - $this->assertTrue(!is_array($return)); + $this->assertIsNotArray($return); } /** @@ -117,7 +117,7 @@ class DbTest extends TestCase /** * Setup in memory database */ - protected function setUp() + protected function setUp(): void { $dbManager = new CapsuleManager(); $dbManager->addConnection(['driver' => 'sqlite', 'database' => ':memory:']); diff --git a/tests/Unit/Database/Migration/MigrateTest.php b/tests/Unit/Database/Migration/MigrateTest.php index 2adbed41..3a9adbe8 100644 --- a/tests/Unit/Database/Migration/MigrateTest.php +++ b/tests/Unit/Database/Migration/MigrateTest.php @@ -21,15 +21,15 @@ class MigrateTest extends TestCase */ public function testRun() { - /** @var MockObject|Application $app */ + /** @var Application|MockObject $app */ $app = $this->getMockBuilder(Application::class) ->setMethods(['instance']) ->getMock(); - /** @var MockObject|SchemaBuilder $builder */ + /** @var SchemaBuilder|MockObject $builder */ $builder = $this->getMockBuilder(SchemaBuilder::class) ->disableOriginalConstructor() ->getMock(); - /** @var MockObject|Migrate $migration */ + /** @var Migrate|MockObject $migration */ $migration = $this->getMockBuilder(Migrate::class) ->setConstructorArgs([$builder, $app]) ->setMethods(['initMigration', 'getMigrationFiles', 'getMigrated', 'migrate', 'setMigrated']) diff --git a/tests/Unit/Database/Migration/MigrationServiceProviderTest.php b/tests/Unit/Database/Migration/MigrationServiceProviderTest.php index 593da5c5..589bda9c 100644 --- a/tests/Unit/Database/Migration/MigrationServiceProviderTest.php +++ b/tests/Unit/Database/Migration/MigrationServiceProviderTest.php @@ -8,7 +8,7 @@ use Engelsystem\Database\Migration\MigrationServiceProvider; use Engelsystem\Test\Unit\ServiceProviderTest; use Illuminate\Database\Connection; use Illuminate\Database\Schema\Builder as SchemaBuilder; -use PHPUnit_Framework_MockObject_MockObject as MockObject; +use PHPUnit\Framework\MockObject\MockObject; class MigrationServiceProviderTest extends ServiceProviderTest { @@ -17,7 +17,7 @@ class MigrationServiceProviderTest extends ServiceProviderTest */ public function testRegister() { - /** @var MockObject|Migrate $migration */ + /** @var Migrate|MockObject $migration */ $migration = $this->getMockBuilder(Migrate::class) ->disableOriginalConstructor() ->getMock(); @@ -25,11 +25,11 @@ class MigrationServiceProviderTest extends ServiceProviderTest $database = $this->getMockBuilder(Database::class) ->disableOriginalConstructor() ->getMock(); - /** @var MockObject|Connection $dbConnection */ + /** @var Connection|MockObject $dbConnection */ $dbConnection = $this->getMockBuilder(Connection::class) ->disableOriginalConstructor() ->getMock(); - /** @var MockObject|SchemaBuilder $schemaBuilder */ + /** @var SchemaBuilder|MockObject $schemaBuilder */ $schemaBuilder = $this->getMockBuilder(SchemaBuilder::class) ->disableOriginalConstructor() ->getMock(); diff --git a/tests/Unit/Database/Migration/MigrationTest.php b/tests/Unit/Database/Migration/MigrationTest.php index 2fa1b6c0..a9c70ecc 100644 --- a/tests/Unit/Database/Migration/MigrationTest.php +++ b/tests/Unit/Database/Migration/MigrationTest.php @@ -19,6 +19,6 @@ class MigrationTest extends TestCase ->getMock(); $instance = new AnotherStuff($schemaBuilder); - $this->assertAttributeEquals($schemaBuilder, 'schema', $instance); + $this->assertEquals($schemaBuilder, $instance->getSchema()); } } diff --git a/tests/Unit/Database/Migration/Stub/2017_12_24_053300_another_stuff.php b/tests/Unit/Database/Migration/Stub/2017_12_24_053300_another_stuff.php index 65846d16..4adaf3ed 100644 --- a/tests/Unit/Database/Migration/Stub/2017_12_24_053300_another_stuff.php +++ b/tests/Unit/Database/Migration/Stub/2017_12_24_053300_another_stuff.php @@ -3,6 +3,7 @@ namespace Engelsystem\Migrations; use Engelsystem\Database\Migration\Migration; +use Illuminate\Database\Schema\Builder as SchemaBuilder; class AnotherStuff extends Migration { @@ -21,4 +22,12 @@ class AnotherStuff extends Migration { // nope } + + /** + * @return SchemaBuilder + */ + public function getSchema() + { + return $this->schema; + } } diff --git a/tests/Unit/Exceptions/ExceptionsServiceProviderTest.php b/tests/Unit/Exceptions/ExceptionsServiceProviderTest.php index 4f2ae654..b484f41f 100644 --- a/tests/Unit/Exceptions/ExceptionsServiceProviderTest.php +++ b/tests/Unit/Exceptions/ExceptionsServiceProviderTest.php @@ -10,7 +10,7 @@ use Engelsystem\Exceptions\Handlers\LegacyDevelopment; use Engelsystem\Exceptions\Handlers\Whoops; use Engelsystem\Http\Request; use Engelsystem\Test\Unit\ServiceProviderTest; -use PHPUnit_Framework_MockObject_MockObject as MockObject; +use PHPUnit\Framework\MockObject\MockObject; class ExceptionsServiceProviderTest extends ServiceProviderTest { @@ -23,7 +23,7 @@ class ExceptionsServiceProviderTest extends ServiceProviderTest { $app = $this->getApp(['make', 'instance', 'bind']); - /** @var MockObject|Handler $handler */ + /** @var Handler|MockObject $handler */ $handler = $this->createMock(Handler::class); $this->setExpects($handler, 'register'); /** @var Legacy|MockObject $legacyHandler */ @@ -81,10 +81,10 @@ class ExceptionsServiceProviderTest extends ServiceProviderTest */ public function testBoot() { - /** @var MockObject|Handler $handler */ + /** @var Handler|MockObject $handler */ $handler = $this->createMock(Handler::class); - /** @var MockObject|Request $request */ + /** @var Request|MockObject $request */ $request = $this->createMock(Request::class); $handler->expects($this->once()) diff --git a/tests/Unit/Exceptions/HandlerTest.php b/tests/Unit/Exceptions/HandlerTest.php index 58d25de3..af89dae7 100644 --- a/tests/Unit/Exceptions/HandlerTest.php +++ b/tests/Unit/Exceptions/HandlerTest.php @@ -7,8 +7,8 @@ use Engelsystem\Exceptions\Handlers\HandlerInterface; use Engelsystem\Http\Request; use ErrorException; use Exception; +use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; -use PHPUnit_Framework_MockObject_MockObject as Mock; class HandlerTest extends TestCase { @@ -17,7 +17,7 @@ class HandlerTest extends TestCase */ public function testCreate() { - /** @var Handler|Mock $handler */ + /** @var Handler|MockObject $handler */ $handler = new Handler(); $this->assertInstanceOf(Handler::class, $handler); $this->assertEquals(Handler::ENV_PRODUCTION, $handler->getEnvironment()); @@ -31,7 +31,7 @@ class HandlerTest extends TestCase */ public function testErrorHandler() { - /** @var Handler|Mock $handler */ + /** @var Handler|MockObject $handler */ $handler = $this->getMockBuilder(Handler::class) ->setMethods(['exceptionHandler']) ->getMock(); @@ -51,7 +51,7 @@ class HandlerTest extends TestCase $exception = new Exception(); $errorMessage = 'Oh noes, an error!'; - /** @var HandlerInterface|Mock $handlerMock */ + /** @var HandlerInterface|MockObject $handlerMock */ $handlerMock = $this->getMockForAbstractClass(HandlerInterface::class); $handlerMock->expects($this->atLeastOnce()) ->method('report') @@ -63,7 +63,7 @@ class HandlerTest extends TestCase echo $errorMessage; }); - /** @var Handler|Mock $handler */ + /** @var Handler|MockObject $handler */ $handler = $this->getMockBuilder(Handler::class) ->setMethods(['terminateApplicationImmediately']) ->getMock(); @@ -84,7 +84,7 @@ class HandlerTest extends TestCase */ public function testRegister() { - /** @var Handler|Mock $handler */ + /** @var Handler|MockObject $handler */ $handler = $this->getMockForAbstractClass(Handler::class); $handler->register(); @@ -120,9 +120,9 @@ class HandlerTest extends TestCase public function testHandler() { $handler = new Handler(); - /** @var HandlerInterface|Mock $devHandler */ + /** @var HandlerInterface|MockObject $devHandler */ $devHandler = $this->getMockForAbstractClass(HandlerInterface::class); - /** @var HandlerInterface|Mock $prodHandler */ + /** @var HandlerInterface|MockObject $prodHandler */ $prodHandler = $this->getMockForAbstractClass(HandlerInterface::class); $handler->setHandler(Handler::ENV_DEVELOPMENT, $devHandler); @@ -139,7 +139,7 @@ class HandlerTest extends TestCase public function testRequest() { $handler = new Handler(); - /** @var Request|Mock $request */ + /** @var Request|MockObject $request */ $request = $this->createMock(Request::class); $handler->setRequest($request); diff --git a/tests/Unit/Exceptions/Handlers/LegacyDevelopmentTest.php b/tests/Unit/Exceptions/Handlers/LegacyDevelopmentTest.php index d5390c9e..bc4625e9 100644 --- a/tests/Unit/Exceptions/Handlers/LegacyDevelopmentTest.php +++ b/tests/Unit/Exceptions/Handlers/LegacyDevelopmentTest.php @@ -6,8 +6,8 @@ namespace Engelsystem\Test\Unit\Exceptions\handlers; use Engelsystem\Exceptions\Handlers\LegacyDevelopment; use Engelsystem\Http\Request; use ErrorException; +use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; -use PHPUnit_Framework_MockObject_MockObject as Mock; class LegacyDevelopmentTest extends TestCase { @@ -18,7 +18,7 @@ class LegacyDevelopmentTest extends TestCase public function testRender() { $handler = new LegacyDevelopment(); - /** @var Request|Mock $request */ + /** @var Request|MockObject $request */ $request = $this->createMock(Request::class); $exception = new ErrorException('Lorem Ipsum', 4242, 1, 'foo.php', 9999); diff --git a/tests/Unit/Exceptions/Handlers/LegacyTest.php b/tests/Unit/Exceptions/Handlers/LegacyTest.php index 04b214f2..d7d65daf 100644 --- a/tests/Unit/Exceptions/Handlers/LegacyTest.php +++ b/tests/Unit/Exceptions/Handlers/LegacyTest.php @@ -6,8 +6,8 @@ namespace Engelsystem\Test\Unit\Exceptions\handlers; use Engelsystem\Exceptions\Handlers\Legacy; use Engelsystem\Http\Request; use Exception; +use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; -use PHPUnit_Framework_MockObject_MockObject as Mock; class LegacyTest extends TestCase { @@ -17,9 +17,9 @@ class LegacyTest extends TestCase public function testRender() { $handler = new Legacy(); - /** @var Request|Mock $request */ + /** @var Request|MockObject $request */ $request = $this->createMock(Request::class); - /** @var Exception|Mock $exception */ + /** @var Exception|MockObject $exception */ $exception = $this->createMock(Exception::class); $this->expectOutputRegex('/.*error occurred.*/i'); @@ -45,11 +45,11 @@ class LegacyTest extends TestCase $logContent = file_get_contents($log); unset($log); - $this->assertContains('4242', $logContent); - $this->assertContains('Lorem Ipsum', $logContent); - $this->assertContains(basename(__FILE__), $logContent); - $this->assertContains((string)$line, $logContent); - $this->assertContains(__FUNCTION__, $logContent); - $this->assertContains(json_encode(__CLASS__), $logContent); + $this->assertStringContainsString('4242', $logContent); + $this->assertStringContainsString('Lorem Ipsum', $logContent); + $this->assertStringContainsString(basename(__FILE__), $logContent); + $this->assertStringContainsString((string)$line, $logContent); + $this->assertStringContainsString(__FUNCTION__, $logContent); + $this->assertStringContainsString(json_encode(__CLASS__), $logContent); } } diff --git a/tests/Unit/Exceptions/Handlers/WhoopsTest.php b/tests/Unit/Exceptions/Handlers/WhoopsTest.php index 4949c45a..74bdc457 100644 --- a/tests/Unit/Exceptions/Handlers/WhoopsTest.php +++ b/tests/Unit/Exceptions/Handlers/WhoopsTest.php @@ -8,8 +8,8 @@ use Engelsystem\Exceptions\Handlers\Whoops; use Engelsystem\Helpers\Authenticator; use Engelsystem\Http\Request; use Exception; +use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; -use PHPUnit_Framework_MockObject_MockObject as Mock; use Whoops\Handler\JsonResponseHandler; use Whoops\Handler\PrettyPageHandler; use Whoops\Run as WhoopsRunner; @@ -22,19 +22,19 @@ class WhoopsTest extends TestCase */ public function testRender() { - /** @var Application|Mock $app */ + /** @var Application|MockObject $app */ $app = $this->createMock(Application::class); - /** @var Authenticator|Mock $auth */ + /** @var Authenticator|MockObject $auth */ $auth = $this->createMock(Authenticator::class); - /** @var Request|Mock $request */ + /** @var Request|MockObject $request */ $request = $this->createMock(Request::class); - /** @var WhoopsRunnerInterface|Mock $whoopsRunner */ + /** @var WhoopsRunnerInterface|MockObject $whoopsRunner */ $whoopsRunner = $this->getMockForAbstractClass(WhoopsRunnerInterface::class); - /** @var PrettyPageHandler|Mock $prettyPageHandler */ + /** @var PrettyPageHandler|MockObject $prettyPageHandler */ $prettyPageHandler = $this->createMock(PrettyPageHandler::class); - /** @var JsonResponseHandler|Mock $jsonResponseHandler */ + /** @var JsonResponseHandler|MockObject $jsonResponseHandler */ $jsonResponseHandler = $this->createMock(JsonResponseHandler::class); - /** @var Exception|Mock $exception */ + /** @var Exception|MockObject $exception */ $exception = $this->createMock(Exception::class); $request->expects($this->once()) diff --git a/tests/Unit/Helpers/AuthenticatorTest.php b/tests/Unit/Helpers/AuthenticatorTest.php index 05c7d16e..400278f2 100644 --- a/tests/Unit/Helpers/AuthenticatorTest.php +++ b/tests/Unit/Helpers/AuthenticatorTest.php @@ -39,11 +39,11 @@ class AuthenticatorTest extends ServiceProviderTest $auth = new Authenticator($request, $session, $userRepository); // Not in session - $this->assertEquals(null, $auth->user()); + $this->assertNull($auth->user()); // Unknown user UserModelImplementation::$id = 42; - $this->assertEquals(null, $auth->user()); + $this->assertNull($auth->user()); // User found UserModelImplementation::$id = 1337; @@ -83,11 +83,11 @@ class AuthenticatorTest extends ServiceProviderTest $auth = new Authenticator($request, $session, $userRepository); // No key - $this->assertEquals(null, $auth->apiUser()); + $this->assertNull($auth->apiUser()); // Unknown user UserModelImplementation::$apiKey = 'iMaNot3xiSt1nGAp1Key!'; - $this->assertEquals(null, $auth->apiUser()); + $this->assertNull($auth->apiUser()); // User found UserModelImplementation::$apiKey = 'SomeSecretApiKey'; diff --git a/tests/Unit/HelpersTest.php b/tests/Unit/HelpersTest.php index e0184b86..210e995e 100644 --- a/tests/Unit/HelpersTest.php +++ b/tests/Unit/HelpersTest.php @@ -11,8 +11,8 @@ use Engelsystem\Http\Request; use Engelsystem\Http\Response; use Engelsystem\Http\UrlGeneratorInterface; use Engelsystem\Renderer\Renderer; +use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; -use PHPUnit_Framework_MockObject_MockObject as MockObject; use Symfony\Component\HttpFoundation\Session\Session; use Symfony\Component\HttpFoundation\Session\Storage\SessionStorageInterface as StorageInterface; @@ -59,7 +59,7 @@ class HelpersTest extends TestCase */ public function testBasePath() { - /** @var MockObject|Application $app */ + /** @var Application|MockObject $app */ $app = $this->getMockBuilder(Container::class) ->getMock(); Application::setInstance($app); @@ -103,7 +103,7 @@ class HelpersTest extends TestCase */ public function testConfigPath() { - /** @var MockObject|Application $app */ + /** @var Application|MockObject $app */ $app = $this->getMockBuilder(Container::class) ->getMock(); Application::setInstance($app); @@ -155,7 +155,7 @@ class HelpersTest extends TestCase */ public function testResponse() { - /** @var MockObject|Response $response */ + /** @var Response|MockObject $response */ $response = $this->getMockBuilder(Response::class)->getMock(); $this->getAppMock('psr7.response', $response); diff --git a/tests/Unit/Http/MessageTraitRequestTest.php b/tests/Unit/Http/MessageTraitRequestTest.php index 31ba249f..31ce68c3 100644 --- a/tests/Unit/Http/MessageTraitRequestTest.php +++ b/tests/Unit/Http/MessageTraitRequestTest.php @@ -2,12 +2,15 @@ namespace Engelsystem\Test\Unit\Http; +use DMS\PHPUnitExtensions\ArraySubset\ArraySubsetAsserts; use Engelsystem\Test\Unit\Http\Stub\MessageTraitRequestImplementation; use Nyholm\Psr7\Stream; use PHPUnit\Framework\TestCase; class MessageTraitRequestTest extends TestCase { + use ArraySubsetAsserts; + /** * @covers \Engelsystem\Http\MessageTrait::withProtocolVersion */ diff --git a/tests/Unit/Http/MessageTraitResponseTest.php b/tests/Unit/Http/MessageTraitResponseTest.php index 9174eadd..33e8dc6b 100644 --- a/tests/Unit/Http/MessageTraitResponseTest.php +++ b/tests/Unit/Http/MessageTraitResponseTest.php @@ -2,6 +2,7 @@ namespace Engelsystem\Test\Unit\Http; +use DMS\PHPUnitExtensions\ArraySubset\ArraySubsetAsserts; use Engelsystem\Test\Unit\Http\Stub\MessageTraitResponseImplementation; use Nyholm\Psr7\Stream; use PHPUnit\Framework\TestCase; @@ -11,6 +12,8 @@ use Symfony\Component\HttpFoundation\Response as SymfonyResponse; class MessageTraitResponseTest extends TestCase { + use ArraySubsetAsserts; + /** * @covers \Engelsystem\Http\MessageTrait */ diff --git a/tests/Unit/Http/RequestServiceProviderTest.php b/tests/Unit/Http/RequestServiceProviderTest.php index 4e9bb4e0..0a2ae31d 100644 --- a/tests/Unit/Http/RequestServiceProviderTest.php +++ b/tests/Unit/Http/RequestServiceProviderTest.php @@ -7,7 +7,7 @@ use Engelsystem\Container\ServiceProvider; use Engelsystem\Http\Request; use Engelsystem\Http\RequestServiceProvider; use Engelsystem\Test\Unit\ServiceProviderTest; -use PHPUnit_Framework_MockObject_MockObject as MockObject; +use PHPUnit\Framework\MockObject\MockObject; use Symfony\Component\HttpFoundation\Request as SymfonyRequest; class RequestServiceProviderTest extends ServiceProviderTest diff --git a/tests/Unit/Http/RequestTest.php b/tests/Unit/Http/RequestTest.php index df171905..26bf0116 100644 --- a/tests/Unit/Http/RequestTest.php +++ b/tests/Unit/Http/RequestTest.php @@ -4,8 +4,8 @@ namespace Engelsystem\Test\Unit\Http; use Engelsystem\Http\Request; use Nyholm\Psr7\UploadedFile; +use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; -use PHPUnit_Framework_MockObject_MockObject as MockObject; use Psr\Http\Message\RequestInterface; use Psr\Http\Message\UploadedFileInterface; use Psr\Http\Message\UriInterface; @@ -90,7 +90,7 @@ class RequestTest extends TestCase */ public function testPath() { - /** @var MockObject|Request $request */ + /** @var Request|MockObject $request */ $request = $this ->getMockBuilder(Request::class) ->setMethods(['getPathInfo']) @@ -113,7 +113,7 @@ class RequestTest extends TestCase */ public function testUrl() { - /** @var MockObject|Request $request */ + /** @var Request|MockObject $request */ $request = $this ->getMockBuilder(Request::class) ->setMethods(['getUri']) @@ -368,7 +368,7 @@ class RequestTest extends TestCase $request = new Request([], [], $attributes); $this->assertEquals($attributes['ipsum'], $request->getAttribute('ipsum')); - $this->assertEquals(null, $request->getAttribute('dolor')); + $this->assertNull($request->getAttribute('dolor')); $this->assertEquals(1234, $request->getAttribute('test', 1234)); } diff --git a/tests/Unit/Http/ResponseServiceProviderTest.php b/tests/Unit/Http/ResponseServiceProviderTest.php index 6ce1f4fe..de252b99 100644 --- a/tests/Unit/Http/ResponseServiceProviderTest.php +++ b/tests/Unit/Http/ResponseServiceProviderTest.php @@ -5,7 +5,7 @@ namespace Engelsystem\Test\Unit\Http; use Engelsystem\Http\Response; use Engelsystem\Http\ResponseServiceProvider; use Engelsystem\Test\Unit\ServiceProviderTest; -use PHPUnit_Framework_MockObject_MockObject as MockObject; +use PHPUnit\Framework\MockObject\MockObject; use Symfony\Component\HttpFoundation\Response as SymfonyResponse; class ResponseServiceProviderTest extends ServiceProviderTest @@ -15,7 +15,7 @@ class ResponseServiceProviderTest extends ServiceProviderTest */ public function testRegister() { - /** @var MockObject|Response $response */ + /** @var Response|MockObject $response */ $response = $this->getMockBuilder(Response::class) ->getMock(); diff --git a/tests/Unit/Http/ResponseTest.php b/tests/Unit/Http/ResponseTest.php index d7dc37c0..6f57e1db 100644 --- a/tests/Unit/Http/ResponseTest.php +++ b/tests/Unit/Http/ResponseTest.php @@ -2,8 +2,10 @@ namespace Engelsystem\Test\Unit\Http; +use DMS\PHPUnitExtensions\ArraySubset\ArraySubsetAsserts; use Engelsystem\Http\Response; use Engelsystem\Renderer\Renderer; +use InvalidArgumentException; use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; use Psr\Http\Message\ResponseInterface; @@ -11,6 +13,8 @@ use Symfony\Component\HttpFoundation\Response as SymfonyResponse; class ResponseTest extends TestCase { + use ArraySubsetAsserts; + /** * @covers \Engelsystem\Http\Response */ @@ -76,7 +80,7 @@ class ResponseTest extends TestCase */ public function testWithViewNoRenderer() { - $this->expectException(\InvalidArgumentException::class); + $this->expectException(InvalidArgumentException::class); $response = new Response(); $response->withView('foo'); diff --git a/tests/Unit/Http/SessionHandlers/DatabaseHandlerTest.php b/tests/Unit/Http/SessionHandlers/DatabaseHandlerTest.php index ea4f3701..61ab982d 100644 --- a/tests/Unit/Http/SessionHandlers/DatabaseHandlerTest.php +++ b/tests/Unit/Http/SessionHandlers/DatabaseHandlerTest.php @@ -88,7 +88,7 @@ class DatabaseHandlerTest extends TestCase /** * Prepare tests */ - protected function setUp() + protected function setUp(): void { $this->initDatabase(); } diff --git a/tests/Unit/Http/SessionServiceProviderTest.php b/tests/Unit/Http/SessionServiceProviderTest.php index 70e751f3..204cfe1e 100644 --- a/tests/Unit/Http/SessionServiceProviderTest.php +++ b/tests/Unit/Http/SessionServiceProviderTest.php @@ -7,7 +7,7 @@ use Engelsystem\Http\Request; use Engelsystem\Http\SessionHandlers\DatabaseHandler; use Engelsystem\Http\SessionServiceProvider; use Engelsystem\Test\Unit\ServiceProviderTest; -use PHPUnit_Framework_MockObject_MockObject as MockObject; +use PHPUnit\Framework\MockObject\MockObject; use Symfony\Component\HttpFoundation\Session\Session; use Symfony\Component\HttpFoundation\Session\SessionInterface; use Symfony\Component\HttpFoundation\Session\Storage\MockArraySessionStorage; @@ -33,7 +33,7 @@ class SessionServiceProviderTest extends ServiceProviderTest $session = $this->getSessionMock(); $request = $this->getRequestMock(); - /** @var MockObject|SessionServiceProvider $serviceProvider */ + /** @var SessionServiceProvider|MockObject $serviceProvider */ $serviceProvider = $this->getMockBuilder(SessionServiceProvider::class) ->setConstructorArgs([$app]) ->setMethods(['isCli']) diff --git a/tests/Unit/Http/UrlGeneratorServiceProviderTest.php b/tests/Unit/Http/UrlGeneratorServiceProviderTest.php index 720af631..c396c05a 100644 --- a/tests/Unit/Http/UrlGeneratorServiceProviderTest.php +++ b/tests/Unit/Http/UrlGeneratorServiceProviderTest.php @@ -5,7 +5,7 @@ namespace Engelsystem\Test\Unit\Http; use Engelsystem\Http\UrlGenerator; use Engelsystem\Http\UrlGeneratorServiceProvider; use Engelsystem\Test\Unit\ServiceProviderTest; -use PHPUnit_Framework_MockObject_MockObject; +use PHPUnit\Framework\MockObject\MockObject; class UrlGeneratorServiceProviderTest extends ServiceProviderTest { @@ -14,7 +14,7 @@ class UrlGeneratorServiceProviderTest extends ServiceProviderTest */ public function testRegister() { - /** @var PHPUnit_Framework_MockObject_MockObject|UrlGenerator $urlGenerator */ + /** @var UrlGenerator|MockObject $urlGenerator */ $urlGenerator = $this->getMockBuilder(UrlGenerator::class) ->getMock(); diff --git a/tests/Unit/Logger/LoggerServiceProviderTest.php b/tests/Unit/Logger/LoggerServiceProviderTest.php index aef0b7d1..304ee6a1 100644 --- a/tests/Unit/Logger/LoggerServiceProviderTest.php +++ b/tests/Unit/Logger/LoggerServiceProviderTest.php @@ -5,7 +5,7 @@ namespace Engelsystem\Test\Unit\Logger; use Engelsystem\Logger\EngelsystemLogger; use Engelsystem\Logger\LoggerServiceProvider; use Engelsystem\Test\Unit\ServiceProviderTest; -use PHPUnit_Framework_MockObject_MockObject; +use PHPUnit\Framework\MockObject\MockObject; use Psr\Log\LoggerInterface; class LoggerServiceProviderTest extends ServiceProviderTest @@ -15,7 +15,7 @@ class LoggerServiceProviderTest extends ServiceProviderTest */ public function testRegister() { - /** @var PHPUnit_Framework_MockObject_MockObject|EngelsystemLogger $logger */ + /** @var EngelsystemLogger|MockObject $logger */ $logger = $this->getMockBuilder(EngelsystemLogger::class) ->disableOriginalConstructor() ->getMock(); diff --git a/tests/Unit/Mail/Transport/LogTransportTest.php b/tests/Unit/Mail/Transport/LogTransportTest.php index 5eb3a667..bf3ec5dc 100644 --- a/tests/Unit/Mail/Transport/LogTransportTest.php +++ b/tests/Unit/Mail/Transport/LogTransportTest.php @@ -35,13 +35,13 @@ class LogTransportTest extends TestCase ->method('debug') ->willReturnCallback(function ($message, $context = []) { foreach (array_keys($context) as $key) { - $this->assertContains(sprintf('{%s}', $key), $message); + $this->assertStringContainsString(sprintf('{%s}', $key), $message); } $this->assertEquals('Some subject', $context['title']); $this->assertEquals('foo@bar.batz,Lorem Ipsum ', $context['recipients']); - $this->assertContains('Head: er', $context['content']); - $this->assertContains('Message body', $context['content']); + $this->assertStringContainsString('Head: er', $context['content']); + $this->assertStringContainsString('Message body', $context['content']); }); /** @var LogTransport|MockObject $transport */ diff --git a/tests/Unit/Middleware/AddHeadersTest.php b/tests/Unit/Middleware/AddHeadersTest.php index 1a1a9e71..be61f9e9 100644 --- a/tests/Unit/Middleware/AddHeadersTest.php +++ b/tests/Unit/Middleware/AddHeadersTest.php @@ -2,16 +2,19 @@ namespace Engelsystem\Test\Unit\Middleware; +use DMS\PHPUnitExtensions\ArraySubset\ArraySubsetAsserts; use Engelsystem\Config\Config; use Engelsystem\Http\Response; use Engelsystem\Middleware\AddHeaders; +use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; -use PHPUnit_Framework_MockObject_MockObject as MockObject; use Psr\Http\Message\ServerRequestInterface; use Psr\Http\Server\RequestHandlerInterface; class AddHeadersTest extends TestCase { + use ArraySubsetAsserts; + /** * @covers \Engelsystem\Middleware\AddHeaders::__construct * @covers \Engelsystem\Middleware\AddHeaders::process diff --git a/tests/Unit/Middleware/DispatcherTest.php b/tests/Unit/Middleware/DispatcherTest.php index 4e1c51a7..6a6d9113 100644 --- a/tests/Unit/Middleware/DispatcherTest.php +++ b/tests/Unit/Middleware/DispatcherTest.php @@ -7,8 +7,8 @@ use Engelsystem\Middleware\Dispatcher; use Engelsystem\Test\Unit\Middleware\Stub\NotARealMiddleware; use InvalidArgumentException; use LogicException; +use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; -use PHPUnit_Framework_MockObject_MockObject as MockObject; use Psr\Http\Message\ResponseInterface; use Psr\Http\Message\ServerRequestInterface; use Psr\Http\Server\MiddlewareInterface; diff --git a/tests/Unit/Middleware/ExceptionHandlerTest.php b/tests/Unit/Middleware/ExceptionHandlerTest.php index 6d2a20e6..33429cc0 100644 --- a/tests/Unit/Middleware/ExceptionHandlerTest.php +++ b/tests/Unit/Middleware/ExceptionHandlerTest.php @@ -9,8 +9,8 @@ use Engelsystem\Middleware\ExceptionHandler; use Engelsystem\Test\Unit\Middleware\Stub\ExceptionMiddlewareHandler; use Engelsystem\Test\Unit\Middleware\Stub\ReturnResponseMiddlewareHandler; use Illuminate\Contracts\Container\Container as ContainerInterface; +use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; -use PHPUnit_Framework_MockObject_MockObject as MockObject; use Psr\Http\Message\ResponseInterface; use Psr\Http\Message\ServerRequestInterface; @@ -22,13 +22,13 @@ class ExceptionHandlerTest extends TestCase */ public function testRegister() { - /** @var MockObject|ContainerInterface $container */ + /** @var ContainerInterface|MockObject $container */ $container = $this->getMockForAbstractClass(ContainerInterface::class); - /** @var MockObject|ServerRequestInterface $request */ + /** @var ServerRequestInterface|MockObject $request */ $request = $this->getMockBuilder(ServerRequestInterface::class)->getMock(); - /** @var MockObject|ResponseInterface $response */ + /** @var ResponseInterface|MockObject $response */ $response = $this->getMockBuilder(Response::class)->getMock(); - /** @var MockObject|Handler $errorHandler */ + /** @var Handler|MockObject $errorHandler */ $errorHandler = $this->getMockBuilder(Handler::class)->getMock(); $returnResponseHandler = new ReturnResponseMiddlewareHandler($response); $throwExceptionHandler = new ExceptionMiddlewareHandler(); diff --git a/tests/Unit/Middleware/LegacyMiddlewareTest.php b/tests/Unit/Middleware/LegacyMiddlewareTest.php index 8dd2f417..0589340a 100644 --- a/tests/Unit/Middleware/LegacyMiddlewareTest.php +++ b/tests/Unit/Middleware/LegacyMiddlewareTest.php @@ -6,8 +6,8 @@ use Engelsystem\Helpers\Authenticator; use Engelsystem\Helpers\Translator; use Engelsystem\Http\Request; use Engelsystem\Middleware\LegacyMiddleware; +use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; -use PHPUnit_Framework_MockObject_MockObject as MockObject; use Psr\Container\ContainerInterface; use Psr\Http\Message\ResponseInterface; use Psr\Http\Message\ServerRequestInterface; diff --git a/tests/Unit/Middleware/SendResponseHandlerTest.php b/tests/Unit/Middleware/SendResponseHandlerTest.php index 7431299e..427cd313 100644 --- a/tests/Unit/Middleware/SendResponseHandlerTest.php +++ b/tests/Unit/Middleware/SendResponseHandlerTest.php @@ -3,8 +3,8 @@ namespace Engelsystem\Test\Unit\Middleware; use Engelsystem\Middleware\SendResponseHandler; +use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; -use PHPUnit_Framework_MockObject_MockObject as MockObject; use Psr\Http\Message\ResponseInterface; use Psr\Http\Message\ServerRequestInterface; use Psr\Http\Server\RequestHandlerInterface; diff --git a/tests/Unit/Middleware/SessionHandlerServiceProviderTest.php b/tests/Unit/Middleware/SessionHandlerServiceProviderTest.php index bb4f7e92..eb780974 100644 --- a/tests/Unit/Middleware/SessionHandlerServiceProviderTest.php +++ b/tests/Unit/Middleware/SessionHandlerServiceProviderTest.php @@ -34,7 +34,7 @@ class SessionHandlerServiceProviderTest extends ServiceProviderTest ->willReturnCallback(function (callable $callable) { $paths = $callable(); - $this->assertTrue(is_array($paths)); + $this->assertIsArray($paths); $this->assertTrue(in_array('/metrics', $paths)); }); diff --git a/tests/Unit/Middleware/SessionHandlerTest.php b/tests/Unit/Middleware/SessionHandlerTest.php index 4abd71a6..3611b5c0 100644 --- a/tests/Unit/Middleware/SessionHandlerTest.php +++ b/tests/Unit/Middleware/SessionHandlerTest.php @@ -3,8 +3,8 @@ namespace Engelsystem\Test\Unit\Middleware; use Engelsystem\Middleware\SessionHandler; +use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; -use PHPUnit_Framework_MockObject_MockObject as MockObject; use Psr\Http\Message\ResponseInterface; use Psr\Http\Message\ServerRequestInterface; use Psr\Http\Server\RequestHandlerInterface; diff --git a/tests/Unit/Middleware/SetLocaleTest.php b/tests/Unit/Middleware/SetLocaleTest.php index c4e9d2a4..dc68d83a 100644 --- a/tests/Unit/Middleware/SetLocaleTest.php +++ b/tests/Unit/Middleware/SetLocaleTest.php @@ -4,8 +4,8 @@ namespace Engelsystem\Test\Unit\Middleware; use Engelsystem\Helpers\Translator; use Engelsystem\Middleware\SetLocale; +use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; -use PHPUnit_Framework_MockObject_MockObject as MockObject; use Psr\Http\Message\ResponseInterface; use Psr\Http\Message\ServerRequestInterface; use Psr\Http\Server\RequestHandlerInterface; diff --git a/tests/Unit/Models/EventConfigTest.php b/tests/Unit/Models/EventConfigTest.php index f08e8801..5a0286b5 100644 --- a/tests/Unit/Models/EventConfigTest.php +++ b/tests/Unit/Models/EventConfigTest.php @@ -121,7 +121,7 @@ class EventConfigTest extends TestCase /** * Prepare test */ - protected function setUp() + protected function setUp(): void { $this->initDatabase(); } diff --git a/tests/Unit/Models/User/HasUserModelTest.php b/tests/Unit/Models/User/HasUserModelTest.php index 07f3d726..58c01e1e 100644 --- a/tests/Unit/Models/User/HasUserModelTest.php +++ b/tests/Unit/Models/User/HasUserModelTest.php @@ -26,7 +26,7 @@ class HasUserModelTest extends TestCase /** * Prepare test */ - protected function setUp() + protected function setUp(): void { $this->initDatabase(); } diff --git a/tests/Unit/Models/User/UserTest.php b/tests/Unit/Models/User/UserTest.php index 9e967892..478c02dd 100644 --- a/tests/Unit/Models/User/UserTest.php +++ b/tests/Unit/Models/User/UserTest.php @@ -2,6 +2,7 @@ namespace Engelsystem\Test\Unit\Models; +use DMS\PHPUnitExtensions\ArraySubset\ArraySubsetAsserts; use Engelsystem\Models\User\Contact; use Engelsystem\Models\User\HasUserModel; use Engelsystem\Models\User\PersonalData; @@ -13,6 +14,7 @@ use PHPUnit\Framework\TestCase; class UserTest extends TestCase { + use ArraySubsetAsserts; use HasDatabase; protected $data = [ @@ -91,7 +93,7 @@ class UserTest extends TestCase /** * Prepare test */ - protected function setUp() + protected function setUp(): void { $this->initDatabase(); } diff --git a/tests/Unit/Renderer/HtmlEngineTest.php b/tests/Unit/Renderer/HtmlEngineTest.php index 8c262932..4a31e4bc 100644 --- a/tests/Unit/Renderer/HtmlEngineTest.php +++ b/tests/Unit/Renderer/HtmlEngineTest.php @@ -58,7 +58,10 @@ class HtmlEngineTest extends TestCase return $fileName; } - public function tearDown() + /** + * Remove files + */ + protected function tearDown(): void { foreach ($this->tmpFileNames as $fileName) { unlink($fileName); diff --git a/tests/Unit/Renderer/RendererServiceProviderTest.php b/tests/Unit/Renderer/RendererServiceProviderTest.php index 6cdf4363..36263b0c 100644 --- a/tests/Unit/Renderer/RendererServiceProviderTest.php +++ b/tests/Unit/Renderer/RendererServiceProviderTest.php @@ -7,7 +7,7 @@ use Engelsystem\Renderer\HtmlEngine; use Engelsystem\Renderer\Renderer; use Engelsystem\Renderer\RendererServiceProvider; use Engelsystem\Test\Unit\ServiceProviderTest; -use PHPUnit_Framework_MockObject_MockObject; +use PHPUnit\Framework\MockObject\MockObject; class RendererServiceProviderTest extends ServiceProviderTest { @@ -18,10 +18,10 @@ class RendererServiceProviderTest extends ServiceProviderTest */ public function testRegister() { - /** @var PHPUnit_Framework_MockObject_MockObject|Renderer $renderer */ + /** @var Renderer|MockObject $renderer */ $renderer = $this->getMockBuilder(Renderer::class) ->getMock(); - /** @var PHPUnit_Framework_MockObject_MockObject|HtmlEngine $htmlEngine */ + /** @var HtmlEngine|MockObject $htmlEngine */ $htmlEngine = $this->getMockBuilder(HtmlEngine::class) ->getMock(); @@ -57,12 +57,12 @@ class RendererServiceProviderTest extends ServiceProviderTest */ public function testBoot() { - /** @var PHPUnit_Framework_MockObject_MockObject|Renderer $renderer */ + /** @var Renderer|MockObject $renderer */ $renderer = $this->getMockBuilder(Renderer::class) ->getMock(); - /** @var PHPUnit_Framework_MockObject_MockObject|EngineInterface $engine1 */ + /** @var EngineInterface|MockObject $engine1 */ $engine1 = $this->getMockForAbstractClass(EngineInterface::class); - /** @var PHPUnit_Framework_MockObject_MockObject|EngineInterface $engine2 */ + /** @var EngineInterface|MockObject $engine2 */ $engine2 = $this->getMockForAbstractClass(EngineInterface::class); $app = $this->getApp(['get', 'tagged']); diff --git a/tests/Unit/Renderer/RendererTest.php b/tests/Unit/Renderer/RendererTest.php index 969ced7f..9304356a 100644 --- a/tests/Unit/Renderer/RendererTest.php +++ b/tests/Unit/Renderer/RendererTest.php @@ -4,8 +4,8 @@ namespace Engelsystem\Test\Unit\Renderer; use Engelsystem\Renderer\EngineInterface; use Engelsystem\Renderer\Renderer; +use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; -use PHPUnit_Framework_MockObject_MockObject as MockObject; use Psr\Log\LoggerInterface; class RendererTest extends TestCase @@ -14,7 +14,7 @@ class RendererTest extends TestCase { $renderer = new Renderer(); - /** @var MockObject|EngineInterface $nullRenderer */ + /** @var EngineInterface|MockObject $nullRenderer */ $nullRenderer = $this->getMockForAbstractClass(EngineInterface::class); $nullRenderer->expects($this->atLeastOnce()) @@ -22,7 +22,7 @@ class RendererTest extends TestCase ->willReturn(false); $renderer->addRenderer($nullRenderer); - /** @var MockObject|EngineInterface $mockRenderer */ + /** @var EngineInterface|MockObject $mockRenderer */ $mockRenderer = $this->getMockForAbstractClass(EngineInterface::class); $mockRenderer->expects($this->atLeastOnce()) @@ -45,7 +45,7 @@ class RendererTest extends TestCase { $renderer = new Renderer(); - /** @var MockObject|LoggerInterface $loggerMock */ + /** @var LoggerInterface|MockObject $loggerMock */ $loggerMock = $this->getMockForAbstractClass(LoggerInterface::class); $loggerMock ->expects($this->once()) diff --git a/tests/Unit/Renderer/Twig/Extensions/ExtensionTest.php b/tests/Unit/Renderer/Twig/Extensions/ExtensionTest.php index ef7dba7a..eb78e1ab 100644 --- a/tests/Unit/Renderer/Twig/Extensions/ExtensionTest.php +++ b/tests/Unit/Renderer/Twig/Extensions/ExtensionTest.php @@ -2,6 +2,7 @@ namespace Engelsystem\Test\Unit\Renderer\Twig\Extensions; +use DMS\PHPUnitExtensions\ArraySubset\ArraySubsetAsserts; use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; use Twig_Function as TwigFunction; @@ -9,6 +10,8 @@ use Twig_Node as TwigNode; abstract class ExtensionTest extends TestCase { + use ArraySubsetAsserts; + /** * Assert that a twig filter was registered * diff --git a/tests/Unit/ServiceProviderTest.php b/tests/Unit/ServiceProviderTest.php index ee5e3151..27929fc7 100644 --- a/tests/Unit/ServiceProviderTest.php +++ b/tests/Unit/ServiceProviderTest.php @@ -3,7 +3,7 @@ namespace Engelsystem\Test\Unit; use Engelsystem\Application; -use PHPUnit_Framework_MockObject_MockObject as MockObject; +use PHPUnit\Framework\MockObject\MockObject; abstract class ServiceProviderTest extends TestCase { @@ -13,7 +13,7 @@ abstract class ServiceProviderTest extends TestCase */ protected function getApp($methods = ['make', 'instance']) { - /** @var MockObject|Application $app */ + /** @var Application|MockObject $app */ return $this->getMockBuilder(Application::class) ->setMethods($methods) ->getMock(); diff --git a/tests/Unit/TestCase.php b/tests/Unit/TestCase.php index 117fba88..d09104d4 100644 --- a/tests/Unit/TestCase.php +++ b/tests/Unit/TestCase.php @@ -3,8 +3,8 @@ namespace Engelsystem\Test\Unit; use PHPUnit\Framework\MockObject\Matcher\InvokedRecorder; +use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase as PHPUnitTestCase; -use PHPUnit_Framework_MockObject_MockObject as MockObject; abstract class TestCase extends PHPUnitTestCase {