-
Notifications
You must be signed in to change notification settings - Fork 178
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #88 from laravel-doctrine/hotfix/boot-extensions
Hotfix/boot extensions
- Loading branch information
Showing
3 changed files
with
100 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
<?php | ||
|
||
namespace LaravelDoctrine\ORM\Http\Middleware; | ||
|
||
use Closure; | ||
use LaravelDoctrine\ORM\Extensions\ExtensionManager; | ||
|
||
class BootExtensions | ||
{ | ||
/** | ||
* @var ExtensionManager | ||
*/ | ||
protected $manager; | ||
|
||
/** | ||
* @param ExtensionManager $manager | ||
*/ | ||
public function __construct(ExtensionManager $manager) | ||
{ | ||
$this->manager = $manager; | ||
} | ||
|
||
/** | ||
* @param \Illuminate\Http\Request $request | ||
* @param Closure $next | ||
* | ||
* @return mixed | ||
*/ | ||
public function handle($request, Closure $next) | ||
{ | ||
$this->manager->boot(); | ||
|
||
return $next($request); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<?php | ||
|
||
use LaravelDoctrine\ORM\Http\Middleware\BootExtensions; | ||
use Mockery as m; | ||
|
||
class BootExtensionsTest extends PHPUnit_Framework_TestCase | ||
{ | ||
public function tearDown() | ||
{ | ||
m::close(); | ||
} | ||
|
||
public function testHandle() | ||
{ | ||
$kernelMock = m::mock(LaravelDoctrine\ORM\Extensions\ExtensionManager::class) | ||
->shouldReceive('boot') | ||
->once() | ||
->getMock(); | ||
|
||
$requestMock = m::mock(Illuminate\Http\Request::class); | ||
|
||
$called = false; | ||
|
||
$nextMock = function () use (&$called) { | ||
$called = true; | ||
}; | ||
|
||
/** @noinspection PhpParamsInspection */ | ||
$middleware = new BootExtensions($kernelMock); | ||
|
||
/** @noinspection PhpParamsInspection */ | ||
$middleware->handle($requestMock, $nextMock); | ||
|
||
$this->assertTrue($called); | ||
} | ||
} |