Skip to content

Commit 91588c9

Browse files
author
plfort
committed
Add DataGridExtensionFunctionalTest
1 parent e9340fe commit 91588c9

9 files changed

Lines changed: 778 additions & 0 deletions

Tests/Twig/DataGridExtensionFunctionalTest.php

Lines changed: 612 additions & 0 deletions
Large diffs are not rendered by default.

Tests/app/AppKernel.php

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
<?php
2+
3+
use Symfony\Component\HttpKernel\Kernel;
4+
use Symfony\Component\Config\Loader\LoaderInterface;
5+
6+
class AppKernel extends Kernel
7+
{
8+
9+
public function registerBundles()
10+
{
11+
return array(
12+
new Symfony\Bundle\FrameworkBundle\FrameworkBundle(),
13+
new Symfony\Bundle\TwigBundle\TwigBundle(),
14+
new \APY\DataGridBundle\APYDataGridBundle()
15+
);
16+
}
17+
18+
public function registerContainerConfiguration(LoaderInterface $loader)
19+
{
20+
21+
$loader->load(__DIR__.'/config_test.yml');
22+
}
23+
24+
/**
25+
* @return string
26+
*/
27+
public function getCacheDir()
28+
{
29+
$cacheDir = sys_get_temp_dir().'/cache';
30+
if (!is_dir($cacheDir)) {
31+
mkdir($cacheDir, 0777, true);
32+
}
33+
34+
return $cacheDir;
35+
}
36+
37+
/**
38+
* @return string
39+
*/
40+
public function getLogDir()
41+
{
42+
$logDir = sys_get_temp_dir().'/logs';
43+
if (!is_dir($logDir)) {
44+
mkdir($logDir, 0777, true);
45+
}
46+
47+
return $logDir;
48+
}
49+
50+
protected function build(\Symfony\Component\DependencyInjection\ContainerBuilder $container)
51+
{
52+
$container->addCompilerPass(
53+
new \APY\DataGridBundle\Tests\app\CompilerPass(),
54+
\Symfony\Component\DependencyInjection\Compiler\PassConfig::TYPE_BEFORE_OPTIMIZATION
55+
);
56+
}
57+
}

Tests/app/CompilerPass.php

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<?php
2+
/**
3+
* Created by PhpStorm.
4+
* User: pilou
5+
* Date: 10/11/17
6+
* Time: 23:19
7+
*/
8+
9+
namespace APY\DataGridBundle\Tests\app;
10+
11+
12+
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
13+
use Symfony\Component\DependencyInjection\ContainerBuilder;
14+
15+
class CompilerPass implements CompilerPassInterface
16+
{
17+
18+
/**
19+
* You can modify the container here before it is dumped to PHP code.
20+
*
21+
* @param ContainerBuilder $container
22+
*/
23+
public function process(ContainerBuilder $container)
24+
{
25+
$container->getDefinition('grid.twig_extension')->setPublic(true);
26+
}
27+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
{# grid_%gridid%_column_ #}
2+
{%- block grid_mygridid_column_myarraycolid_cell -%}
3+
grid_mygridid_column_myarraycolid_cell
4+
{%- endblock -%}
5+
6+
{%- block grid_mygridid_column_array_cell -%}
7+
should_not_be_used
8+
{%- endblock -%}
9+
10+
{%- block grid_mygridid_column_id_myarraycolid_cell -%}
11+
should_not_be_used
12+
{%- endblock -%}
13+
14+
{# grid_column_ #}
15+
{%- block grid_column_myarraycolid_cell -%}
16+
grid_column_myarraycolid_cell
17+
{%- endblock -%}
18+
19+
{%- block grid_column_array_cell -%}
20+
should_not_be_used
21+
{%- endblock -%}
22+
23+
{%- block grid_column_id_myarraycolid_cell -%}
24+
should_not_be_used
25+
{%- endblock -%}
26+
27+
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{%- block grid_mygridid_column_id_myarraycolid_cell -%}
2+
grid_mygridid_column_id_myarraycolid_cell
3+
{%- endblock -%}
4+
5+
{%- block grid_mygridid_column_type_array_cell -%}
6+
should_not_be_used
7+
{%- endblock -%}
8+
9+
10+
{%- block grid_column_id_myarraycolid_cell -%}
11+
grid_column_id_myarraycolid_cell
12+
{%- endblock -%}
13+
{%- block grid_column_type_array_cell -%}
14+
should_not_be_used
15+
{%- endblock -%}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{# start ArrayColumn#}
2+
{%- block grid_column_array_cell -%}
3+
grid_column_array_cell
4+
{%- endblock -%}
5+
6+
{%- block grid_mygridid_column_array_cell -%}
7+
grid_mygridid_column_array_cell
8+
{%- endblock -%}
9+
10+
11+
{%- block grid_column_id_myarraycolid_cell -%}
12+
should_not_be_used
13+
{%- endblock -%}
14+
15+
{%- block grid_mygridid_column_id_myarraycolid_cell -%}
16+
should_not_be_used
17+
{%- endblock -%}
18+
{# end ArrayColumn#}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{%- block grid_column_type_array_cell -%}
2+
grid_column_type_array_cell
3+
{%- endblock -%}
4+
5+
{%- block grid_mygridid_column_type_array_cell -%}
6+
grid_mygridid_column_type_array_cell
7+
{%- endblock -%}

Tests/app/config_test.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
framework:
2+
secret: "secret"
3+
router:
4+
resource: "%kernel.root_dir%/routing.yml"
5+
form: ~
6+
7+
twig:
8+
paths:
9+
'%kernel.root_dir%/../../Resources/views': APYDataGridBundle
10+
11+
apy_data_grid:
12+
theme: '@APYDataGridBundle/blocks.html.twig'

phpunit.xml.dist

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@
66
<directory suffix="Test.php">./Tests</directory>
77
</testsuite>
88
</testsuites>
9+
<php>
10+
<server name="KERNEL_DIR" value="./Tests/app" />
11+
</php>
912
<filter>
1013
<whitelist>
1114
<directory>./</directory>

0 commit comments

Comments
 (0)