forked from lexik/LexikTranslationBundle
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
313 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,3 +3,4 @@ composer.lock | |
Propel/map | ||
Propel/om | ||
|
||
Tests/app/tmp/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# Testing | ||
|
||
run test from console | ||
|
||
``` bash | ||
$ phpunit.phar | ||
``` | ||
|
||
or you can setup vars for doctrine pdo driver like this | ||
|
||
``` bash | ||
$ export DB_NAME=acme && export DB_USER=acme && export DB_PASSWD=acme && export DB=mysql && export DB_HOST=acme && phpunit.phar | ||
``` | ||
|
||
according to default credentials for travis CI you must run | ||
|
||
``` bash | ||
$ export DB_NAME=lexik_test && export DB_USER=root && unset DB_PASSWD && unset DB && unset DB_HOST && phpunit.phar | ||
``` | ||
|
||
Available variables are: | ||
- ORM - orm system, currently we support only doctrine2, we should also support propel and mongo | ||
- DB_NAME - database name (default: lexik_translation_test) | ||
- DB_USER - database user name (default: root) | ||
- DB_PASSWD - database user password (default: null) | ||
- DB_ENGINE - database engine (default: pdo_mysql) | ||
- DB_PORT - database port (default: null) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the Symfony package. | ||
* | ||
* (c) Fabien Potencier <[email protected]> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
use Symfony\Component\Config\Loader\LoaderInterface; | ||
use Symfony\Component\Filesystem\Filesystem; | ||
use Symfony\Component\HttpKernel\Kernel; | ||
|
||
/** | ||
* App Test Kernel for functional tests. | ||
* | ||
* @author Johannes M. Schmitt <[email protected]> | ||
*/ | ||
class AppKernel extends Kernel | ||
{ | ||
private $testCase; | ||
private $rootConfig; | ||
|
||
public function __construct($testCase, $debug = true) | ||
{ | ||
$environment = $testCase; | ||
|
||
if (!is_dir(__DIR__ . '/' . $testCase)) { | ||
throw new \InvalidArgumentException(sprintf('The test case "%s" does not exist.', $testCase)); | ||
} | ||
$this->testCase = $testCase; | ||
|
||
$rootConfig = __DIR__ . '/' . $testCase . '/config.yml'; | ||
|
||
$fs = new Filesystem(); | ||
if (!$fs->isAbsolutePath($rootConfig) | ||
&& !file_exists( | ||
$rootConfig = __DIR__ . '/' . $testCase . '/' . $rootConfig | ||
) | ||
) { | ||
throw new \InvalidArgumentException(sprintf('The root config "%s" does not exist.', $rootConfig)); | ||
} | ||
$this->rootConfig = $rootConfig; | ||
|
||
parent::__construct($environment, $debug); | ||
} | ||
|
||
public function registerBundles() | ||
{ | ||
if (!file_exists($filename = $this->getRootDir() . '/' . $this->testCase . '/bundles.php')) { | ||
throw new \RuntimeException(sprintf('The bundles file "%s" does not exist.', $filename)); | ||
} | ||
|
||
return include $filename; | ||
} | ||
|
||
public function getRootDir() | ||
{ | ||
return __DIR__; | ||
} | ||
|
||
public function getCacheDir() | ||
{ | ||
return $this->getRootDir() . '/tmp/' . $this->testCase . '/cache/' . $this->environment; | ||
} | ||
|
||
public function getLogDir() | ||
{ | ||
return $this->getRootDir() . '/tmp/' . $this->testCase . '/logs'; | ||
} | ||
|
||
public function registerContainerConfiguration(LoaderInterface $loader) | ||
{ | ||
$loader->load($this->rootConfig); | ||
} | ||
|
||
public function serialize() | ||
{ | ||
return serialize(array($this->testCase, $this->rootConfig, $this->getEnvironment(), $this->isDebug())); | ||
} | ||
|
||
public function unserialize($str) | ||
{ | ||
call_user_func_array(array($this, '__construct'), unserialize($str)); | ||
} | ||
|
||
protected function getKernelParameters() | ||
{ | ||
$parameters = parent::getKernelParameters(); | ||
$parameters['kernel.test_case'] = $this->testCase; | ||
|
||
return $parameters; | ||
} | ||
|
||
public function terminate( | ||
\Symfony\Component\HttpFoundation\Request $request, \Symfony\Component\HttpFoundation\Response $response) | ||
{ | ||
return parent::terminate($request, $response); // TODO: Change the autogenerated stub | ||
} | ||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<?php | ||
|
||
return array( | ||
new \Symfony\Bundle\FrameworkBundle\FrameworkBundle(), | ||
new \Doctrine\Bundle\DoctrineBundle\DoctrineBundle(), | ||
new \Lexik\Bundle\TranslationBundle\LexikTranslationBundle(), | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
imports: | ||
- { resource: database.php } | ||
|
||
framework: | ||
fragments: ~ | ||
secret: afasfsf | ||
|
||
lexik_translation: | ||
fallback_locale: en | ||
managed_locales: [en, pl, de, sv] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<?php | ||
|
||
if (ORM_TYPE == "doctrine") { | ||
$container->loadFromExtension( | ||
'doctrine', | ||
array( | ||
'orm' => array( | ||
'mappings' => array( | ||
'Mapping' => array( | ||
'type' => 'xml', | ||
'prefix' => 'Lexik\Bundle\TranslationBundle\Entity', | ||
'is_bundle' => false, | ||
'dir' => '%kernel.root_dir%/../../Resources/config/doctrine' | ||
) | ||
) | ||
), | ||
'dbal' => array( | ||
'charset' => 'UTF8', | ||
'driver' => DB_ENGINE, | ||
'host' => DB_HOST, | ||
'port' => DB_PORT, | ||
'dbname' => DB_NAME, | ||
'user' => DB_USER, | ||
'password' => DB_PASSWD | ||
) | ||
) | ||
); | ||
} else { | ||
throw new \Exception("Currently only doctrine is supported"); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,16 @@ | ||
<?php | ||
|
||
define("ORM_TYPE", getenv("ORM") ?: "doctrine"); | ||
|
||
define("DB_ENGINE", getenv("DB_ENGINE") ?: "pdo_mysql"); | ||
define("DB_HOST", getenv("DB_HOST") ?: "localhost"); | ||
define("DB_PORT", getenv("DB_PORT") ?: null); | ||
define('DB_NAME', getenv("DB_NAME") ?: "lexik_translation_test"); | ||
define("DB_USER", getenv("DB_USER") ?: "root"); | ||
define("DB_PASSWD", getenv("DB_PASSWD") ?: null); | ||
|
||
if (file_exists($file = __DIR__.'/autoload.php')) { | ||
require_once $file; | ||
} elseif (file_exists($file = __DIR__.'/autoload.php.dist')) { | ||
require_once $file; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.