|
| 1 | +<?php |
| 2 | + |
| 3 | +namespace ApiSkeletonsTest\Laravel\Doctrine\DataFixture; |
| 4 | + |
| 5 | +use ApiSkeletons\Laravel\HAL\Doctrine\ServiceProvider; |
| 6 | +use Doctrine\Laminas\Hydrator\DoctrineObject; |
| 7 | +use Doctrine\ORM\EntityManager; |
| 8 | +use Doctrine\ORM\Tools\SchemaTool; |
| 9 | +use Illuminate\Support\Facades\Route; |
| 10 | +use LaravelDoctrine\ORM\DoctrineServiceProvider; |
| 11 | +use Orchestra\Testbench\TestCase as OrchestraTestCase; |
| 12 | + |
| 13 | +abstract class TestCase extends OrchestraTestCase |
| 14 | +{ |
| 15 | + public function setUp(): void |
| 16 | + { |
| 17 | + parent::setUp(); |
| 18 | + |
| 19 | + Route::get('address', function() { |
| 20 | + return true; |
| 21 | + })->name('api.address::fetchAll'); |
| 22 | + Route::get('address/{id}', function() { |
| 23 | + return true; |
| 24 | + })->name('api.address::fetch'); |
| 25 | + |
| 26 | + Route::get('artist', function() { |
| 27 | + return true; |
| 28 | + })->name('api.artist::fetchAll'); |
| 29 | + Route::get('artist/{id}', function() { |
| 30 | + return true; |
| 31 | + })->name('api.artist::fetch'); |
| 32 | + |
| 33 | + Route::get('performance', function() { |
| 34 | + return true; |
| 35 | + })->name('api.performance::fetchAll'); |
| 36 | + Route::get('performance/{id}', function() { |
| 37 | + return true; |
| 38 | + })->name('api.performance::fetch'); |
| 39 | + |
| 40 | + Route::get('recording', function() { |
| 41 | + return true; |
| 42 | + })->name('api.recording::fetchAll'); |
| 43 | + Route::get('recording/{id}', function() { |
| 44 | + return true; |
| 45 | + })->name('api.recording::fetch'); |
| 46 | + |
| 47 | + Route::get('user', function() { |
| 48 | + return true; |
| 49 | + })->name('api.user::fetchAll'); |
| 50 | + Route::get('user/{id}', function() { |
| 51 | + return true; |
| 52 | + })->name('api.user::fetch'); |
| 53 | + |
| 54 | + } |
| 55 | + |
| 56 | + protected function getPackageProviders($app) |
| 57 | + { |
| 58 | + return [ |
| 59 | + DoctrineServiceProvider::class, |
| 60 | + ServiceProvider::class, |
| 61 | + ]; |
| 62 | + } |
| 63 | + |
| 64 | + protected function getEnvironmentSetUp($app) |
| 65 | + { |
| 66 | + $app['config']['doctrine.managers.default.paths'] = [ |
| 67 | + __DIR__ . '/config' |
| 68 | + ]; |
| 69 | + |
| 70 | + $app['config']['doctrine.managers.default.namespaces'] = [ |
| 71 | + 'ApiSkeletonsTest\Laravel\HAL\Doctrine\Entity', |
| 72 | + ]; |
| 73 | + |
| 74 | + $app['config']['doctrine.managers.default.meta'] = 'xml'; |
| 75 | + |
| 76 | + $app['config']['hal-doctrine'] = include(__DIR__ . '/config/hal-doctrine.php'); |
| 77 | + |
| 78 | + $app['config']['doctrine.custom_hydration_modes'] = [ |
| 79 | + 'hal-doctrine' => DoctrineObject::class, |
| 80 | + ]; |
| 81 | + } |
| 82 | + |
| 83 | + protected function createDatabase(): EntityManager |
| 84 | + { |
| 85 | + $entityManager = app('em'); |
| 86 | + $tool = new SchemaTool($entityManager); |
| 87 | + $tool->createSchema($entityManager->getMetadataFactory()->getAllMetadata()); |
| 88 | + |
| 89 | + return $entityManager; |
| 90 | + } |
| 91 | +} |
0 commit comments