Skip to content

Commit

Permalink
Test DoctrineServiceProvider
Browse files Browse the repository at this point in the history
  • Loading branch information
TomHAnderson committed Oct 29, 2024
1 parent cb8b148 commit e65f033
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/DoctrineServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,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);

Check failure on line 314 in src/DoctrineServiceProvider.php

View workflow job for this annotation

GitHub Actions / Coding Standards / Coding Standards (8.2)

Function config() should not be referenced via a fallback global name, but via a use statement.
}
}
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

Check failure on line 19 in tests/Feature/DoctrineServiceProviderTest.php

View workflow job for this annotation

GitHub Actions / Coding Standards / Coding Standards (8.2)

Multi-line function calls must have a trailing comma after the last parameter.
);
}

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

Check failure on line 37 in tests/Feature/DoctrineServiceProviderTest.php

View workflow job for this annotation

GitHub Actions / Coding Standards / Coding Standards (8.2)

Multi-line function calls must have a trailing comma after the last parameter.
);
}
}

0 comments on commit e65f033

Please sign in to comment.