-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
150 additions
and
2 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
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,3 @@ | ||
error_level: "E_ALL" | ||
|
||
class_name: IntegrationSuiteGuy |
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,5 @@ | ||
<?php | ||
|
||
define('TEMP_DIR', __DIR__ . '/../_temp/integration_' . md5(time())); | ||
|
||
mkdir(TEMP_DIR); |
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,20 @@ | ||
extensions: | ||
arachne.containeradapter: Arachne\ContainerAdapter\DI\ContainerAdapterExtension | ||
arachne.doctrine: Arachne\Doctrine\DI\DoctrineExtension | ||
nette.caching: Nette\Bridges\CacheDI\CacheExtension( %tempDir% ) | ||
kdyby.annotations: Kdyby\Annotations\DI\AnnotationsExtension | ||
kdyby.events: Kdyby\Events\DI\EventsExtension | ||
kdyby.doctrine: Kdyby\Doctrine\DI\OrmExtension | ||
|
||
kdyby.doctrine: | ||
driver: pdo_sqlite | ||
memory: true | ||
|
||
kdyby.events: | ||
debugger: false | ||
|
||
services: | ||
subscriber: | ||
class: Tests\Integration\Fixtures\Subscriber | ||
tags: | ||
- arachne.doctrine.subscriber |
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,16 @@ | ||
extensions: | ||
arachne.containeradapter: Arachne\ContainerAdapter\DI\ContainerAdapterExtension | ||
arachne.doctrine: Arachne\Doctrine\DI\DoctrineExtension | ||
nette.caching: Nette\Bridges\CacheDI\CacheExtension( %tempDir% ) | ||
kdyby.annotations: Kdyby\Annotations\DI\AnnotationsExtension | ||
kdyby.doctrine: Kdyby\Doctrine\DI\OrmExtension | ||
|
||
kdyby.doctrine: | ||
driver: pdo_sqlite | ||
memory: true | ||
|
||
services: | ||
subscriber: | ||
class: Tests\Integration\Fixtures\Subscriber | ||
tags: | ||
- arachne.doctrine.subscriber |
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,47 @@ | ||
<?php | ||
|
||
namespace Tests\Integration; | ||
|
||
use Arachne\Bootstrap\Configurator; | ||
use Codeception\TestCase\Test; | ||
use Doctrine\Common\EventManager; | ||
use Symfony\Bridge\Doctrine\ContainerAwareEventManager; | ||
|
||
/** | ||
* @author Jáchym Toušek <enumag@gmail.com> | ||
*/ | ||
class DoctrineExtensionTest extends Test | ||
{ | ||
/** | ||
* @expectedException Nette\Utils\AssertionException | ||
* @expectedExceptionMessage Subscribers support requires 'Arachne\ContainerAdapter\DI\ContainerAdapterExtension' to be installed and 'Kdyby\Events\DI\EventsExtension' to NOT be installed. | ||
*/ | ||
public function testSubscriberException() | ||
{ | ||
$this->createContainer('subscriber-exception.neon'); | ||
} | ||
|
||
public function testSubscriber() | ||
{ | ||
$container = $this->createContainer('subscriber.neon'); | ||
|
||
/* @var $evm EventManager */ | ||
$evm = $container->getByType(EventManager::class); | ||
$this->assertInstanceOf(ContainerAwareEventManager::class, $evm); | ||
|
||
// Ensure laziness. | ||
$this->assertFalse($container->isCreated('subscriber')); | ||
$evm->dispatchEvent('fooEvent'); | ||
$this->assertFalse($container->isCreated('subscriber')); | ||
$evm->dispatchEvent('barEvent'); | ||
$this->assertTrue($container->isCreated('subscriber')); | ||
} | ||
|
||
private function createContainer($file) | ||
{ | ||
$config = new Configurator(); | ||
$config->setTempDirectory(TEMP_DIR); | ||
$config->addConfig(__DIR__ . '/../config/' . $file, false); | ||
return $config->createContainer(); | ||
} | ||
} |
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,22 @@ | ||
<?php | ||
|
||
namespace Tests\Integration\Fixtures; | ||
|
||
use Doctrine\Common\EventSubscriber; | ||
|
||
/** | ||
* @author Jáchym Toušek <enumag@gmail.com> | ||
*/ | ||
class Subscriber implements EventSubscriber | ||
{ | ||
public function getSubscribedEvents() | ||
{ | ||
return [ | ||
'barEvent', | ||
]; | ||
} | ||
|
||
public function barEvent() | ||
{ | ||
} | ||
} |