Skip to content

Commit

Permalink
Merge pull request #643 from TomHAnderson/feature/service-provider-test
Browse files Browse the repository at this point in the history
Feature/service provider test
  • Loading branch information
TomHAnderson authored Oct 30, 2024
2 parents 9e3e2f2 + a245230 commit 936cadc
Show file tree
Hide file tree
Showing 6 changed files with 105 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/coding-standards.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ on:
jobs:
coding-standards:
name: "Coding Standards"
uses: "doctrine/.github/.github/workflows/coding-standards.yml@1.3.0"
uses: "doctrine/.github/.github/workflows/coding-standards.yml@5.2.0"
with:
php-version: '8.2'
composer-options: '--prefer-dist --ignore-platform-req=php'
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -116,4 +116,4 @@
"@php vendor/bin/phpstan analyse --verbose --ansi"
]
}
}
}
1 change: 0 additions & 1 deletion config/doctrine.php
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,6 @@
|
*/
'extensions' => [
//LaravelDoctrine\ORM\Extensions\TablePrefix\TablePrefixExtension::class,
//LaravelDoctrine\Extensions\Timestamps\TimestampableExtension::class,
//LaravelDoctrine\Extensions\SoftDeletes\SoftDeleteableExtension::class,
//LaravelDoctrine\Extensions\Sluggable\SluggableExtension::class,
Expand Down
37 changes: 37 additions & 0 deletions tests/Feature/DoctrineServiceProviderCustomFunctionsTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?php

declare(strict_types=1);

namespace LaravelDoctrineTest\ORM\Feature;

use Doctrine\Persistence\ManagerRegistry;
use Illuminate\Config\Repository;
use Illuminate\Foundation\Application;
use LaravelDoctrineTest\ORM\TestCase;

use function tap;

class DoctrineServiceProviderCustomFunctionsTest extends TestCase
{
/**
* @param Application $app
* phpcs:disable
*/
protected function defineEnvironment($app): void
{
// Setup default database to use sqlite :memory:
tap($app['config'], static function (Repository $config): void {
// Custom functions are tested in the extensions repository
});
}

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

$this->assertInstanceOf(
ManagerRegistry::class,
$registry,
);
}
}
32 changes: 32 additions & 0 deletions tests/Feature/DoctrineServiceProviderExtensionTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?php

declare(strict_types=1);

namespace LaravelDoctrineTest\ORM\Feature;

use Illuminate\Config\Repository;
use Illuminate\Foundation\Application;
use LaravelDoctrineTest\ORM\TestCase;

use function tap;

class DoctrineServiceProviderExtensionTest extends TestCase
{
/**
* @param Application $app
* phpcs:disable
*/
protected function defineEnvironment($app): void
{
// Setup default database to use sqlite :memory:
tap($app['config'], static function (Repository $config): void {
});
}

public function testExtensions(): void
{
$registry = $this->app->get('registry');

$this->assertTrue(true);
}
}
34 changes: 34 additions & 0 deletions tests/Feature/DoctrineServiceProviderInvalidExtensionTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?php

declare(strict_types=1);

namespace LaravelDoctrineTest\ORM\Feature;

use Illuminate\Config\Repository;
use Illuminate\Foundation\Application;
use LaravelDoctrine\ORM\Exceptions\ExtensionNotFound;
use LaravelDoctrineTest\ORM\TestCase;

use function tap;

class DoctrineServiceProviderInvalidExtensionTest extends TestCase
{
/**
* @param Application $app
* phpcs:disable
*/
protected function defineEnvironment($app): void
{
// Setup default database to use sqlite :memory:
tap($app['config'], static function (Repository $config): void {
$config->set('doctrine.extensions', ['invalid' => 'InvalalidExtension']);
});
}

public function testInvalidException(): void
{
$this->expectException(ExtensionNotFound::class);

$registry = $this->app->get('registry');
}
}

0 comments on commit 936cadc

Please sign in to comment.