mirror of
https://github.com/Sylius/Sylius.git
synced 2026-07-14 09:02:12 +00:00
simple tests and travis-ci.org support.
This commit is contained in:
parent
370f78854c
commit
a5b50df32f
6 changed files with 176 additions and 0 deletions
10
src/Sylius/Bundle/AddressingBundle/.gitignore
vendored
Normal file
10
src/Sylius/Bundle/AddressingBundle/.gitignore
vendored
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
.buildpath
|
||||
.project
|
||||
.settings/
|
||||
phpunit.xml
|
||||
Tests/autoload.php
|
||||
nbproject
|
||||
vendor/
|
||||
composer.phar
|
||||
composer.lock
|
||||
|
||||
14
src/Sylius/Bundle/AddressingBundle/.travis.yml
Normal file
14
src/Sylius/Bundle/AddressingBundle/.travis.yml
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
language: php
|
||||
|
||||
php:
|
||||
- 5.3
|
||||
- 5.4
|
||||
|
||||
before_script:
|
||||
- wget http://getcomposer.org/composer.phar
|
||||
- php composer.phar install
|
||||
|
||||
notifications:
|
||||
email:
|
||||
- travis-ci@sylius.org
|
||||
|
||||
|
|
@ -0,0 +1,81 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Sylius package.
|
||||
*
|
||||
* (c) Paweł Jędrzejewski
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Sylius\Bundle\AddressingBundle\Tests\DependencyInjection;
|
||||
|
||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||
use Sylius\Bundle\AddressingBundle\DependencyInjection\SyliusAddressingExtension;
|
||||
use Symfony\Component\Yaml\Parser;
|
||||
|
||||
class SyliusAddressingExtensionTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
/**
|
||||
* @expectedException \Symfony\Component\Config\Definition\Exception\InvalidConfigurationException
|
||||
*/
|
||||
public function testUserLoadThrowsExceptionUnlessDriverSet()
|
||||
{
|
||||
$loader = new SyliusAddressingExtension();
|
||||
$config = $this->getEmptyConfig();
|
||||
unset($config['driver']);
|
||||
$loader->load(array($config), new ContainerBuilder());
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \InvalidArgumentException
|
||||
*/
|
||||
public function testUserLoadThrowsExceptionUnlessDriverIsValid()
|
||||
{
|
||||
$loader = new SyliusAddressingExtension();
|
||||
$config = $this->getEmptyConfig();
|
||||
$config['driver'] = 'foo';
|
||||
$loader->load(array($config), new ContainerBuilder());
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \InvalidArgumentException
|
||||
*/
|
||||
public function testUserLoadThrowsExceptionUnlessEngineIsValid()
|
||||
{
|
||||
$loader = new SyliusAddressingExtension();
|
||||
$config = $this->getEmptyConfig();
|
||||
$config['engine'] = 'foo';
|
||||
$loader->load(array($config), new ContainerBuilder());
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Symfony\Component\Config\Definition\Exception\InvalidConfigurationException
|
||||
*/
|
||||
public function testUserLoadThrowsExceptionUnlessaddressModelClassSet()
|
||||
{
|
||||
$loader = new SyliusAddressingExtension();
|
||||
$config = $this->getEmptyConfig();
|
||||
unset($config['classes']['model']['address']);
|
||||
$loader->load(array($config), new ContainerBuilder());
|
||||
}
|
||||
|
||||
/**
|
||||
* getEmptyConfig
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function getEmptyConfig()
|
||||
{
|
||||
$yaml = <<<EOF
|
||||
driver: ORM
|
||||
classes:
|
||||
model:
|
||||
address: Sylius\Bundle\AddressingBundle\Entity\DefaultAddress
|
||||
EOF;
|
||||
$parser = new Parser();
|
||||
|
||||
return $parser->parse($yaml);
|
||||
}
|
||||
}
|
||||
35
src/Sylius/Bundle/AddressingBundle/Tests/autoload.php.dist
Normal file
35
src/Sylius/Bundle/AddressingBundle/Tests/autoload.php.dist
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* Autoloader for tests.
|
||||
*/
|
||||
|
||||
if (!file_exists($file = __DIR__.'/../vendor/.composer/autoload.php')) {
|
||||
|
||||
$vendorDir = __DIR__.'/../vendor';
|
||||
require_once $vendorDir.'/symfony/src/Symfony/Component/ClassLoader/UniversalClassLoader.php';
|
||||
|
||||
$loader = new \Symfony\Component\ClassLoader\UniversalClassLoader();
|
||||
$loader->registerNamespaces(array(
|
||||
'Symfony' => array($vendorDir.'/symfony/src', $vendorDir.'/bundles'),
|
||||
'Doctrine\\Common' => $vendorDir.'/doctrine-common/lib',
|
||||
'Doctrine\\DBAL' => $vendorDir.'/doctrine-dbal/lib',
|
||||
'Doctrine' => $vendorDir.'/doctrine/lib',
|
||||
));
|
||||
|
||||
$loader->register();
|
||||
|
||||
} else {
|
||||
require_once $file;
|
||||
}
|
||||
|
||||
spl_autoload_register(function($class) {
|
||||
if (0 === strpos($class, 'Sylius\\Bundle\\AddressingBundle\\')) {
|
||||
$path = __DIR__.'/../'.implode('/', array_slice(explode('\\', $class), 3)).'.php';
|
||||
if (!stream_resolve_include_path($path)) {
|
||||
return false;
|
||||
}
|
||||
require_once $path;
|
||||
return true;
|
||||
}
|
||||
});
|
||||
16
src/Sylius/Bundle/AddressingBundle/Tests/bootstrap.php
Normal file
16
src/Sylius/Bundle/AddressingBundle/Tests/bootstrap.php
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Sylius package.
|
||||
*
|
||||
* (c) Paweł Jędrzejewski
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
if (file_exists($file = __DIR__.'/autoload.php')) {
|
||||
require_once $file;
|
||||
} elseif (file_exists($file = __DIR__.'/autoload.php.dist')) {
|
||||
require_once $file;
|
||||
}
|
||||
20
src/Sylius/Bundle/AddressingBundle/phpunit.xml.dist
Normal file
20
src/Sylius/Bundle/AddressingBundle/phpunit.xml.dist
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<phpunit bootstrap="./Tests/bootstrap.php" color="true">
|
||||
|
||||
<testsuites>
|
||||
<testsuite name="SyliusAddressingBundle test suite">
|
||||
<directory suffix="Test.php">./Tests</directory>
|
||||
</testsuite>
|
||||
</testsuites>
|
||||
|
||||
<filter>
|
||||
<whitelist>
|
||||
<directory>./</directory>
|
||||
<exclude>
|
||||
<directory>./Resources</directory>
|
||||
<directory>./Tests</directory>
|
||||
</exclude>
|
||||
</whitelist>
|
||||
</filter>
|
||||
</phpunit>
|
||||
Loading…
Add table
Reference in a new issue