|
|
|
@ -2,10 +2,9 @@
|
|
|
|
|
|
|
|
|
|
namespace Engelsystem\Test\Feature\Database;
|
|
|
|
|
|
|
|
|
|
use Engelsystem\Application;
|
|
|
|
|
use Engelsystem\Config\Config;
|
|
|
|
|
use Engelsystem\Database\Database;
|
|
|
|
|
use Engelsystem\Database\DatabaseServiceProvider;
|
|
|
|
|
use PHPUnit\Framework\MockObject\MockObject;
|
|
|
|
|
|
|
|
|
|
class DatabaseServiceProviderTest extends DatabaseTest
|
|
|
|
|
{
|
|
|
|
@ -14,27 +13,13 @@ class DatabaseServiceProviderTest extends DatabaseTest
|
|
|
|
|
*/
|
|
|
|
|
public function testRegister()
|
|
|
|
|
{
|
|
|
|
|
/** @var Config|MockObject $config */
|
|
|
|
|
$config = $this->getMockBuilder(Config::class)
|
|
|
|
|
->getMock();
|
|
|
|
|
$this->app->instance('config', new Config([
|
|
|
|
|
'database' => $this->getDbConfig(),
|
|
|
|
|
'timezone' => 'UTC',
|
|
|
|
|
]));
|
|
|
|
|
|
|
|
|
|
/** @var Application|MockObject $app */
|
|
|
|
|
$app = $this->getMockBuilder(Application::class)
|
|
|
|
|
->setMethods(['get'])
|
|
|
|
|
->getMock();
|
|
|
|
|
Application::setInstance($app);
|
|
|
|
|
|
|
|
|
|
$app->expects($this->once())
|
|
|
|
|
->method('get')
|
|
|
|
|
->with('config')
|
|
|
|
|
->willReturn($config);
|
|
|
|
|
|
|
|
|
|
$config->expects($this->atLeastOnce())
|
|
|
|
|
->method('get')
|
|
|
|
|
->with('database')
|
|
|
|
|
->willReturn($this->getDbConfig());
|
|
|
|
|
|
|
|
|
|
$serviceProvider = new DatabaseServiceProvider($app);
|
|
|
|
|
$serviceProvider = new DatabaseServiceProvider($this->app);
|
|
|
|
|
$serviceProvider->register();
|
|
|
|
|
$this->assertTrue($this->app->has(Database::class));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|