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
4 changed files
with
55 additions
and
47 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
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 declare (strict_types = 1); | ||
|
||
namespace Tests\Cases\DI; | ||
|
||
use Contributte\Elastica\Client; | ||
use Contributte\Elastica\DI\ElasticaExtension; | ||
use Contributte\Elastica\Diagnostics\Panel; | ||
use Contributte\Tester\Utils\ContainerBuilder; | ||
use Nette\DI\Compiler; | ||
use Nette\DI\MissingServiceException; | ||
use Tester\Assert; | ||
use Tester\TestCase; | ||
|
||
require_once __DIR__ . '/../../bootstrap.php'; | ||
|
||
class ElasticaExtensionTest extends TestCase | ||
{ | ||
|
||
public function testRegisterServicesWithTracyPanel(): void | ||
{ | ||
$container = ContainerBuilder::of() | ||
->withCompiler(static function (Compiler $compiler): void { | ||
$compiler->addExtension('elastica', new ElasticaExtension()); | ||
$compiler->addConfig(['elastica' => ['debug' => true]]); | ||
}) | ||
->build(); | ||
|
||
Assert::type(Client::class, $container->getService('elastica.client')); | ||
Assert::type(Panel::class, $container->getService('elastica.panel')); | ||
} | ||
|
||
public function testWithoutTracyPanel(): void | ||
{ | ||
Assert::exception(static function (): void { | ||
$container = ContainerBuilder::of() | ||
->withCompiler(static function (Compiler $compiler): void { | ||
$compiler->addExtension('elastica', new ElasticaExtension()); | ||
}) | ||
->build(); | ||
|
||
$container->getService('elastica.panel'); | ||
}, MissingServiceException::class); | ||
} | ||
|
||
} | ||
|
||
(new ElasticaExtensionTest())->run(); |
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,3 +1,10 @@ | ||
<?php declare(strict_types = 1); | ||
|
||
require __DIR__ . '/../vendor/autoload.php'; | ||
use Contributte\Tester\Environment; | ||
|
||
if (@!include __DIR__ . '/../vendor/autoload.php') { | ||
echo 'Install Nette Tester using `composer update --dev`'; | ||
exit(1); | ||
} | ||
|
||
Environment::setup(__DIR__); |