Skip to content

Commit 2029824

Browse files
committed
Added functional tests to make sure the bundle compiles
1 parent 75105db commit 2029824

File tree

8 files changed

+123
-3
lines changed

8 files changed

+123
-3
lines changed

composer.json

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@
2121
"psr/log": "^1.0"
2222
},
2323
"require-dev": {
24-
"php-http/guzzle6-adapter": "~1.0"
24+
"php-http/guzzle6-adapter": "~1.0",
25+
"php-http/httplug-bundle": "~1.0"
2526
},
2627
"suggest": {
2728
"php-http/httplug-bundle": "To easier configure your httplug clients.",
@@ -31,6 +32,11 @@
3132
"psr-4": {
3233
"Happyr\\TranslationBundle\\": "src/"
3334
}
35+
},
36+
"autoload-dev": {
37+
"psr-4": {
38+
"Happyr\\TranslationBundle\\tests\\": "tests/"
39+
}
3440
}
3541
}
3642

phpunit.xml.dist

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
<formatter type="clover" usefile="false"/>
1717
<testsuites>
1818
<testsuite name="Happyr Test Suite">
19-
<directory>./Test</directory>
19+
<directory>./tests</directory>
2020
</testsuite>
2121
</testsuites>
2222

@@ -25,7 +25,7 @@
2525
<directory suffix=".php">./</directory>
2626
<exclude>
2727
<directory>vendor</directory>
28-
<directory>Test</directory>
28+
<directory>tests</directory>
2929
</exclude>
3030
</whitelist>
3131
</filter>

tests/Functional/AppKernel.php

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
<?php
2+
3+
namespace Happyr\TranslationBundle\tests\Functional;
4+
5+
use Http\HttplugBundle\HttplugBundle;
6+
use Symfony\Component\Config\Loader\LoaderInterface;
7+
use Symfony\Component\Filesystem\Filesystem;
8+
use Symfony\Component\HttpKernel\Kernel;
9+
10+
class AppKernel extends Kernel
11+
{
12+
private $config;
13+
14+
public function __construct($config)
15+
{
16+
parent::__construct('test', true);
17+
18+
$fs = new Filesystem();
19+
if (!$fs->isAbsolutePath($config)) {
20+
$config = __DIR__.'/config/'.$config;
21+
}
22+
23+
if (!file_exists($config)) {
24+
throw new \RuntimeException(sprintf('The config file "%s" does not exist.', $config));
25+
}
26+
27+
$this->config = $config;
28+
}
29+
30+
public function registerBundles()
31+
{
32+
return array(
33+
new \Symfony\Bundle\FrameworkBundle\FrameworkBundle(),
34+
new \Symfony\Bundle\SecurityBundle\SecurityBundle(),
35+
new \Happyr\TranslationBundle\HappyrTranslationBundle(),
36+
new \Http\HttplugBundle\HttplugBundle(),
37+
);
38+
}
39+
40+
public function registerContainerConfiguration(LoaderInterface $loader)
41+
{
42+
$loader->load($this->config);
43+
}
44+
45+
public function getCacheDir()
46+
{
47+
return sys_get_temp_dir().'/HappyrTranslationBundle';
48+
}
49+
50+
public function serialize()
51+
{
52+
return $this->config;
53+
}
54+
55+
public function unserialize($config)
56+
{
57+
$this->__construct($config);
58+
}
59+
}

tests/Functional/BaseTestCase.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?php
2+
3+
namespace Happyr\TranslationBundle\tests\Functional;
4+
5+
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
6+
7+
class BaseTestCase extends WebTestCase
8+
{
9+
protected static function createKernel(array $options = array())
10+
{
11+
return new AppKernel(isset($options['config']) ? $options['config'] : 'default.yml');
12+
}
13+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<?php
2+
3+
namespace Happyr\TranslationBundle\tests\Functional;
4+
5+
class BundleInitializationTest extends BaseTestCase
6+
{
7+
8+
/**
9+
* @test
10+
*/
11+
public function bundle_will_install_with_no_errors()
12+
{
13+
$client = static::createClient();
14+
$container = $client->getContainer();
15+
$container->get('happyr.translation.service.loco');
16+
$container->get('happyr.translation.service.blackhole');
17+
$container->get('happyr.translation.service.filesystem');
18+
}
19+
20+
21+
}

tests/Functional/config/default.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
imports:
2+
- { resource: framework.yml }
3+

tests/Functional/config/framework.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
framework:
2+
secret: test
3+
test: ~
4+
session:
5+
storage_id: session.storage.mock_file
6+
form: false
7+
csrf_protection: false
8+
validation:
9+
enabled: false
10+
router:
11+
resource: "%kernel.root_dir%/config/routing.yml"
12+
13+
httplug:
14+
classes:
15+
client: Http\Adapter\Guzzle6\Client
16+
message_factory: Http\Message\MessageFactory\GuzzleMessageFactory
17+
uri_factory: Http\Message\UriFactory\GuzzleUriFactory
18+
stream_factory: Http\Message\StreamFactory\GuzzleStreamFactory

tests/Functional/config/routing.yml

Whitespace-only changes.

0 commit comments

Comments
 (0)