Skip to content

Commit

Permalink
Merge pull request #38 from Happyr/tests
Browse files Browse the repository at this point in the history
Added functional tests to make sure the bundle compiles
  • Loading branch information
Nyholm committed Apr 23, 2016
2 parents 75105db + c3076d6 commit e4145af
Show file tree
Hide file tree
Showing 9 changed files with 123 additions and 4 deletions.
1 change: 0 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
language: php

php:
- 5.4
- 5.5
- 5.6
- 7.0
Expand Down
8 changes: 7 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@
"psr/log": "^1.0"
},
"require-dev": {
"php-http/guzzle6-adapter": "~1.0"
"php-http/guzzle6-adapter": "~1.0",
"php-http/httplug-bundle": "~1.0"
},
"suggest": {
"php-http/httplug-bundle": "To easier configure your httplug clients.",
Expand All @@ -31,6 +32,11 @@
"psr-4": {
"Happyr\\TranslationBundle\\": "src/"
}
},
"autoload-dev": {
"psr-4": {
"Happyr\\TranslationBundle\\tests\\": "tests/"
}
}
}

4 changes: 2 additions & 2 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<formatter type="clover" usefile="false"/>
<testsuites>
<testsuite name="Happyr Test Suite">
<directory>./Test</directory>
<directory>./tests</directory>
</testsuite>
</testsuites>

Expand All @@ -25,7 +25,7 @@
<directory suffix=".php">./</directory>
<exclude>
<directory>vendor</directory>
<directory>Test</directory>
<directory>tests</directory>
</exclude>
</whitelist>
</filter>
Expand Down
59 changes: 59 additions & 0 deletions tests/Functional/AppKernel.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
<?php

namespace Happyr\TranslationBundle\tests\Functional;

use Http\HttplugBundle\HttplugBundle;
use Symfony\Component\Config\Loader\LoaderInterface;
use Symfony\Component\Filesystem\Filesystem;
use Symfony\Component\HttpKernel\Kernel;

class AppKernel extends Kernel
{
private $config;

public function __construct($config)
{
parent::__construct('test', true);

$fs = new Filesystem();
if (!$fs->isAbsolutePath($config)) {
$config = __DIR__.'/config/'.$config;
}

if (!file_exists($config)) {
throw new \RuntimeException(sprintf('The config file "%s" does not exist.', $config));
}

$this->config = $config;
}

public function registerBundles()
{
return array(
new \Symfony\Bundle\FrameworkBundle\FrameworkBundle(),
new \Symfony\Bundle\SecurityBundle\SecurityBundle(),
new \Happyr\TranslationBundle\HappyrTranslationBundle(),
new \Http\HttplugBundle\HttplugBundle(),
);
}

public function registerContainerConfiguration(LoaderInterface $loader)
{
$loader->load($this->config);
}

public function getCacheDir()
{
return sys_get_temp_dir().'/HappyrTranslationBundle';
}

public function serialize()
{
return $this->config;
}

public function unserialize($config)
{
$this->__construct($config);
}
}
13 changes: 13 additions & 0 deletions tests/Functional/BaseTestCase.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php

namespace Happyr\TranslationBundle\tests\Functional;

use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;

class BaseTestCase extends WebTestCase
{
protected static function createKernel(array $options = array())
{
return new AppKernel(isset($options['config']) ? $options['config'] : 'default.yml');
}
}
21 changes: 21 additions & 0 deletions tests/Functional/BundleInitializationTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php

namespace Happyr\TranslationBundle\tests\Functional;

class BundleInitializationTest extends BaseTestCase
{

/**
* @test
*/
public function bundle_will_install_with_no_errors()
{
$client = static::createClient();
$container = $client->getContainer();
$container->get('happyr.translation.service.loco');
$container->get('happyr.translation.service.blackhole');
$container->get('happyr.translation.service.filesystem');
}


}
3 changes: 3 additions & 0 deletions tests/Functional/config/default.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
imports:
- { resource: framework.yml }

18 changes: 18 additions & 0 deletions tests/Functional/config/framework.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
framework:
secret: test
test: ~
session:
storage_id: session.storage.mock_file
form: false
csrf_protection: false
validation:
enabled: false
router:
resource: "%kernel.root_dir%/config/routing.yml"

httplug:
classes:
client: Http\Adapter\Guzzle6\Client
message_factory: Http\Message\MessageFactory\GuzzleMessageFactory
uri_factory: Http\Message\UriFactory\GuzzleUriFactory
stream_factory: Http\Message\StreamFactory\GuzzleStreamFactory
Empty file.

0 comments on commit e4145af

Please sign in to comment.