Skip to content

Commit a5feaa6

Browse files
committed
Tests: Adding functional configuration tests
1 parent 3476683 commit a5feaa6

File tree

9 files changed

+163
-6
lines changed

9 files changed

+163
-6
lines changed

Resources/config/schema/overblog_graphiql-0.1.xsd

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<xsd:element name="config" type="config" />
88

99
<xsd:simpleType name="relayMode">
10-
<xsd:restriction>
10+
<xsd:restriction base="xsd:token">
1111
<xsd:enumeration value="modern" />
1212
<xsd:enumeration value="classic" />
1313
</xsd:restriction>
@@ -21,7 +21,9 @@
2121
</xsd:complexType>
2222

2323
<xsd:complexType name="config">
24-
<xsd:attribute name="template" type="xsd:string" />
25-
<xsd:attribute name="javascript_libraries" type="javascriptLibraries" />
24+
<xsd:choice maxOccurs="unbounded">
25+
<xsd:element name="template" type="xsd:string" minOccurs="0" maxOccurs="1" />
26+
<xsd:element name="javascript_libraries" type="javascriptLibraries" minOccurs="0" maxOccurs="1" />
27+
</xsd:choice>
2628
</xsd:complexType>
2729
</xsd:schema>

Tests/Fixtures/TestKernel.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public function registerBundles()
2121
}
2222

