engelsystem/tests/Unit/ServiceProviderTest.php

34 lines
949 B
PHP
Raw Permalink Normal View History

2017-10-31 13:40:13 +01:00
<?php
declare(strict_types=1);
2017-10-31 13:40:13 +01:00
namespace Engelsystem\Test\Unit;
use Engelsystem\Application;
2023-05-03 17:51:43 +02:00
use Engelsystem\Config\Config;
use PHPUnit\Framework\MockObject\MockObject;
2017-10-31 13:40:13 +01:00
abstract class ServiceProviderTest extends TestCase
{
protected function getApp(array $methods = ['make', 'instance']): Application|MockObject
2017-10-31 13:40:13 +01:00
{
return $this->getMockBuilder(Application::class)
->onlyMethods($methods)
2017-10-31 13:40:13 +01:00
->getMock();
}
2023-05-03 17:51:43 +02:00
/**
* Creates an Application instance with a Config set as 'config'.
* Also sets up the instance as global Application instance.
*
* @param string[] $methods Names of the methods to mock
*/
protected function createAndSetUpAppWithConfig(array $methods = ['make', 'instance']): Application|MockObject
{
$app = $this->getApp($methods);
$app->instance('config', new Config([]));
Application::setInstance($app);
return $app;
}
2017-10-31 13:40:13 +01:00
}