phpunit: Upgrade to version 8, fixed tests, formatting

Use `dms/phpunit-arraysubset-asserts` after `assertArraySubset` got deprecated
main
Igor Scheller 6 years ago committed by msquare
parent b74835a096
commit c74fa7955d

1
.gitignore vendored

@ -7,6 +7,7 @@
*.DS_Store *.DS_Store
.*.swp .*.swp
*.out *.out
*.cache
Thumbs.db Thumbs.db
.project .project
.buildpath .buildpath

@ -39,8 +39,9 @@
"twig/twig": "~2.6.0" "twig/twig": "~2.6.0"
}, },
"require-dev": { "require-dev": {
"dms/phpunit-arraysubset-asserts": "^0.1.0",
"filp/whoops": "^2.1", "filp/whoops": "^2.1",
"phpunit/phpunit": "^6.3", "phpunit/phpunit": "^8.1",
"symfony/var-dumper": "^3.3" "symfony/var-dumper": "^3.3"
}, },
"autoload": { "autoload": {

@ -9,6 +9,11 @@ abstract class Migration
/** @var SchemaBuilder */ /** @var SchemaBuilder */
protected $schema; protected $schema;
/**
* Migration constructor.
*
* @param SchemaBuilder $schemaBuilder
*/
public function __construct(SchemaBuilder $schemaBuilder) public function __construct(SchemaBuilder $schemaBuilder)
{ {
$this->schema = $schemaBuilder; $this->schema = $schemaBuilder;

@ -6,7 +6,7 @@ use PHPUnit\Framework\TestCase;
abstract class ApplicationFeatureTest extends TestCase abstract class ApplicationFeatureTest extends TestCase
{ {
public static function setUpBeforeClass() public static function setUpBeforeClass(): void
{ {
$_SERVER['HTTP_HOST'] = 'foo.bar'; $_SERVER['HTTP_HOST'] = 'foo.bar';
require_once __DIR__ . '/../../includes/engelsystem.php'; require_once __DIR__ . '/../../includes/engelsystem.php';

@ -5,7 +5,7 @@ namespace Engelsystem\Test\Feature\Database;
use Engelsystem\Application; use Engelsystem\Application;
use Engelsystem\Config\Config; use Engelsystem\Config\Config;
use Engelsystem\Database\DatabaseServiceProvider; use Engelsystem\Database\DatabaseServiceProvider;
use PHPUnit_Framework_MockObject_MockObject as MockObject; use PHPUnit\Framework\MockObject\MockObject;
class DatabaseServiceProviderTest extends DatabaseTest class DatabaseServiceProviderTest extends DatabaseTest
{ {
@ -14,11 +14,11 @@ class DatabaseServiceProviderTest extends DatabaseTest
*/ */
public function testRegister() public function testRegister()
{ {
/** @var MockObject|Config $config */ /** @var Config|MockObject $config */
$config = $this->getMockBuilder(Config::class) $config = $this->getMockBuilder(Config::class)
->getMock(); ->getMock();
/** @var MockObject|Application $app */ /** @var Application|MockObject $app */
$app = $this->getMockBuilder(Application::class) $app = $this->getMockBuilder(Application::class)
->setMethods(['get']) ->setMethods(['get'])
->getMock(); ->getMock();

@ -8,10 +8,12 @@ use Engelsystem\Test\Feature\ApplicationFeatureTest;
use Psr\Log\InvalidArgumentException; use Psr\Log\InvalidArgumentException;
use Psr\Log\LoggerInterface; use Psr\Log\LoggerInterface;
use Psr\Log\LogLevel; use Psr\Log\LogLevel;
use stdClass;
class EngelsystemLoggerTest extends ApplicationFeatureTest class EngelsystemLoggerTest extends ApplicationFeatureTest
{ {
/** /**
* @covers \Engelsystem\Logger\EngelsystemLogger::__construct
* @return LoggerInterface * @return LoggerInterface
*/ */
public function getLogger() public function getLogger()
@ -20,6 +22,9 @@ class EngelsystemLoggerTest extends ApplicationFeatureTest
return new EngelsystemLogger($logEntry); return new EngelsystemLogger($logEntry);
} }
/**
* @covers \Engelsystem\Logger\EngelsystemLogger::__construct
*/
public function testImplements() public function testImplements()
{ {
$this->assertInstanceOf(LoggerInterface::class, $this->getLogger()); $this->assertInstanceOf(LoggerInterface::class, $this->getLogger());
@ -43,6 +48,7 @@ class EngelsystemLoggerTest extends ApplicationFeatureTest
} }
/** /**
* @covers \Engelsystem\Models\LogEntry
* @dataProvider provideLogLevels * @dataProvider provideLogLevels
* @param string $level * @param string $level
*/ */
@ -58,6 +64,9 @@ class EngelsystemLoggerTest extends ApplicationFeatureTest
$this->assertCount(2, $entries); $this->assertCount(2, $entries);
} }
/**
* @covers \Engelsystem\Logger\EngelsystemLogger::log
*/
public function testContextReplacement() public function testContextReplacement()
{ {
LogEntry::query()->truncate(); LogEntry::query()->truncate();
@ -78,12 +87,13 @@ class EngelsystemLoggerTest extends ApplicationFeatureTest
return [ return [
['Data and {context}', [], 'Data and {context}'], ['Data and {context}', [], 'Data and {context}'],
['Data and {context}', ['context' => null], 'Data and '], ['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?'], ['Some user asked: {question}', ['question' => 'Foo?'], 'Some user asked: Foo?'],
]; ];
} }
/** /**
* @covers \Engelsystem\Logger\EngelsystemLogger::log
* @dataProvider provideContextReplaceValues * @dataProvider provideContextReplaceValues
* *
* @param string $message * @param string $message
@ -99,6 +109,9 @@ class EngelsystemLoggerTest extends ApplicationFeatureTest
$this->assertEquals($expected, $entry['message']); $this->assertEquals($expected, $entry['message']);
} }
/**
* @covers \Engelsystem\Logger\EngelsystemLogger::log
*/
public function testContextToString() public function testContextToString()
{ {
LogEntry::query()->truncate(); LogEntry::query()->truncate();
@ -119,19 +132,20 @@ class EngelsystemLoggerTest extends ApplicationFeatureTest
} }
/** /**
* @expectedException InvalidArgumentException * @covers \Engelsystem\Logger\EngelsystemLogger::log
*/ */
public function testThrowExceptionOnInvalidLevel() public function testThrowExceptionOnInvalidLevel()
{ {
$logger = $this->getLogger(); $logger = $this->getLogger();
$this->expectException(InvalidArgumentException::class);
$logger->log('This log level should never be defined', 'Some message'); $logger->log('This log level should never be defined', 'Some message');
} }
/** /**
* @return array * @return array
*/ */
public function getLastEntry() protected function getLastEntry()
{ {
$entries = LogEntry::all(); $entries = LogEntry::all();
$entry = $entries->last(); $entry = $entries->last();
@ -139,7 +153,10 @@ class EngelsystemLoggerTest extends ApplicationFeatureTest
return $entry; return $entry;
} }
public function tearDown() /**
* Cleanup
*/
protected function tearDown(): void
{ {
LogEntry::query()->truncate(); LogEntry::query()->truncate();
} }

@ -49,7 +49,7 @@ class LogEntryTest extends TestCase
/** /**
* This method is called before a test is executed. * This method is called before a test is executed.
*/ */
public function setUp() protected function setUp(): void
{ {
LogEntry::query()->truncate(); LogEntry::query()->truncate();
} }

@ -8,11 +8,17 @@ class RoomModelTest extends TestCase
{ {
private $room_id = null; private $room_id = null;
/**
* @covers \Room_create
*/
public function createRoom() public function createRoom()
{ {
$this->room_id = Room_create('test', false, null, null); $this->room_id = Room_create('test', false, null, null);
} }
/**
* @covers \Room
*/
public function testRoom() public function testRoom()
{ {
$this->createRoom(); $this->createRoom();
@ -26,7 +32,10 @@ class RoomModelTest extends TestCase
$this->assertEmpty(Room(-1)); $this->assertEmpty(Room(-1));
} }
public function tearDown() /**
* Cleanup
*/
protected function tearDown(): void
{ {
if ($this->room_id != null) { if ($this->room_id != null) {
Room_delete($this->room_id); Room_delete($this->room_id);

@ -6,8 +6,8 @@ use Engelsystem\Application;
use Engelsystem\Config\Config; use Engelsystem\Config\Config;
use Engelsystem\Container\Container; use Engelsystem\Container\Container;
use Engelsystem\Container\ServiceProvider; use Engelsystem\Container\ServiceProvider;
use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\TestCase; use PHPUnit\Framework\TestCase;
use PHPUnit_Framework_MockObject_MockObject;
use Psr\Container\ContainerInterface; use Psr\Container\ContainerInterface;
use Psr\Http\Server\MiddlewareInterface; use Psr\Http\Server\MiddlewareInterface;
use ReflectionClass; use ReflectionClass;
@ -130,7 +130,7 @@ class ApplicationTest extends TestCase
*/ */
public function testBootstrap() public function testBootstrap()
{ {
/** @var PHPUnit_Framework_MockObject_MockObject|Application $app */ /** @var Application|MockObject $app */
$app = $this->getMockBuilder(Application::class) $app = $this->getMockBuilder(Application::class)
->setMethods(['register']) ->setMethods(['register'])
->getMock(); ->getMock();
@ -143,6 +143,7 @@ class ApplicationTest extends TestCase
->method('register') ->method('register')
->with($serviceProvider); ->with($serviceProvider);
/** @var Config|MockObject $config */
$config = $this->getMockBuilder(Config::class) $config = $this->getMockBuilder(Config::class)
->getMock(); ->getMock();
@ -168,7 +169,7 @@ class ApplicationTest extends TestCase
/** /**
* @param Application $app * @param Application $app
* @param array $methods * @param array $methods
* @return PHPUnit_Framework_MockObject_MockObject|ServiceProvider * @return ServiceProvider|MockObject
*/ */
protected function mockServiceProvider(Application $app, $methods = []) protected function mockServiceProvider(Application $app, $methods = [])
{ {

@ -2,6 +2,7 @@
namespace Engelsystem\Test\Unit\Config; namespace Engelsystem\Test\Unit\Config;
use DMS\PHPUnitExtensions\ArraySubset\ArraySubsetAsserts;
use Engelsystem\Application; use Engelsystem\Application;
use Engelsystem\Config\Config; use Engelsystem\Config\Config;
use Engelsystem\Config\ConfigServiceProvider; use Engelsystem\Config\ConfigServiceProvider;
@ -14,13 +15,15 @@ use PHPUnit\Framework\MockObject\MockObject;
class ConfigServiceProviderTest extends ServiceProviderTest class ConfigServiceProviderTest extends ServiceProviderTest
{ {
use ArraySubsetAsserts;
/** /**
* @covers \Engelsystem\Config\ConfigServiceProvider::register * @covers \Engelsystem\Config\ConfigServiceProvider::register
* @covers \Engelsystem\Config\ConfigServiceProvider::getConfigPath * @covers \Engelsystem\Config\ConfigServiceProvider::getConfigPath
*/ */
public function testRegister() public function testRegister()
{ {
/** @var MockObject|Config $config */ /** @var Config|MockObject $config */
$config = $this->getMockBuilder(Config::class) $config = $this->getMockBuilder(Config::class)
->getMock(); ->getMock();
@ -61,7 +64,7 @@ class ConfigServiceProviderTest extends ServiceProviderTest
*/ */
public function testRegisterException() public function testRegisterException()
{ {
/** @var MockObject|Config $config */ /** @var Config|MockObject $config */
$config = $this->getMockBuilder(Config::class) $config = $this->getMockBuilder(Config::class)
->getMock(); ->getMock();

@ -13,7 +13,7 @@ use Illuminate\Database\Capsule\Manager as CapsuleManager;
use Illuminate\Database\Connection; use Illuminate\Database\Connection;
use PDO; use PDO;
use PDOException; use PDOException;
use PHPUnit_Framework_MockObject_MockObject as MockObject; use PHPUnit\Framework\MockObject\MockObject;
class DatabaseServiceProviderTest extends ServiceProviderTest class DatabaseServiceProviderTest extends ServiceProviderTest
{ {
@ -78,13 +78,13 @@ class DatabaseServiceProviderTest extends ServiceProviderTest
*/ */
protected function prepare($dbConfigData, $getPdoThrowException = false) protected function prepare($dbConfigData, $getPdoThrowException = false)
{ {
/** @var MockObject|Config $config */ /** @var Config|MockObject $config */
$config = $this->getMockBuilder(Config::class) $config = $this->getMockBuilder(Config::class)
->getMock(); ->getMock();
/** @var MockObject|CapsuleManager $config */ /** @var CapsuleManager|MockObject $config */
$dbManager = $this->getMockBuilder(CapsuleManager::class) $dbManager = $this->getMockBuilder(CapsuleManager::class)
->getMock(); ->getMock();
/** @var MockObject|Connection $connection */ /** @var Connection|MockObject $connection */
$connection = $this->getMockBuilder(Connection::class) $connection = $this->getMockBuilder(Connection::class)
->disableOriginalConstructor() ->disableOriginalConstructor()
->getMock(); ->getMock();

@ -6,8 +6,8 @@ use Engelsystem\Database\Database;
use Illuminate\Database\Capsule\Manager as CapsuleManager; use Illuminate\Database\Capsule\Manager as CapsuleManager;
use Illuminate\Database\Connection as DatabaseConnection; use Illuminate\Database\Connection as DatabaseConnection;
use PDO; use PDO;
use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\TestCase; use PHPUnit\Framework\TestCase;
use PHPUnit_Framework_MockObject_MockObject as MockObject;
class DatabaseTest extends TestCase class DatabaseTest extends TestCase
{ {
@ -69,7 +69,7 @@ class DatabaseTest extends TestCase
$this->assertEmpty($return); $this->assertEmpty($return);
$return = $db->selectOne('SELECT * FROM test_data WHERE id = ?', [3]); $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 * Setup in memory database
*/ */
protected function setUp() protected function setUp(): void
{ {
$dbManager = new CapsuleManager(); $dbManager = new CapsuleManager();
$dbManager->addConnection(['driver' => 'sqlite', 'database' => ':memory:']); $dbManager->addConnection(['driver' => 'sqlite', 'database' => ':memory:']);

@ -6,8 +6,8 @@ use Engelsystem\Database\Db;
use Illuminate\Database\Capsule\Manager as CapsuleManager; use Illuminate\Database\Capsule\Manager as CapsuleManager;
use Illuminate\Database\Connection as DatabaseConnection; use Illuminate\Database\Connection as DatabaseConnection;
use PDO; use PDO;
use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\TestCase; use PHPUnit\Framework\TestCase;
use PHPUnit_Framework_MockObject_MockObject as MockObject;
class DbTest extends TestCase class DbTest extends TestCase
{ {
@ -17,15 +17,15 @@ class DbTest extends TestCase
*/ */
public function testSetDbManager() public function testSetDbManager()
{ {
/** @var MockObject|Pdo $pdo */ /** @var Pdo|MockObject $pdo */
$pdo = $this->getMockBuilder(Pdo::class) $pdo = $this->getMockBuilder(Pdo::class)
->disableOriginalConstructor() ->disableOriginalConstructor()
->getMock(); ->getMock();
/** @var MockObject|CapsuleManager $dbManager */ /** @var CapsuleManager|MockObject $dbManager */
$dbManager = $this->getMockBuilder(CapsuleManager::class) $dbManager = $this->getMockBuilder(CapsuleManager::class)
->disableOriginalConstructor() ->disableOriginalConstructor()
->getMock(); ->getMock();
/** @var MockObject|DatabaseConnection $dbManager */ /** @var DatabaseConnection|MockObject $dbManager */
$databaseConnection = $this->getMockBuilder(DatabaseConnection::class) $databaseConnection = $this->getMockBuilder(DatabaseConnection::class)
->disableOriginalConstructor() ->disableOriginalConstructor()
->getMock(); ->getMock();
@ -69,7 +69,7 @@ class DbTest extends TestCase
$return = Db::selectOne('SELECT * FROM test_data WHERE id = ?', [3]); $return = Db::selectOne('SELECT * FROM test_data WHERE id = ?', [3]);
$return = array_pop($return); $return = array_pop($return);
$this->assertTrue(!is_array($return)); $this->assertIsNotArray($return);
} }
/** /**
@ -117,7 +117,7 @@ class DbTest extends TestCase
/** /**
* Setup in memory database * Setup in memory database
*/ */
protected function setUp() protected function setUp(): void
{ {
$dbManager = new CapsuleManager(); $dbManager = new CapsuleManager();
$dbManager->addConnection(['driver' => 'sqlite', 'database' => ':memory:']); $dbManager->addConnection(['driver' => 'sqlite', 'database' => ':memory:']);

@ -21,15 +21,15 @@ class MigrateTest extends TestCase
*/ */
public function testRun() public function testRun()
{ {
/** @var MockObject|Application $app */ /** @var Application|MockObject $app */
$app = $this->getMockBuilder(Application::class) $app = $this->getMockBuilder(Application::class)
->setMethods(['instance']) ->setMethods(['instance'])
->getMock(); ->getMock();
/** @var MockObject|SchemaBuilder $builder */ /** @var SchemaBuilder|MockObject $builder */
$builder = $this->getMockBuilder(SchemaBuilder::class) $builder = $this->getMockBuilder(SchemaBuilder::class)
->disableOriginalConstructor() ->disableOriginalConstructor()
->getMock(); ->getMock();
/** @var MockObject|Migrate $migration */ /** @var Migrate|MockObject $migration */
$migration = $this->getMockBuilder(Migrate::class) $migration = $this->getMockBuilder(Migrate::class)
->setConstructorArgs([$builder, $app]) ->setConstructorArgs([$builder, $app])
->setMethods(['initMigration', 'getMigrationFiles', 'getMigrated', 'migrate', 'setMigrated']) ->setMethods(['initMigration', 'getMigrationFiles', 'getMigrated', 'migrate', 'setMigrated'])

@ -8,7 +8,7 @@ use Engelsystem\Database\Migration\MigrationServiceProvider;
use Engelsystem\Test\Unit\ServiceProviderTest; use Engelsystem\Test\Unit\ServiceProviderTest;
use Illuminate\Database\Connection; use Illuminate\Database\Connection;
use Illuminate\Database\Schema\Builder as SchemaBuilder; use Illuminate\Database\Schema\Builder as SchemaBuilder;
use PHPUnit_Framework_MockObject_MockObject as MockObject; use PHPUnit\Framework\MockObject\MockObject;
class MigrationServiceProviderTest extends ServiceProviderTest class MigrationServiceProviderTest extends ServiceProviderTest
{ {
@ -17,7 +17,7 @@ class MigrationServiceProviderTest extends ServiceProviderTest
*/ */
public function testRegister() public function testRegister()
{ {
/** @var MockObject|Migrate $migration */ /** @var Migrate|MockObject $migration */
$migration = $this->getMockBuilder(Migrate::class) $migration = $this->getMockBuilder(Migrate::class)
->disableOriginalConstructor() ->disableOriginalConstructor()
->getMock(); ->getMock();
@ -25,11 +25,11 @@ class MigrationServiceProviderTest extends ServiceProviderTest
$database = $this->getMockBuilder(Database::class) $database = $this->getMockBuilder(Database::class)
->disableOriginalConstructor() ->disableOriginalConstructor()
->getMock(); ->getMock();
/** @var MockObject|Connection $dbConnection */ /** @var Connection|MockObject $dbConnection */
$dbConnection = $this->getMockBuilder(Connection::class) $dbConnection = $this->getMockBuilder(Connection::class)
->disableOriginalConstructor() ->disableOriginalConstructor()
->getMock(); ->getMock();
/** @var MockObject|SchemaBuilder $schemaBuilder */ /** @var SchemaBuilder|MockObject $schemaBuilder */
$schemaBuilder = $this->getMockBuilder(SchemaBuilder::class) $schemaBuilder = $this->getMockBuilder(SchemaBuilder::class)
->disableOriginalConstructor() ->disableOriginalConstructor()
->getMock(); ->getMock();

@ -19,6 +19,6 @@ class MigrationTest extends TestCase
->getMock(); ->getMock();
$instance = new AnotherStuff($schemaBuilder); $instance = new AnotherStuff($schemaBuilder);
$this->assertAttributeEquals($schemaBuilder, 'schema', $instance); $this->assertEquals($schemaBuilder, $instance->getSchema());
} }
} }

@ -3,6 +3,7 @@
namespace Engelsystem\Migrations; namespace Engelsystem\Migrations;
use Engelsystem\Database\Migration\Migration; use Engelsystem\Database\Migration\Migration;
use Illuminate\Database\Schema\Builder as SchemaBuilder;
class AnotherStuff extends Migration class AnotherStuff extends Migration
{ {
@ -21,4 +22,12 @@ class AnotherStuff extends Migration
{ {
// nope // nope
} }
/**
* @return SchemaBuilder
*/
public function getSchema()
{
return $this->schema;
}
} }

@ -10,7 +10,7 @@ use Engelsystem\Exceptions\Handlers\LegacyDevelopment;
use Engelsystem\Exceptions\Handlers\Whoops; use Engelsystem\Exceptions\Handlers\Whoops;
use Engelsystem\Http\Request; use Engelsystem\Http\Request;
use Engelsystem\Test\Unit\ServiceProviderTest; use Engelsystem\Test\Unit\ServiceProviderTest;
use PHPUnit_Framework_MockObject_MockObject as MockObject; use PHPUnit\Framework\MockObject\MockObject;
class ExceptionsServiceProviderTest extends ServiceProviderTest class ExceptionsServiceProviderTest extends ServiceProviderTest
{ {
@ -23,7 +23,7 @@ class ExceptionsServiceProviderTest extends ServiceProviderTest
{ {
$app = $this->getApp(['make', 'instance', 'bind']); $app = $this->getApp(['make', 'instance', 'bind']);
/** @var MockObject|Handler $handler */ /** @var Handler|MockObject $handler */
$handler = $this->createMock(Handler::class); $handler = $this->createMock(Handler::class);
$this->setExpects($handler, 'register'); $this->setExpects($handler, 'register');
/** @var Legacy|MockObject $legacyHandler */ /** @var Legacy|MockObject $legacyHandler */
@ -81,10 +81,10 @@ class ExceptionsServiceProviderTest extends ServiceProviderTest
*/ */
public function testBoot() public function testBoot()
{ {
/** @var MockObject|Handler $handler */ /** @var Handler|MockObject $handler */
$handler = $this->createMock(Handler::class); $handler = $this->createMock(Handler::class);
/** @var MockObject|Request $request */ /** @var Request|MockObject $request */
$request = $this->createMock(Request::class); $request = $this->createMock(Request::class);
$handler->expects($this->once()) $handler->expects($this->once())

@ -7,8 +7,8 @@ use Engelsystem\Exceptions\Handlers\HandlerInterface;
use Engelsystem\Http\Request; use Engelsystem\Http\Request;
use ErrorException; use ErrorException;
use Exception; use Exception;
use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\TestCase; use PHPUnit\Framework\TestCase;
use PHPUnit_Framework_MockObject_MockObject as Mock;
class HandlerTest extends TestCase class HandlerTest extends TestCase
{ {
@ -17,7 +17,7 @@ class HandlerTest extends TestCase
*/ */
public function testCreate() public function testCreate()
{ {
/** @var Handler|Mock $handler */ /** @var Handler|MockObject $handler */
$handler = new Handler(); $handler = new Handler();
$this->assertInstanceOf(Handler::class, $handler); $this->assertInstanceOf(Handler::class, $handler);
$this->assertEquals(Handler::ENV_PRODUCTION, $handler->getEnvironment()); $this->assertEquals(Handler::ENV_PRODUCTION, $handler->getEnvironment());
@ -31,7 +31,7 @@ class HandlerTest extends TestCase
*/ */
public function testErrorHandler() public function testErrorHandler()
{ {
/** @var Handler|Mock $handler */ /** @var Handler|MockObject $handler */
$handler = $this->getMockBuilder(Handler::class) $handler = $this->getMockBuilder(Handler::class)
->setMethods(['exceptionHandler']) ->setMethods(['exceptionHandler'])
->getMock(); ->getMock();
@ -51,7 +51,7 @@ class HandlerTest extends TestCase
$exception = new Exception(); $exception = new Exception();
$errorMessage = 'Oh noes, an error!'; $errorMessage = 'Oh noes, an error!';
/** @var HandlerInterface|Mock $handlerMock */ /** @var HandlerInterface|MockObject $handlerMock */
$handlerMock = $this->getMockForAbstractClass(HandlerInterface::class); $handlerMock = $this->getMockForAbstractClass(HandlerInterface::class);
$handlerMock->expects($this->atLeastOnce()) $handlerMock->expects($this->atLeastOnce())
->method('report') ->method('report')
@ -63,7 +63,7 @@ class HandlerTest extends TestCase
echo $errorMessage; echo $errorMessage;
}); });
/** @var Handler|Mock $handler */ /** @var Handler|MockObject $handler */
$handler = $this->getMockBuilder(Handler::class) $handler = $this->getMockBuilder(Handler::class)
->setMethods(['terminateApplicationImmediately']) ->setMethods(['terminateApplicationImmediately'])
->getMock(); ->getMock();
@ -84,7 +84,7 @@ class HandlerTest extends TestCase
*/ */
public function testRegister() public function testRegister()
{ {
/** @var Handler|Mock $handler */ /** @var Handler|MockObject $handler */
$handler = $this->getMockForAbstractClass(Handler::class); $handler = $this->getMockForAbstractClass(Handler::class);
$handler->register(); $handler->register();
@ -120,9 +120,9 @@ class HandlerTest extends TestCase
public function testHandler() public function testHandler()
{ {
$handler = new Handler(); $handler = new Handler();
/** @var HandlerInterface|Mock $devHandler */ /** @var HandlerInterface|MockObject $devHandler */
$devHandler = $this->getMockForAbstractClass(HandlerInterface::class); $devHandler = $this->getMockForAbstractClass(HandlerInterface::class);
/** @var HandlerInterface|Mock $prodHandler */ /** @var HandlerInterface|MockObject $prodHandler */
$prodHandler = $this->getMockForAbstractClass(HandlerInterface::class); $prodHandler = $this->getMockForAbstractClass(HandlerInterface::class);
$handler->setHandler(Handler::ENV_DEVELOPMENT, $devHandler); $handler->setHandler(Handler::ENV_DEVELOPMENT, $devHandler);
@ -139,7 +139,7 @@ class HandlerTest extends TestCase
public function testRequest() public function testRequest()
{ {
$handler = new Handler(); $handler = new Handler();
/** @var Request|Mock $request */ /** @var Request|MockObject $request */
$request = $this->createMock(Request::class); $request = $this->createMock(Request::class);
$handler->setRequest($request); $handler->setRequest($request);

@ -6,8 +6,8 @@ namespace Engelsystem\Test\Unit\Exceptions\handlers;
use Engelsystem\Exceptions\Handlers\LegacyDevelopment; use Engelsystem\Exceptions\Handlers\LegacyDevelopment;
use Engelsystem\Http\Request; use Engelsystem\Http\Request;
use ErrorException; use ErrorException;
use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\TestCase; use PHPUnit\Framework\TestCase;
use PHPUnit_Framework_MockObject_MockObject as Mock;
class LegacyDevelopmentTest extends TestCase class LegacyDevelopmentTest extends TestCase
{ {
@ -18,7 +18,7 @@ class LegacyDevelopmentTest extends TestCase
public function testRender() public function testRender()
{ {
$handler = new LegacyDevelopment(); $handler = new LegacyDevelopment();
/** @var Request|Mock $request */ /** @var Request|MockObject $request */
$request = $this->createMock(Request::class); $request = $this->createMock(Request::class);
$exception = new ErrorException('Lorem Ipsum', 4242, 1, 'foo.php', 9999); $exception = new ErrorException('Lorem Ipsum', 4242, 1, 'foo.php', 9999);

@ -6,8 +6,8 @@ namespace Engelsystem\Test\Unit\Exceptions\handlers;
use Engelsystem\Exceptions\Handlers\Legacy; use Engelsystem\Exceptions\Handlers\Legacy;
use Engelsystem\Http\Request; use Engelsystem\Http\Request;
use Exception; use Exception;
use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\TestCase; use PHPUnit\Framework\TestCase;
use PHPUnit_Framework_MockObject_MockObject as Mock;
class LegacyTest extends TestCase class LegacyTest extends TestCase
{ {
@ -17,9 +17,9 @@ class LegacyTest extends TestCase
public function testRender() public function testRender()
{ {
$handler = new Legacy(); $handler = new Legacy();
/** @var Request|Mock $request */ /** @var Request|MockObject $request */
$request = $this->createMock(Request::class); $request = $this->createMock(Request::class);
/** @var Exception|Mock $exception */ /** @var Exception|MockObject $exception */
$exception = $this->createMock(Exception::class); $exception = $this->createMock(Exception::class);
$this->expectOutputRegex('/.*error occurred.*/i'); $this->expectOutputRegex('/.*error occurred.*/i');
@ -45,11 +45,11 @@ class LegacyTest extends TestCase
$logContent = file_get_contents($log); $logContent = file_get_contents($log);
unset($log); unset($log);
$this->assertContains('4242', $logContent); $this->assertStringContainsString('4242', $logContent);
$this->assertContains('Lorem Ipsum', $logContent); $this->assertStringContainsString('Lorem Ipsum', $logContent);
$this->assertContains(basename(__FILE__), $logContent); $this->assertStringContainsString(basename(__FILE__), $logContent);
$this->assertContains((string)$line, $logContent); $this->assertStringContainsString((string)$line, $logContent);
$this->assertContains(__FUNCTION__, $logContent); $this->assertStringContainsString(__FUNCTION__, $logContent);
$this->assertContains(json_encode(__CLASS__), $logContent); $this->assertStringContainsString(json_encode(__CLASS__), $logContent);
} }
} }

@ -8,8 +8,8 @@ use Engelsystem\Exceptions\Handlers\Whoops;
use Engelsystem\Helpers\Authenticator; use Engelsystem\Helpers\Authenticator;
use Engelsystem\Http\Request; use Engelsystem\Http\Request;
use Exception; use Exception;
use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\TestCase; use PHPUnit\Framework\TestCase;
use PHPUnit_Framework_MockObject_MockObject as Mock;
use Whoops\Handler\JsonResponseHandler; use Whoops\Handler\JsonResponseHandler;
use Whoops\Handler\PrettyPageHandler; use Whoops\Handler\PrettyPageHandler;
use Whoops\Run as WhoopsRunner; use Whoops\Run as WhoopsRunner;
@ -22,19 +22,19 @@ class WhoopsTest extends TestCase
*/ */
public function testRender() public function testRender()
{ {
/** @var Application|Mock $app */ /** @var Application|MockObject $app */
$app = $this->createMock(Application::class); $app = $this->createMock(Application::class);
/** @var Authenticator|Mock $auth */ /** @var Authenticator|MockObject $auth */
$auth = $this->createMock(Authenticator::class); $auth = $this->createMock(Authenticator::class);
/** @var Request|Mock $request */ /** @var Request|MockObject $request */
$request = $this->createMock(Request::class); $request = $this->createMock(Request::class);
/** @var WhoopsRunnerInterface|Mock $whoopsRunner */ /** @var WhoopsRunnerInterface|MockObject $whoopsRunner */
$whoopsRunner = $this->getMockForAbstractClass(WhoopsRunnerInterface::class); $whoopsRunner = $this->getMockForAbstractClass(WhoopsRunnerInterface::class);
/** @var PrettyPageHandler|Mock $prettyPageHandler */ /** @var PrettyPageHandler|MockObject $prettyPageHandler */
$prettyPageHandler = $this->createMock(PrettyPageHandler::class); $prettyPageHandler = $this->createMock(PrettyPageHandler::class);
/** @var JsonResponseHandler|Mock $jsonResponseHandler */ /** @var JsonResponseHandler|MockObject $jsonResponseHandler */
$jsonResponseHandler = $this->createMock(JsonResponseHandler::class); $jsonResponseHandler = $this->createMock(JsonResponseHandler::class);
/** @var Exception|Mock $exception */ /** @var Exception|MockObject $exception */
$exception = $this->createMock(Exception::class); $exception = $this->createMock(Exception::class);
$request->expects($this->once()) $request->expects($this->once())

@ -39,11 +39,11 @@ class AuthenticatorTest extends ServiceProviderTest
$auth = new Authenticator($request, $session, $userRepository); $auth = new Authenticator($request, $session, $userRepository);
// Not in session // Not in session
$this->assertEquals(null, $auth->user()); $this->assertNull($auth->user());
// Unknown user // Unknown user
UserModelImplementation::$id = 42; UserModelImplementation::$id = 42;
$this->assertEquals(null, $auth->user()); $this->assertNull($auth->user());
// User found // User found
UserModelImplementation::$id = 1337; UserModelImplementation::$id = 1337;
@ -83,11 +83,11 @@ class AuthenticatorTest extends ServiceProviderTest
$auth = new Authenticator($request, $session, $userRepository); $auth = new Authenticator($request, $session, $userRepository);
// No key // No key
$this->assertEquals(null, $auth->apiUser()); $this->assertNull($auth->apiUser());
// Unknown user // Unknown user
UserModelImplementation::$apiKey = 'iMaNot3xiSt1nGAp1Key!'; UserModelImplementation::$apiKey = 'iMaNot3xiSt1nGAp1Key!';
$this->assertEquals(null, $auth->apiUser()); $this->assertNull($auth->apiUser());
// User found // User found
UserModelImplementation::$apiKey = 'SomeSecretApiKey'; UserModelImplementation::$apiKey = 'SomeSecretApiKey';

@ -11,8 +11,8 @@ use Engelsystem\Http\Request;
use Engelsystem\Http\Response; use Engelsystem\Http\Response;
use Engelsystem\Http\UrlGeneratorInterface; use Engelsystem\Http\UrlGeneratorInterface;
use Engelsystem\Renderer\Renderer; use Engelsystem\Renderer\Renderer;
use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\TestCase; use PHPUnit\Framework\TestCase;
use PHPUnit_Framework_MockObject_MockObject as MockObject;
use Symfony\Component\HttpFoundation\Session\Session; use Symfony\Component\HttpFoundation\Session\Session;
use Symfony\Component\HttpFoundation\Session\Storage\SessionStorageInterface as StorageInterface; use Symfony\Component\HttpFoundation\Session\Storage\SessionStorageInterface as StorageInterface;
@ -59,7 +59,7 @@ class HelpersTest extends TestCase
*/ */
public function testBasePath() public function testBasePath()
{ {
/** @var MockObject|Application $app */ /** @var Application|MockObject $app */
$app = $this->getMockBuilder(Container::class) $app = $this->getMockBuilder(Container::class)
->getMock(); ->getMock();
Application::setInstance($app); Application::setInstance($app);
@ -103,7 +103,7 @@ class HelpersTest extends TestCase
*/ */
public function testConfigPath() public function testConfigPath()
{ {
/** @var MockObject|Application $app */ /** @var Application|MockObject $app */
$app = $this->getMockBuilder(Container::class) $app = $this->getMockBuilder(Container::class)
->getMock(); ->getMock();
Application::setInstance($app); Application::setInstance($app);
@ -155,7 +155,7 @@ class HelpersTest extends TestCase
*/ */
public function testResponse() public function testResponse()
{ {
/** @var MockObject|Response $response */ /** @var Response|MockObject $response */
$response = $this->getMockBuilder(Response::class)->getMock(); $response = $this->getMockBuilder(Response::class)->getMock();
$this->getAppMock('psr7.response', $response); $this->getAppMock('psr7.response', $response);

@ -2,12 +2,15 @@
namespace Engelsystem\Test\Unit\Http; namespace Engelsystem\Test\Unit\Http;
use DMS\PHPUnitExtensions\ArraySubset\ArraySubsetAsserts;
use Engelsystem\Test\Unit\Http\Stub\MessageTraitRequestImplementation; use Engelsystem\Test\Unit\Http\Stub\MessageTraitRequestImplementation;
use Nyholm\Psr7\Stream; use Nyholm\Psr7\Stream;
use PHPUnit\Framework\TestCase; use PHPUnit\Framework\TestCase;
class MessageTraitRequestTest extends TestCase class MessageTraitRequestTest extends TestCase
{ {
use ArraySubsetAsserts;
/** /**
* @covers \Engelsystem\Http\MessageTrait::withProtocolVersion * @covers \Engelsystem\Http\MessageTrait::withProtocolVersion
*/ */

@ -2,6 +2,7 @@
namespace Engelsystem\Test\Unit\Http; namespace Engelsystem\Test\Unit\Http;
use DMS\PHPUnitExtensions\ArraySubset\ArraySubsetAsserts;
use Engelsystem\Test\Unit\Http\Stub\MessageTraitResponseImplementation; use Engelsystem\Test\Unit\Http\Stub\MessageTraitResponseImplementation;
use Nyholm\Psr7\Stream; use Nyholm\Psr7\Stream;
use PHPUnit\Framework\TestCase; use PHPUnit\Framework\TestCase;
@ -11,6 +12,8 @@ use Symfony\Component\HttpFoundation\Response as SymfonyResponse;
class MessageTraitResponseTest extends TestCase class MessageTraitResponseTest extends TestCase
{ {
use ArraySubsetAsserts;
/** /**
* @covers \Engelsystem\Http\MessageTrait * @covers \Engelsystem\Http\MessageTrait
*/ */

@ -7,7 +7,7 @@ use Engelsystem\Container\ServiceProvider;
use Engelsystem\Http\Request; use Engelsystem\Http\Request;
use Engelsystem\Http\RequestServiceProvider; use Engelsystem\Http\RequestServiceProvider;
use Engelsystem\Test\Unit\ServiceProviderTest; use Engelsystem\Test\Unit\ServiceProviderTest;
use PHPUnit_Framework_MockObject_MockObject as MockObject; use PHPUnit\Framework\MockObject\MockObject;
use Symfony\Component\HttpFoundation\Request as SymfonyRequest; use Symfony\Component\HttpFoundation\Request as SymfonyRequest;
class RequestServiceProviderTest extends ServiceProviderTest class RequestServiceProviderTest extends ServiceProviderTest

@ -4,8 +4,8 @@ namespace Engelsystem\Test\Unit\Http;
use Engelsystem\Http\Request; use Engelsystem\Http\Request;
use Nyholm\Psr7\UploadedFile; use Nyholm\Psr7\UploadedFile;
use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\TestCase; use PHPUnit\Framework\TestCase;
use PHPUnit_Framework_MockObject_MockObject as MockObject;
use Psr\Http\Message\RequestInterface; use Psr\Http\Message\RequestInterface;
use Psr\Http\Message\UploadedFileInterface; use Psr\Http\Message\UploadedFileInterface;
use Psr\Http\Message\UriInterface; use Psr\Http\Message\UriInterface;
@ -90,7 +90,7 @@ class RequestTest extends TestCase
*/ */
public function testPath() public function testPath()
{ {
/** @var MockObject|Request $request */ /** @var Request|MockObject $request */
$request = $this $request = $this
->getMockBuilder(Request::class) ->getMockBuilder(Request::class)
->setMethods(['getPathInfo']) ->setMethods(['getPathInfo'])
@ -113,7 +113,7 @@ class RequestTest extends TestCase
*/ */
public function testUrl() public function testUrl()
{ {
/** @var MockObject|Request $request */ /** @var Request|MockObject $request */
$request = $this $request = $this
->getMockBuilder(Request::class) ->getMockBuilder(Request::class)
->setMethods(['getUri']) ->setMethods(['getUri'])
@ -368,7 +368,7 @@ class RequestTest extends TestCase
$request = new Request([], [], $attributes); $request = new Request([], [], $attributes);
$this->assertEquals($attributes['ipsum'], $request->getAttribute('ipsum')); $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)); $this->assertEquals(1234, $request->getAttribute('test', 1234));
} }

@ -5,7 +5,7 @@ namespace Engelsystem\Test\Unit\Http;
use Engelsystem\Http\Response; use Engelsystem\Http\Response;
use Engelsystem\Http\ResponseServiceProvider; use Engelsystem\Http\ResponseServiceProvider;
use Engelsystem\Test\Unit\ServiceProviderTest; use Engelsystem\Test\Unit\ServiceProviderTest;
use PHPUnit_Framework_MockObject_MockObject as MockObject; use PHPUnit\Framework\MockObject\MockObject;
use Symfony\Component\HttpFoundation\Response as SymfonyResponse; use Symfony\Component\HttpFoundation\Response as SymfonyResponse;
class ResponseServiceProviderTest extends ServiceProviderTest class ResponseServiceProviderTest extends ServiceProviderTest
@ -15,7 +15,7 @@ class ResponseServiceProviderTest extends ServiceProviderTest
*/ */
public function testRegister() public function testRegister()
{ {
/** @var MockObject|Response $response */ /** @var Response|MockObject $response */
$response = $this->getMockBuilder(Response::class) $response = $this->getMockBuilder(Response::class)
->getMock(); ->getMock();

@ -2,8 +2,10 @@
namespace Engelsystem\Test\Unit\Http; namespace Engelsystem\Test\Unit\Http;
use DMS\PHPUnitExtensions\ArraySubset\ArraySubsetAsserts;
use Engelsystem\Http\Response; use Engelsystem\Http\Response;
use Engelsystem\Renderer\Renderer; use Engelsystem\Renderer\Renderer;
use InvalidArgumentException;
use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\TestCase; use PHPUnit\Framework\TestCase;
use Psr\Http\Message\ResponseInterface; use Psr\Http\Message\ResponseInterface;
@ -11,6 +13,8 @@ use Symfony\Component\HttpFoundation\Response as SymfonyResponse;
class ResponseTest extends TestCase class ResponseTest extends TestCase
{ {
use ArraySubsetAsserts;
/** /**
* @covers \Engelsystem\Http\Response * @covers \Engelsystem\Http\Response
*/ */
@ -76,7 +80,7 @@ class ResponseTest extends TestCase
*/ */
public function testWithViewNoRenderer() public function testWithViewNoRenderer()
{ {
$this->expectException(\InvalidArgumentException::class); $this->expectException(InvalidArgumentException::class);
$response = new Response(); $response = new Response();
$response->withView('foo'); $response->withView('foo');

@ -88,7 +88,7 @@ class DatabaseHandlerTest extends TestCase
/** /**
* Prepare tests * Prepare tests
*/ */
protected function setUp() protected function setUp(): void
{ {
$this->initDatabase(); $this->initDatabase();
} }

@ -7,7 +7,7 @@ use Engelsystem\Http\Request;
use Engelsystem\Http\SessionHandlers\DatabaseHandler; use Engelsystem\Http\SessionHandlers\DatabaseHandler;
use Engelsystem\Http\SessionServiceProvider; use Engelsystem\Http\SessionServiceProvider;
use Engelsystem\Test\Unit\ServiceProviderTest; 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\Session;
use Symfony\Component\HttpFoundation\Session\SessionInterface; use Symfony\Component\HttpFoundation\Session\SessionInterface;
use Symfony\Component\HttpFoundation\Session\Storage\MockArraySessionStorage; use Symfony\Component\HttpFoundation\Session\Storage\MockArraySessionStorage;
@ -33,7 +33,7 @@ class SessionServiceProviderTest extends ServiceProviderTest
$session = $this->getSessionMock(); $session = $this->getSessionMock();
$request = $this->getRequestMock(); $request = $this->getRequestMock();
/** @var MockObject|SessionServiceProvider $serviceProvider */ /** @var SessionServiceProvider|MockObject $serviceProvider */
$serviceProvider = $this->getMockBuilder(SessionServiceProvider::class) $serviceProvider = $this->getMockBuilder(SessionServiceProvider::class)
->setConstructorArgs([$app]) ->setConstructorArgs([$app])
->setMethods(['isCli']) ->setMethods(['isCli'])

@ -5,7 +5,7 @@ namespace Engelsystem\Test\Unit\Http;
use Engelsystem\Http\UrlGenerator; use Engelsystem\Http\UrlGenerator;
use Engelsystem\Http\UrlGeneratorServiceProvider; use Engelsystem\Http\UrlGeneratorServiceProvider;
use Engelsystem\Test\Unit\ServiceProviderTest; use Engelsystem\Test\Unit\ServiceProviderTest;
use PHPUnit_Framework_MockObject_MockObject; use PHPUnit\Framework\MockObject\MockObject;
class UrlGeneratorServiceProviderTest extends ServiceProviderTest class UrlGeneratorServiceProviderTest extends ServiceProviderTest
{ {
@ -14,7 +14,7 @@ class UrlGeneratorServiceProviderTest extends ServiceProviderTest
*/ */
public function testRegister() public function testRegister()
{ {
/** @var PHPUnit_Framework_MockObject_MockObject|UrlGenerator $urlGenerator */ /** @var UrlGenerator|MockObject $urlGenerator */
$urlGenerator = $this->getMockBuilder(UrlGenerator::class) $urlGenerator = $this->getMockBuilder(UrlGenerator::class)
->getMock(); ->getMock();

@ -5,7 +5,7 @@ namespace Engelsystem\Test\Unit\Logger;
use Engelsystem\Logger\EngelsystemLogger; use Engelsystem\Logger\EngelsystemLogger;
use Engelsystem\Logger\LoggerServiceProvider; use Engelsystem\Logger\LoggerServiceProvider;
use Engelsystem\Test\Unit\ServiceProviderTest; use Engelsystem\Test\Unit\ServiceProviderTest;
use PHPUnit_Framework_MockObject_MockObject; use PHPUnit\Framework\MockObject\MockObject;
use Psr\Log\LoggerInterface; use Psr\Log\LoggerInterface;
class LoggerServiceProviderTest extends ServiceProviderTest class LoggerServiceProviderTest extends ServiceProviderTest
@ -15,7 +15,7 @@ class LoggerServiceProviderTest extends ServiceProviderTest
*/ */
public function testRegister() public function testRegister()
{ {
/** @var PHPUnit_Framework_MockObject_MockObject|EngelsystemLogger $logger */ /** @var EngelsystemLogger|MockObject $logger */
$logger = $this->getMockBuilder(EngelsystemLogger::class) $logger = $this->getMockBuilder(EngelsystemLogger::class)
->disableOriginalConstructor() ->disableOriginalConstructor()
->getMock(); ->getMock();

@ -35,13 +35,13 @@ class LogTransportTest extends TestCase
->method('debug') ->method('debug')
->willReturnCallback(function ($message, $context = []) { ->willReturnCallback(function ($message, $context = []) {
foreach (array_keys($context) as $key) { 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('Some subject', $context['title']);
$this->assertEquals('foo@bar.batz,Lorem Ipsum <lor@em.ips>', $context['recipients']); $this->assertEquals('foo@bar.batz,Lorem Ipsum <lor@em.ips>', $context['recipients']);
$this->assertContains('Head: er', $context['content']); $this->assertStringContainsString('Head: er', $context['content']);
$this->assertContains('Message body', $context['content']); $this->assertStringContainsString('Message body', $context['content']);
}); });
/** @var LogTransport|MockObject $transport */ /** @var LogTransport|MockObject $transport */

@ -2,16 +2,19 @@
namespace Engelsystem\Test\Unit\Middleware; namespace Engelsystem\Test\Unit\Middleware;
use DMS\PHPUnitExtensions\ArraySubset\ArraySubsetAsserts;
use Engelsystem\Config\Config; use Engelsystem\Config\Config;
use Engelsystem\Http\Response; use Engelsystem\Http\Response;
use Engelsystem\Middleware\AddHeaders; use Engelsystem\Middleware\AddHeaders;
use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\TestCase; use PHPUnit\Framework\TestCase;
use PHPUnit_Framework_MockObject_MockObject as MockObject;
use Psr\Http\Message\ServerRequestInterface; use Psr\Http\Message\ServerRequestInterface;
use Psr\Http\Server\RequestHandlerInterface; use Psr\Http\Server\RequestHandlerInterface;
class AddHeadersTest extends TestCase class AddHeadersTest extends TestCase
{ {
use ArraySubsetAsserts;
/** /**
* @covers \Engelsystem\Middleware\AddHeaders::__construct * @covers \Engelsystem\Middleware\AddHeaders::__construct
* @covers \Engelsystem\Middleware\AddHeaders::process * @covers \Engelsystem\Middleware\AddHeaders::process

@ -7,8 +7,8 @@ use Engelsystem\Middleware\Dispatcher;
use Engelsystem\Test\Unit\Middleware\Stub\NotARealMiddleware; use Engelsystem\Test\Unit\Middleware\Stub\NotARealMiddleware;
use InvalidArgumentException; use InvalidArgumentException;
use LogicException; use LogicException;
use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\TestCase; use PHPUnit\Framework\TestCase;
use PHPUnit_Framework_MockObject_MockObject as MockObject;
use Psr\Http\Message\ResponseInterface; use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface; use Psr\Http\Message\ServerRequestInterface;
use Psr\Http\Server\MiddlewareInterface; use Psr\Http\Server\MiddlewareInterface;

@ -9,8 +9,8 @@ use Engelsystem\Middleware\ExceptionHandler;
use Engelsystem\Test\Unit\Middleware\Stub\ExceptionMiddlewareHandler; use Engelsystem\Test\Unit\Middleware\Stub\ExceptionMiddlewareHandler;
use Engelsystem\Test\Unit\Middleware\Stub\ReturnResponseMiddlewareHandler; use Engelsystem\Test\Unit\Middleware\Stub\ReturnResponseMiddlewareHandler;
use Illuminate\Contracts\Container\Container as ContainerInterface; use Illuminate\Contracts\Container\Container as ContainerInterface;
use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\TestCase; use PHPUnit\Framework\TestCase;
use PHPUnit_Framework_MockObject_MockObject as MockObject;
use Psr\Http\Message\ResponseInterface; use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface; use Psr\Http\Message\ServerRequestInterface;
@ -22,13 +22,13 @@ class ExceptionHandlerTest extends TestCase
*/ */
public function testRegister() public function testRegister()
{ {
/** @var MockObject|ContainerInterface $container */ /** @var ContainerInterface|MockObject $container */
$container = $this->getMockForAbstractClass(ContainerInterface::class); $container = $this->getMockForAbstractClass(ContainerInterface::class);
/** @var MockObject|ServerRequestInterface $request */ /** @var ServerRequestInterface|MockObject $request */
$request = $this->getMockBuilder(ServerRequestInterface::class)->getMock(); $request = $this->getMockBuilder(ServerRequestInterface::class)->getMock();
/** @var MockObject|ResponseInterface $response */ /** @var ResponseInterface|MockObject $response */
$response = $this->getMockBuilder(Response::class)->getMock(); $response = $this->getMockBuilder(Response::class)->getMock();
/** @var MockObject|Handler $errorHandler */ /** @var Handler|MockObject $errorHandler */
$errorHandler = $this->getMockBuilder(Handler::class)->getMock(); $errorHandler = $this->getMockBuilder(Handler::class)->getMock();
$returnResponseHandler = new ReturnResponseMiddlewareHandler($response); $returnResponseHandler = new ReturnResponseMiddlewareHandler($response);
$throwExceptionHandler = new ExceptionMiddlewareHandler(); $throwExceptionHandler = new ExceptionMiddlewareHandler();

@ -6,8 +6,8 @@ use Engelsystem\Helpers\Authenticator;
use Engelsystem\Helpers\Translator; use Engelsystem\Helpers\Translator;
use Engelsystem\Http\Request; use Engelsystem\Http\Request;
use Engelsystem\Middleware\LegacyMiddleware; use Engelsystem\Middleware\LegacyMiddleware;
use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\TestCase; use PHPUnit\Framework\TestCase;
use PHPUnit_Framework_MockObject_MockObject as MockObject;
use Psr\Container\ContainerInterface; use Psr\Container\ContainerInterface;
use Psr\Http\Message\ResponseInterface; use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface; use Psr\Http\Message\ServerRequestInterface;

@ -3,8 +3,8 @@
namespace Engelsystem\Test\Unit\Middleware; namespace Engelsystem\Test\Unit\Middleware;
use Engelsystem\Middleware\SendResponseHandler; use Engelsystem\Middleware\SendResponseHandler;
use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\TestCase; use PHPUnit\Framework\TestCase;
use PHPUnit_Framework_MockObject_MockObject as MockObject;
use Psr\Http\Message\ResponseInterface; use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface; use Psr\Http\Message\ServerRequestInterface;
use Psr\Http\Server\RequestHandlerInterface; use Psr\Http\Server\RequestHandlerInterface;

@ -34,7 +34,7 @@ class SessionHandlerServiceProviderTest extends ServiceProviderTest
->willReturnCallback(function (callable $callable) { ->willReturnCallback(function (callable $callable) {
$paths = $callable(); $paths = $callable();
$this->assertTrue(is_array($paths)); $this->assertIsArray($paths);
$this->assertTrue(in_array('/metrics', $paths)); $this->assertTrue(in_array('/metrics', $paths));
}); });

@ -3,8 +3,8 @@
namespace Engelsystem\Test\Unit\Middleware; namespace Engelsystem\Test\Unit\Middleware;
use Engelsystem\Middleware\SessionHandler; use Engelsystem\Middleware\SessionHandler;
use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\TestCase; use PHPUnit\Framework\TestCase;
use PHPUnit_Framework_MockObject_MockObject as MockObject;
use Psr\Http\Message\ResponseInterface; use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface; use Psr\Http\Message\ServerRequestInterface;
use Psr\Http\Server\RequestHandlerInterface; use Psr\Http\Server\RequestHandlerInterface;

@ -4,8 +4,8 @@ namespace Engelsystem\Test\Unit\Middleware;
use Engelsystem\Helpers\Translator; use Engelsystem\Helpers\Translator;
use Engelsystem\Middleware\SetLocale; use Engelsystem\Middleware\SetLocale;
use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\TestCase; use PHPUnit\Framework\TestCase;
use PHPUnit_Framework_MockObject_MockObject as MockObject;
use Psr\Http\Message\ResponseInterface; use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface; use Psr\Http\Message\ServerRequestInterface;
use Psr\Http\Server\RequestHandlerInterface; use Psr\Http\Server\RequestHandlerInterface;

@ -121,7 +121,7 @@ class EventConfigTest extends TestCase
/** /**
* Prepare test * Prepare test
*/ */
protected function setUp() protected function setUp(): void
{ {
$this->initDatabase(); $this->initDatabase();
} }

@ -26,7 +26,7 @@ class HasUserModelTest extends TestCase
/** /**
* Prepare test * Prepare test
*/ */
protected function setUp() protected function setUp(): void
{ {
$this->initDatabase(); $this->initDatabase();
} }

@ -2,6 +2,7 @@
namespace Engelsystem\Test\Unit\Models; namespace Engelsystem\Test\Unit\Models;
use DMS\PHPUnitExtensions\ArraySubset\ArraySubsetAsserts;
use Engelsystem\Models\User\Contact; use Engelsystem\Models\User\Contact;
use Engelsystem\Models\User\HasUserModel; use Engelsystem\Models\User\HasUserModel;
use Engelsystem\Models\User\PersonalData; use Engelsystem\Models\User\PersonalData;
@ -13,6 +14,7 @@ use PHPUnit\Framework\TestCase;
class UserTest extends TestCase class UserTest extends TestCase
{ {
use ArraySubsetAsserts;
use HasDatabase; use HasDatabase;
protected $data = [ protected $data = [
@ -91,7 +93,7 @@ class UserTest extends TestCase
/** /**
* Prepare test * Prepare test
*/ */
protected function setUp() protected function setUp(): void
{ {
$this->initDatabase(); $this->initDatabase();
} }

@ -58,7 +58,10 @@ class HtmlEngineTest extends TestCase
return $fileName; return $fileName;
} }
public function tearDown() /**
* Remove files
*/
protected function tearDown(): void
{ {
foreach ($this->tmpFileNames as $fileName) { foreach ($this->tmpFileNames as $fileName) {
unlink($fileName); unlink($fileName);

@ -7,7 +7,7 @@ use Engelsystem\Renderer\HtmlEngine;
use Engelsystem\Renderer\Renderer; use Engelsystem\Renderer\Renderer;
use Engelsystem\Renderer\RendererServiceProvider; use Engelsystem\Renderer\RendererServiceProvider;
use Engelsystem\Test\Unit\ServiceProviderTest; use Engelsystem\Test\Unit\ServiceProviderTest;
use PHPUnit_Framework_MockObject_MockObject; use PHPUnit\Framework\MockObject\MockObject;
class RendererServiceProviderTest extends ServiceProviderTest class RendererServiceProviderTest extends ServiceProviderTest
{ {
@ -18,10 +18,10 @@ class RendererServiceProviderTest extends ServiceProviderTest
*/ */
public function testRegister() public function testRegister()
{ {
/** @var PHPUnit_Framework_MockObject_MockObject|Renderer $renderer */ /** @var Renderer|MockObject $renderer */
$renderer = $this->getMockBuilder(Renderer::class) $renderer = $this->getMockBuilder(Renderer::class)
->getMock(); ->getMock();
/** @var PHPUnit_Framework_MockObject_MockObject|HtmlEngine $htmlEngine */ /** @var HtmlEngine|MockObject $htmlEngine */
$htmlEngine = $this->getMockBuilder(HtmlEngine::class) $htmlEngine = $this->getMockBuilder(HtmlEngine::class)
->getMock(); ->getMock();
@ -57,12 +57,12 @@ class RendererServiceProviderTest extends ServiceProviderTest
*/ */
public function testBoot() public function testBoot()
{ {
/** @var PHPUnit_Framework_MockObject_MockObject|Renderer $renderer */ /** @var Renderer|MockObject $renderer */
$renderer = $this->getMockBuilder(Renderer::class) $renderer = $this->getMockBuilder(Renderer::class)
->getMock(); ->getMock();
/** @var PHPUnit_Framework_MockObject_MockObject|EngineInterface $engine1 */ /** @var EngineInterface|MockObject $engine1 */
$engine1 = $this->getMockForAbstractClass(EngineInterface::class); $engine1 = $this->getMockForAbstractClass(EngineInterface::class);
/** @var PHPUnit_Framework_MockObject_MockObject|EngineInterface $engine2 */ /** @var EngineInterface|MockObject $engine2 */
$engine2 = $this->getMockForAbstractClass(EngineInterface::class); $engine2 = $this->getMockForAbstractClass(EngineInterface::class);
$app = $this->getApp(['get', 'tagged']); $app = $this->getApp(['get', 'tagged']);

@ -4,8 +4,8 @@ namespace Engelsystem\Test\Unit\Renderer;
use Engelsystem\Renderer\EngineInterface; use Engelsystem\Renderer\EngineInterface;
use Engelsystem\Renderer\Renderer; use Engelsystem\Renderer\Renderer;
use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\TestCase; use PHPUnit\Framework\TestCase;
use PHPUnit_Framework_MockObject_MockObject as MockObject;
use Psr\Log\LoggerInterface; use Psr\Log\LoggerInterface;
class RendererTest extends TestCase class RendererTest extends TestCase
@ -14,7 +14,7 @@ class RendererTest extends TestCase
{ {
$renderer = new Renderer(); $renderer = new Renderer();
/** @var MockObject|EngineInterface $nullRenderer */ /** @var EngineInterface|MockObject $nullRenderer */
$nullRenderer = $this->getMockForAbstractClass(EngineInterface::class); $nullRenderer = $this->getMockForAbstractClass(EngineInterface::class);
$nullRenderer->expects($this->atLeastOnce()) $nullRenderer->expects($this->atLeastOnce())
@ -22,7 +22,7 @@ class RendererTest extends TestCase
->willReturn(false); ->willReturn(false);
$renderer->addRenderer($nullRenderer); $renderer->addRenderer($nullRenderer);
/** @var MockObject|EngineInterface $mockRenderer */ /** @var EngineInterface|MockObject $mockRenderer */
$mockRenderer = $this->getMockForAbstractClass(EngineInterface::class); $mockRenderer = $this->getMockForAbstractClass(EngineInterface::class);
$mockRenderer->expects($this->atLeastOnce()) $mockRenderer->expects($this->atLeastOnce())
@ -45,7 +45,7 @@ class RendererTest extends TestCase
{ {
$renderer = new Renderer(); $renderer = new Renderer();
/** @var MockObject|LoggerInterface $loggerMock */ /** @var LoggerInterface|MockObject $loggerMock */
$loggerMock = $this->getMockForAbstractClass(LoggerInterface::class); $loggerMock = $this->getMockForAbstractClass(LoggerInterface::class);
$loggerMock $loggerMock
->expects($this->once()) ->expects($this->once())

@ -2,6 +2,7 @@
namespace Engelsystem\Test\Unit\Renderer\Twig\Extensions; namespace Engelsystem\Test\Unit\Renderer\Twig\Extensions;
use DMS\PHPUnitExtensions\ArraySubset\ArraySubsetAsserts;
use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\TestCase; use PHPUnit\Framework\TestCase;
use Twig_Function as TwigFunction; use Twig_Function as TwigFunction;
@ -9,6 +10,8 @@ use Twig_Node as TwigNode;
abstract class ExtensionTest extends TestCase abstract class ExtensionTest extends TestCase
{ {
use ArraySubsetAsserts;
/** /**
* Assert that a twig filter was registered * Assert that a twig filter was registered
* *

@ -3,7 +3,7 @@
namespace Engelsystem\Test\Unit; namespace Engelsystem\Test\Unit;
use Engelsystem\Application; use Engelsystem\Application;
use PHPUnit_Framework_MockObject_MockObject as MockObject; use PHPUnit\Framework\MockObject\MockObject;
abstract class ServiceProviderTest extends TestCase abstract class ServiceProviderTest extends TestCase
{ {
@ -13,7 +13,7 @@ abstract class ServiceProviderTest extends TestCase
*/ */
protected function getApp($methods = ['make', 'instance']) protected function getApp($methods = ['make', 'instance'])
{ {
/** @var MockObject|Application $app */ /** @var Application|MockObject $app */
return $this->getMockBuilder(Application::class) return $this->getMockBuilder(Application::class)
->setMethods($methods) ->setMethods($methods)
->getMock(); ->getMock();

@ -3,8 +3,8 @@
namespace Engelsystem\Test\Unit; namespace Engelsystem\Test\Unit;
use PHPUnit\Framework\MockObject\Matcher\InvokedRecorder; use PHPUnit\Framework\MockObject\Matcher\InvokedRecorder;
use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\TestCase as PHPUnitTestCase; use PHPUnit\Framework\TestCase as PHPUnitTestCase;
use PHPUnit_Framework_MockObject_MockObject as MockObject;
abstract class TestCase extends PHPUnitTestCase abstract class TestCase extends PHPUnitTestCase
{ {

Loading…
Cancel
Save