Skip to content

Commit fec8c08

Browse files
committed
- Adding test
1 parent d0dd953 commit fec8c08

File tree

7 files changed

+119
-0
lines changed

7 files changed

+119
-0
lines changed

tests/IPubTests/.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
coverage.dat
2+
*.actual
3+
*.expected
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
<?php
2+
/**
3+
* Test: IPub\DataTables\Extension
4+
* @testCase
5+
*
6+
* @copyright More in license.md
7+
* @license https://www.ipublikuj.eu
8+
* @author Adam Kadlec <[email protected]>
9+
* @package iPublikuj:DataTables!
10+
* @subpackage Tests
11+
* @since 1.0.0
12+
*
13+
* @date 16.03.18
14+
*/
15+
16+
declare(strict_types = 1);
17+
18+
namespace IPubTests\DataTables;
19+
20+
use Nette;
21+
22+
use Tester;
23+
use Tester\Assert;
24+
25+
use IPub\DataTables;
26+
27+
require __DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'bootstrap.php';
28+
29+
/**
30+
* Extension registration tests
31+
*
32+
* @package iPublikuj:DataTables!
33+
* @subpackage Tests
34+
*
35+
* @author Adam Kadlec <[email protected]>
36+
*/
37+
class ExtensionTest extends Tester\TestCase
38+
{
39+
public function testFunctional() : void
40+
{
41+
$dic = $this->createContainer();
42+
43+
Assert::true($dic->getService('dataTables.stateSaver') instanceof DataTables\StateSavers\StateSaver);
44+
Assert::true($dic->getService('dataTables.grid') instanceof DataTables\Components\Control);
45+
}
46+
47+
/**
48+
* @return Nette\DI\Container
49+
*/
50+
private function createContainer() : Nette\DI\Container
51+
{
52+
$config = new Nette\Configurator();
53+
$config->setTempDirectory(TEMP_DIR);
54+
55+
DataTables\DI\DataTablesExtension::register($config);
56+
57+
return $config->createContainer();
58+
}
59+
}
60+
61+
\run(new ExtensionTest());
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
application:
2+
mapping:
3+
*: IPubTests\ConfirmationDialog\*Presenter
4+
5+
services:
6+
# Test presenter
7+
presenters.test:
8+
class: IPubTests\ConfirmationDialog\TestPresenter
9+
10+
router: IPubTests\ConfirmationDialog\Libs\RouterFactory::createRouter

tests/IPubTests/bootstrap.php

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
<?php
2+
3+
declare(strict_types = 1);
4+
5+
define('DS', DIRECTORY_SEPARATOR);
6+
7+
require __DIR__ . DS . '..' . DS . '..' . DS . 'vendor' . DS . 'autoload.php';
8+
9+
if (!class_exists('Tester\Assert')) {
10+
echo "Install Nette Tester using `composer update --dev`\n";
11+
exit(1);
12+
}
13+
14+
Tester\Environment::setup();
15+
date_default_timezone_set('Europe/Prague');
16+
17+
// Create temporary directory
18+
define('TEMP_DIR', __DIR__ . '/../tmp/' . (isset($_SERVER['argv']) ? md5(serialize($_SERVER['argv'])) : getmypid()));
19+
Tester\Helpers::purge(TEMP_DIR);
20+
\Tracy\Debugger::$logDirectory = TEMP_DIR;
21+
22+
$_SERVER = array_intersect_key($_SERVER, array_flip([
23+
'PHP_SELF', 'SCRIPT_NAME', 'SERVER_ADDR', 'SERVER_SOFTWARE', 'HTTP_HOST', 'DOCUMENT_ROOT', 'OS', 'argc', 'argv'
24+
]));
25+
$_SERVER['REQUEST_TIME'] = 1234567890;
26+
$_ENV = $_GET = $_POST = [];
27+
28+
function id($val)
29+
{
30+
return $val;
31+
}
32+
33+
function run(Tester\TestCase $testCase)
34+
{
35+
$testCase->run();
36+
}

tests/php.ini-unix

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
extension = xdebug.so
2+
3+
[xdebug]
4+
xdebug.enable = On

tests/php.ini-win

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[PHP]
2+
extension_dir = "./ext"
3+
extension=php_xdebug.dll

tests/tmp/.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
*
2+
!.*

0 commit comments

Comments
 (0)