2323
/**
24-
* @inheritdoc
24+
* {@inheritdoc}
2525
*/
2626
public function registerContainerConfiguration(LoaderInterface $loader)
2727
{
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
<?php
2+
3+
namespace Overblog\GraphiQLBundle\Tests\Functional\DependencyInjection\Fixtures\Xml;
4+
5+
use Overblog\GraphiQLBundle\OverblogGraphiQLBundle;
6+
use Overblog\GraphiQLBundle\Tests\TestKernel as AbstractTestKernel;
7+
use Symfony\Bundle\FrameworkBundle\FrameworkBundle;
8+
use Symfony\Bundle\TwigBundle\TwigBundle;
9+
use Symfony\Component\Config\Loader\LoaderInterface;
10+
use Symfony\Component\DependencyInjection\ContainerBuilder;
11+
12+
final class TestKernel extends AbstractTestKernel
13+
{
14+
public function registerBundles()
15+
{
16+
return [
17+
new FrameworkBundle(),
18+
new TwigBundle(),
19+
new OverblogGraphiQLBundle(),
20+
];
21+
}
22+
23+
/**
24+
* {@inheritdoc}
25+
*/
26+
public function registerContainerConfiguration(LoaderInterface $loader)
27+
{
28+
$loader->load(__DIR__.'/config.xml');
29+
$loader->load(function (ContainerBuilder $container) {
30+
$container->loadFromExtension('framework', [
31+
'assets' => ['enabled' => false],
32+
]);
33+
});
34+
}
35+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<?xml version="1.0" encoding="UTF-8" ?>
2+
<container xmlns="http://symfony.com/schema/dic/services"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xmlns:framework="http://symfony.com/schema/dic/symfony"
5+
xmlns:overblog_graphiql="http://over-blog.com/schema/dic/overblog_graphiql"
6+
xsi:schemaLocation="http://symfony.com/schema/dic/services
7+
http://symfony.com/schema/dic/services/services-1.0.xsd
8+
http://symfony.com/schema/dic/symfony
9+
http://symfony.com/schema/dic/symfony/symfony-1.0.xsd
10+
http://over-blog.com/schema/dic/overblog_graphiql
11+
http://over-blog.com/schema/dic/overblog_graphiql/overblog_graphiql-0.1.xsd">
12+
13+
<framework:config
14+
secret="secret"
15+
test="true">
16+
<framework:router resource="%kernel.root_dir%/app/config/routing.xml" />
17+
<framework:profiler enabled="false" />
18+
<framework:templating>
19+
<framework:engine>twig</framework:engine>
20+
</framework:templating>
21+
</framework:config>
22+
23+
<overblog_graphiql:config/>
24+
</container>
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<?php
2+
3+
namespace Overblog\GraphiQLBundle\Tests\Functional\DependencyInjection\Fixtures\Yaml;
4+
5+
use Overblog\GraphiQLBundle\OverblogGraphiQLBundle;
6+
use Overblog\GraphiQLBundle\Tests\TestKernel as AbstractTestKernel;
7+
use Symfony\Bundle\FrameworkBundle\FrameworkBundle;
8+
use Symfony\Bundle\TwigBundle\TwigBundle;
9+
use Symfony\Component\Config\Loader\LoaderInterface;
10+
11+
final class TestKernel extends AbstractTestKernel
12+
{
13+
public function registerBundles()
14+
{
15+
return [
16+
new FrameworkBundle(),
17+
new TwigBundle(),
18+
new OverblogGraphiQLBundle(),
19+
];
20+
}
21+
22+
/**
23+
* {@inheritdoc}
24+
*/
25+
public function registerContainerConfiguration(LoaderInterface $loader)
26+
{
27+
$loader->load(__DIR__.'/config.yml');
28+
}
29+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
framework:
2+
test: ~
3+
secret: test
4+
router:
5+
resource: "%kernel.root_dir%/../Resources/config/routing.xml"
6+
templating:
7+
engines: ['twig']
8+
profiler:
9+
enabled: false
10+
assets:
11+
enabled: false
12+
13+
overblog_graphiql: ~
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<?php
2+
3+
namespace Overblog\GraphiQLBundle\Tests\Functional\DependencyInjection\Xml;
4+
5+
use Overblog\GraphiQLBundle\Tests\Functional\DependencyInjection\Fixtures\Xml\TestKernel;
6+
use Overblog\GraphiQLBundle\Tests\TestCase;
7+
8+
final class ConfigurationTest extends TestCase
9+
{
10+
protected static function getKernelClass()
11+
{
12+
return TestKernel::class;
13+
}
14+
15+
public function setUp()
16+
{
17+
static::bootKernel(['test_case' => str_replace('\\', '_', __NAMESPACE__)]);
18+
}
19+
20+
public function testSuccessConfiguration()
21+
{
22+
/** @var TestKernel $kernel */
23+
$kernel = static::$kernel;
24+
25+
$this->assertTrue($kernel->isBooted());
26+
}
27+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<?php
2+
3+
namespace Overblog\GraphiQLBundle\Tests\Functional\DependencyInjection\Yaml;
4+
5+
use Overblog\GraphiQLBundle\Tests\Functional\DependencyInjection\Fixtures\Yaml\TestKernel;
6+
use Overblog\GraphiQLBundle\Tests\TestCase;
7+
8+
final class ConfigurationTest extends TestCase
9+
{
10+
protected static function getKernelClass()
11+
{
12+
return TestKernel::class;
13+
}
14+
15+
public function setUp()
16+
{
17+
static::bootKernel(['test_case' => str_replace('\\', '_', __NAMESPACE__)]);
18+
}
19+
20+
public function testSuccessConfiguration()
21+
{
22+
/** @var TestKernel $kernel */
23+
$kernel = static::$kernel;
24+
25+
$this->assertTrue($kernel->isBooted());
26+
}
27+
}

Tests/Integration/OverblogGraphQLBundle/Fixtures/TestKernel.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
namespace Overblog\GraphiQLBundle\Tests\Integration\OverblogGraphQLBundle\Fixtures;
44

55
use Overblog\GraphiQLBundle\OverblogGraphiQLBundle;
6-
use Overblog\GraphQLBundle\OverblogGraphQLBundle;
76
use Overblog\GraphiQLBundle\Tests\TestKernel as AbstractTestKernel;
7+
use Overblog\GraphQLBundle\OverblogGraphQLBundle;
88
use Symfony\Bundle\FrameworkBundle\FrameworkBundle;
99
use Symfony\Bundle\TwigBundle\TwigBundle;
1010
use Symfony\Component\Config\Loader\LoaderInterface;
@@ -34,7 +34,7 @@ public function registerContainerConfiguration(LoaderInterface $loader)
3434
'templating' => ['engine' => ['twig']],
3535
'assets' => ['enabled' => false],
3636
'router' => [
37-
'resource' => __DIR__ . '/Resources/config/routing.xml',
37+
'resource' => __DIR__.'/Resources/config/routing.xml',
3838
],
3939
]);
4040
});

0 commit comments

Comments
 (0)