Skip to content

Commit

Permalink
Merge pull request #642 from TomHAnderson/feature/service-provider-test
Browse files Browse the repository at this point in the history
Test DoctrineServiceProvider
  • Loading branch information
TomHAnderson authored Oct 29, 2024
2 parents 0edc0ae + 7d9938b commit 9e3e2f2
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/DoctrineServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@

use function assert;
use function class_exists;
use function config;
use function config_path;

class DoctrineServiceProvider extends ServiceProvider
Expand Down Expand Up @@ -311,6 +312,6 @@ protected function registerConsoleCommands(): void

protected function shouldRegisterDoctrinePresenceValidator(): bool
{
return $this->app['config']->get('doctrine.doctrine_presence_verifier', true);
return config('doctrine.doctrine_presence_verifier', true);
}
}
40 changes: 40 additions & 0 deletions tests/Feature/DoctrineServiceProviderTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<?php

declare(strict_types=1);

namespace LaravelDoctrineTest\ORM\Feature;

use Doctrine\ORM\Mapping\ClassMetadataFactory;
use Doctrine\Persistence\ManagerRegistry;
use LaravelDoctrineTest\ORM\TestCase;

class DoctrineServiceProviderTest extends TestCase
{
public function testRegistryIsRegistered(): void
{
$registry = $this->app->get('registry');

$this->assertInstanceOf(
ManagerRegistry::class,
$registry,
);
}

public function testEntityManagerSingleton(): void
{
$em1 = $this->app->get('em');
$em2 = $this->app->get('em');

$this->assertSame($em1, $em2);
}

public function testMetaDataFactory(): void
{
$metaDataFactory = $this->app->get(ClassMetadataFactory::class);

$this->assertInstanceOf(
ClassMetadataFactory::class,
$metaDataFactory,
);
}
}

0 comments on commit 9e3e2f2

Please sign in to comment.