Skip to content

Commit

Permalink
refactor: Extract bundle test setup
Browse files Browse the repository at this point in the history
  • Loading branch information
eFrane committed Feb 26, 2022
1 parent b11494f commit ca1ae79
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 14 deletions.
22 changes: 22 additions & 0 deletions tests/Bundle/BaseBundleTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php

namespace EFrane\TusBundle\Tests\Bundle;

use EFrane\TusBundle\Bundle\TusBundle;
use Nyholm\BundleTest\BaseBundleTestCase;

abstract class BaseBundleTest extends BaseBundleTestCase
{
protected function getBundleClass(): string
{
return TusBundle::class;
}

protected function getBootedKernel(): \Nyholm\BundleTest\AppKernel
{
$kernel = $this->createKernel();
$kernel->boot();

return $kernel;
}
}
15 changes: 1 addition & 14 deletions tests/Bundle/TusBundleTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,25 +11,12 @@
use EFrane\TusBundle\Bundle\TusBundle;
use Nyholm\BundleTest\BaseBundleTestCase;

class TusBundleTest extends BaseBundleTestCase
class TusBundleTest extends BaseBundleTest
{
protected function getBundleClass(): string
{
return TusBundle::class;
}

public function testBundleRegistration(): void
{
$kernel = $this->getBootedKernel();

self::assertInstanceOf(TusBundle::class, $kernel->getBundle('TusBundle'));
}

private function getBootedKernel(): \Nyholm\BundleTest\AppKernel
{
$kernel = $this->createKernel();
$kernel->boot();

return $kernel;
}
}

0 comments on commit ca1ae79

Please sign in to comment.