Skip to content

Commit

Permalink
Add kernel for functional tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ch3ric committed Feb 12, 2018
1 parent d97d9d0 commit cec9393
Show file tree
Hide file tree
Showing 6 changed files with 2,138 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Expand Up @@ -18,4 +18,4 @@ env:

before_script:
- composer require symfony/symfony:${SYMFONY_VERSION} --no-update
- composer install --dev
- composer install
31 changes: 31 additions & 0 deletions Test/AppKernel.php
@@ -0,0 +1,31 @@
<?php

namespace ETS\Payment\DotpayBundle\Test;

use Symfony\Component\HttpKernel\Kernel;
use Symfony\Component\Config\Loader\LoaderInterface;

class AppKernel extends Kernel
{
/**
* @inheritDoc
*/
public function registerBundles()
{
return array(
new \Symfony\Bundle\FrameworkBundle\FrameworkBundle(),
new \Symfony\Bundle\TwigBundle\TwigBundle(),
new \Doctrine\Bundle\DoctrineBundle\DoctrineBundle(),
new \Sensio\Bundle\FrameworkExtraBundle\SensioFrameworkExtraBundle(),
new \Symfony\Bundle\MonologBundle\MonologBundle(),

new \JMS\Payment\CoreBundle\JMSPaymentCoreBundle(),
new \ETS\Payment\DotpayBundle\ETSPaymentDotpayBundle(),
);
}

public function registerContainerConfiguration(LoaderInterface $loader)
{
$loader->load(__DIR__.'/config.yml');
}
}
34 changes: 34 additions & 0 deletions Test/ContainerAwareWebTestCase.php
Expand Up @@ -4,6 +4,11 @@

use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;

use Doctrine\ORM\Tools\Setup;
use Doctrine\ORM\EntityManager;
use Doctrine\Common\Persistence\PersistentObject;
use Doctrine\ORM\Tools\SchemaTool;

/*
* Copyright 2012 ETSGlobal <ecs@etsglobal.org>
*
Expand Down Expand Up @@ -32,6 +37,9 @@ class ContainerAwareWebTestCase extends WebTestCase
*/
protected static $client;

protected $em;
protected $tool;

/**
* @return null
*/
Expand All @@ -40,6 +48,8 @@ public function setUp()
self::$client = self::createClient();

parent::setUp();

$this->setUpDoctrine();
}

/**
Expand Down Expand Up @@ -71,4 +81,28 @@ public function getContainer()
{
return static::$kernel->getContainer();
}

/**
* @inheritDoc
*/
protected static function getKernelClass()
{
require_once __DIR__.'/AppKernel.php';

return 'ETS\Payment\DotpayBundle\Test\AppKernel';
}

protected function setUpDoctrine()
{
$this->em = $this->get('doctrine.orm.default_entity_manager');
PersistentObject::setObjectManager($this->em);

$this->tool = new SchemaTool($this->em);
$this->tool->updateSchema($this->em->getMetadataFactory()->getAllMetadata(), true);
}

protected function dropDoctrine()
{
$this->tool->dropSchema($this->em->getMetadataFactory()->getAllMetadata());
}
}
25 changes: 25 additions & 0 deletions Test/config.yml
@@ -0,0 +1,25 @@
framework:
secret: test
test: ~
form: true
templating:
engines: ['twig']
router:
resource: "%kernel.root_dir%/../Resources/config/routing.yml"
session:
storage_id: "session.storage.mock_file"

doctrine:
dbal:
driver: pdo_sqlite
path: "%kernel.cache_dir%/data.sqlite"
orm:
entity_managers:
default:
auto_mapping: true

ets_payment_dotpay:
direct:
id: testid
pin: testpin
type: 3
8 changes: 7 additions & 1 deletion composer.json
Expand Up @@ -17,12 +17,18 @@
],
"require": {
"php": ">=5.4",
"symfony/symfony": "~2.2",
"symfony/framework-bundle": "~2.2",
"jms/payment-core-bundle": "~1.0"
},
"require-dev": {
"symfony/browser-kit": "~2.2",
"symfony/finder": "~2.2"
"symfony/finder": "~2.2",
"symfony/twig-bundle": "~2.2",
"sensio/framework-extra-bundle": "~2.2",
"symfony/monolog-bundle": "~2.2",
"doctrine/doctrine-bundle": "*",
"doctrine/orm": "*"
},
"autoload": {
"psr-4": { "ETS\\Payment\\DotpayBundle\\": "" }
Expand Down

0 comments on commit cec9393

Please sign in to comment.