Skip to content

Commit f300969

Browse files
committed
Tests: refactor
1 parent 0e4adb7 commit f300969

File tree

4 files changed

+55
-47
lines changed

4 files changed

+55
-47
lines changed

tests/.coveralls.yml

Lines changed: 0 additions & 4 deletions
This file was deleted.
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
<?php declare (strict_types = 1);
2+
3+
namespace Tests\Cases\DI;
4+
5+
use Contributte\Elastica\Client;
6+
use Contributte\Elastica\DI\ElasticaExtension;
7+
use Contributte\Elastica\Diagnostics\Panel;
8+
use Contributte\Tester\Utils\ContainerBuilder;
9+
use Nette\DI\Compiler;
10+
use Nette\DI\MissingServiceException;
11+
use Tester\Assert;
12+
use Tester\TestCase;
13+
14+
require_once __DIR__ . '/../../bootstrap.php';
15+
16+
class ElasticaExtensionTest extends TestCase
17+
{
18+
19+
public function testRegisterServicesWithTracyPanel(): void
20+
{
21+
$container = ContainerBuilder::of()
22+
->withCompiler(static function (Compiler $compiler): void {
23+
$compiler->addExtension('elastica', new ElasticaExtension());
24+
$compiler->addConfig(['elastica' => ['debug' => true]]);
25+
})
26+
->build();
27+
28+
Assert::type(Client::class, $container->getService('elastica.client'));
29+
Assert::type(Panel::class, $container->getService('elastica.panel'));
30+
}
31+
32+
public function testWithoutTracyPanel(): void
33+
{
34+
Assert::exception(static function (): void {
35+
$container = ContainerBuilder::of()
36+
->withCompiler(static function (Compiler $compiler): void {
37+
$compiler->addExtension('elastica', new ElasticaExtension());
38+
})
39+
->build();
40+
41+
$container->getService('elastica.panel');
42+
}, MissingServiceException::class);
43+
}
44+
45+
}
46+
47+
(new ElasticaExtensionTest())->run();

tests/DI/ElasticaExtensionTest.php

Lines changed: 0 additions & 42 deletions
This file was deleted.

tests/bootstrap.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
11
<?php declare(strict_types = 1);
22

3-
require __DIR__ . '/../vendor/autoload.php';
3+
use Contributte\Tester\Environment;
4+
5+
if (@!include __DIR__ . '/../vendor/autoload.php') {
6+
echo 'Install Nette Tester using `composer update --dev`';
7+
exit(1);
8+
}
9+
10+
Environment::setup(__DIR__);

0 commit comments

Comments
 (0)