Skip to content

Commit

Permalink
Tests: refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
f3l1x committed Nov 28, 2023
1 parent 0e4adb7 commit f300969
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 47 deletions.
4 changes: 0 additions & 4 deletions tests/.coveralls.yml

This file was deleted.

47 changes: 47 additions & 0 deletions tests/Cases/DI/ElasticaExtensionTest.php
@@ -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();
42 changes: 0 additions & 42 deletions tests/DI/ElasticaExtensionTest.php

This file was deleted.

9 changes: 8 additions & 1 deletion tests/bootstrap.php
@@ -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__);

0 comments on commit f300969

Please sign in to comment.