Commit 570bd5b9 authored by Julien Fastré's avatar Julien Fastré
Browse files

bootstrapping tests with kernel

parent 198907a2
vendor/*
composer.lock
/nbproject/private/
\ No newline at end of file
<?php
use Symfony\Component\HttpKernel\Kernel;
use Symfony\Component\Config\Loader\LoaderInterface;
class AppKernel extends Kernel
{
public function registerBundles()
{
return array(
new Symfony\Bundle\FrameworkBundle\FrameworkBundle(),
new Chill\CustomFieldsBundle\ChillCustomFieldsBundle(),
new Symfony\Bundle\SecurityBundle\SecurityBundle(),
new Symfony\Bundle\MonologBundle\MonologBundle(),
new Symfony\Bundle\TwigBundle\TwigBundle(),
new \Symfony\Bundle\AsseticBundle\AsseticBundle(),
new Doctrine\Bundle\DoctrineBundle\DoctrineBundle(),
new \Chill\MainBundle\ChillMainBundle,
new \Doctrine\Bundle\FixturesBundle\DoctrineFixturesBundle(),
new Doctrine\Bundle\MigrationsBundle\DoctrineMigrationsBundle(),
new Chill\ICPC2Bundle\ChillICPC2Bundle()
#add here all the required bundle (some bundle are not required)
);
}
public function registerContainerConfiguration(LoaderInterface $loader)
{
$loader->load(__DIR__.'/config/config_'.$this->getEnvironment().'.yml');
}
/**
* @return string
*/
public function getCacheDir()
{
return sys_get_temp_dir().'/icpc2/cache';
}
/**
* @return string
*/
public function getLogDir()
{
return sys_get_temp_dir().'/icpc2/logs';
}
}
<?php
use Doctrine\Common\Annotations\AnnotationRegistry;
use Composer\Autoload\ClassLoader;
/**
* @var ClassLoader $loader
*/
$loader = require __DIR__.'/../../../../vendor/autoload.php';
AnnotationRegistry::registerLoader(array($loader, 'loadClass'));
return $loader;
This diff is collapsed.
imports:
- { resource: parameters.yml }
framework:
secret: Not very secret
router: { resource: "%kernel.root_dir%/config/routing.yml" }
form: true
csrf_protection: true
session: ~
default_locale: fr
translator: { fallback: fr }
profiler: { only_exceptions: false }
templating:
engines: ['twig']
doctrine:
dbal:
driver: pdo_pgsql
host: "%database_host%"
port: "%database_port%"
dbname: "%database_name%"
user: "%database_user%"
password: "%database_password%"
charset: UTF8
orm:
auto_generate_proxy_classes: "%kernel.debug%"
auto_mapping: true
# Assetic Configuration
assetic:
debug: "%kernel.debug%"
use_controller: false
bundles: [ ]
#java: /usr/bin/java
filters:
cssrewrite: ~
chill_main:
available_languages: [ fr, nl, en ]
security:
providers:
chain_provider:
chain :
providers: [in_memory, users]
in_memory:
memory:
users:
admin: { password: olala, roles: 'ROLE_ADMIN' }
users:
entity:
class: Chill\MainBundle\Entity\User
property: username
encoders:
Chill\MainBundle\Entity\User:
algorithm: bcrypt
Symfony\Component\Security\Core\User\User: plaintext
firewalls:
dev:
pattern: ^/(_(profiler|wdt)|css|images|js)/
security: false
default:
anonymous: ~
form_login:
csrf_parameter: _csrf_token
csrf_token_id: authenticate
csrf_provider: form.csrf_provider
logout: ~
access_control:
#disable authentication for tests
#- { path: ^/login, roles: IS_AUTHENTICATED_ANONYMOUSLY }
#- { path: ^/admin, roles: ROLE_ADMIN }
#- { path: ^/, roles: ROLE_USER }
\ No newline at end of file
imports:
- { resource: config.yml } #here we import a config.yml file, this is not required
framework:
test: ~
session:
storage_id: session.storage.filesystem
chill_custom_fields:
customizables_entities:
- { class: TEST, name: test }
\ No newline at end of file
# config/config_test.yml
imports:
- { resource: config.yml } #here we import a config.yml file, this is not required
framework:
test: ~
session:
storage_id: session.storage.filesystem
\ No newline at end of file
parameters:
database_host: chill__database
database_port: 5432
database_name: postgres
database_user: postgres
database_password: postgres
locale: fr
parameters:
database_host: localhost
database_port: 5435
database_name: postgres
database_user: postgres
database_password: postgres
locale: fr
parameters:
database_host: 127.0.0.1
database_port: 5434
database_name: symfony
database_user: symfony
database_password: symfony
locale: fr
\ No newline at end of file
cl_custom_fields:
resource: .
type: chill_routes
chill_main:
resource: "@ChillMainBundle/Resources/config/routing.yml"
test_custom_field_form_render:
path: /customfieldsgroup/test/render/{id}
defaults: { _controller: ChillCustomFieldsBundle:CustomFieldsGroup:renderForm }
\ No newline at end of file
#!/usr/bin/env php
<?php
// if you don't want to setup permissions the proper way, just uncomment the following PHP line
// read http://symfony.com/doc/current/book/installation.html#configuration-and-setup for more information
//umask(0000);
set_time_limit(0);
require_once __DIR__.'/../../bootstrap.php';
require_once __DIR__.'/AppKernel.php';
use Symfony\Bundle\FrameworkBundle\Console\Application;
use Symfony\Component\Console\Input\ArgvInput;
use Symfony\Component\Debug\Debug;
$input = new ArgvInput();
$env = $input->getParameterOption(array('--env', '-e'), getenv('SYMFONY_ENV') ?: 'dev');
$debug = getenv('SYMFONY_DEBUG') !== '0' && !$input->hasParameterOption(array('--no-debug', '')) && $env !== 'prod';
if ($debug) {
Debug::enable();
}
$kernel = new AppKernel($env, $debug);
$application = new Application($kernel);
$application->run($input);
<?php
if (!is_file($autoloadFile = __DIR__.'/../../vendor/autoload.php')) {
throw new \LogicException('Could not find autoload.php in vendor/. Did you run "composer install --dev"?');
}
require $autoloadFile;
<?php
/*
* Chill is a software for social workers
* Copyright (C) 2015, Champs Libres Cooperative SCRLFS, <http://www.champs-libres.coop>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
namespace Chill\ICPC2Bundle\Tests\CustomField;
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
use Chill\CustomFieldsBundle\Entity\CustomField;
/**
*
*
* @author Julien Fastré <julien.fastre@champs-libres.coop>
*/
class CustomFieldICPC2CodeTest extends KernelTestCase
{
/**
*
* @var \Chill\CustomFieldsBundle\Service\CustomFieldProvider
*/
private $cfProvider;
/**
*
* @var \Chill\ICPC2Bundle\CustomField\CustomFieldICPC2Code
*/
private $cfICPC2;
public function setUp()
{
static::bootKernel();
$this->cfProvider = static::$kernel->getContainer()
->get('chill.custom_field.provider');
$this->cfICPC2 = $this->cfProvider->getCustomFieldByType('ICPC2');
}
/**
*
* @param array $options
* @return CustomField
*/
private function generateCustomField($options = array())
{
return (new CustomField())
->setActive(true)
->setSlug('slug')
->setOptions(array())
->setType('ICPC2')
;
}
/////////////////////////////////////////
//
// test function isEmptyValue
//
////////////////////////////////////////
public function testIsEmtpyWithEmptyValue()
{
$cf = $this->generateCustomField();
$data = array(
'slug' => null
);
$isEmpty = $this->cfICPC2->isEmptyValue($data, $cf);
$this->assertTrue($isEmpty);
}
}
......@@ -4,7 +4,7 @@
"type": "symfony-bundle",
"description": "ICPC2 for the Chill App",
"keywords" : ["chill", "social work", "icpc2"],
"homepage" : "https://github.com/Chill-project/ICPC2",
"homepage" : "https://git.framasoft.org/Chill-project/Chill-ICPC2",
"autoload": {
"psr-4": { "Chill\\ICPC2Bundle\\": "" }
},
......@@ -30,5 +30,23 @@
"chill-project/main": "dev-master@dev",
"chill-project/custom-fields": "dev-master@dev",
"doctrine/doctrine-migrations-bundle": "dev-master@dev"
},
"require-dev": {
"doctrine/doctrine-fixtures-bundle": "~2.2",
"fzaninotto/faker": "~1"
},
"scripts": {
"post-install-cmd": [
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::buildBootstrap",
"ComposerBundleMigration\\Composer\\Migrations::synchronizeMigrations"
],
"post-update-cmd": [
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::buildBootstrap",
"ComposerBundleMigration\\Composer\\Migrations::synchronizeMigrations"
]
},
"extra": {
"symfony-app-dir": "Resources/test/App/app",
"app-migrations-dir": "Resources/test/App/app/DoctrineMigrations"
}
}
<?xml version="1.0" encoding="UTF-8"?>
<phpunit bootstrap="./Resources/test/bootstrap.php" colors="true">
<testsuites>
<testsuite name="Chill ICPC2 test suite">
<directory suffix="Test.php">./Tests</directory>
</testsuite>
</testsuites>
<filter>
<whitelist>
<directory>./</directory>
<exclude>
<directory>./Resources</directory>
<directory>./Tests</directory>
<directory>./vendor</directory>
</exclude>
</whitelist>
</filter>
<php>
<server name="KERNEL_DIR" value="Resources/test/App/app/" />
<ini name="error_reporting" value="-16385"/>
</php>
</phpunit>
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment