From a5b50df32ffeecd405b455dd296548ad1a778f97 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20J=C4=99drzejewski?= Date: Tue, 27 Dec 2011 20:29:48 +0100 Subject: [PATCH] simple tests and travis-ci.org support. --- src/Sylius/Bundle/AddressingBundle/.gitignore | 10 +++ .../Bundle/AddressingBundle/.travis.yml | 14 ++++ .../SyliusAddressingExtensionTest.php | 81 +++++++++++++++++++ .../AddressingBundle/Tests/autoload.php.dist | 35 ++++++++ .../AddressingBundle/Tests/bootstrap.php | 16 ++++ .../Bundle/AddressingBundle/phpunit.xml.dist | 20 +++++ 6 files changed, 176 insertions(+) create mode 100644 src/Sylius/Bundle/AddressingBundle/.gitignore create mode 100644 src/Sylius/Bundle/AddressingBundle/.travis.yml create mode 100644 src/Sylius/Bundle/AddressingBundle/Tests/DependencyInjection/SyliusAddressingExtensionTest.php create mode 100644 src/Sylius/Bundle/AddressingBundle/Tests/autoload.php.dist create mode 100644 src/Sylius/Bundle/AddressingBundle/Tests/bootstrap.php create mode 100644 src/Sylius/Bundle/AddressingBundle/phpunit.xml.dist diff --git a/src/Sylius/Bundle/AddressingBundle/.gitignore b/src/Sylius/Bundle/AddressingBundle/.gitignore new file mode 100644 index 0000000000..0f5da0ae24 --- /dev/null +++ b/src/Sylius/Bundle/AddressingBundle/.gitignore @@ -0,0 +1,10 @@ +.buildpath +.project +.settings/ +phpunit.xml +Tests/autoload.php +nbproject +vendor/ +composer.phar +composer.lock + diff --git a/src/Sylius/Bundle/AddressingBundle/.travis.yml b/src/Sylius/Bundle/AddressingBundle/.travis.yml new file mode 100644 index 0000000000..b7bc1108d7 --- /dev/null +++ b/src/Sylius/Bundle/AddressingBundle/.travis.yml @@ -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 + diff --git a/src/Sylius/Bundle/AddressingBundle/Tests/DependencyInjection/SyliusAddressingExtensionTest.php b/src/Sylius/Bundle/AddressingBundle/Tests/DependencyInjection/SyliusAddressingExtensionTest.php new file mode 100644 index 0000000000..6ca075704c --- /dev/null +++ b/src/Sylius/Bundle/AddressingBundle/Tests/DependencyInjection/SyliusAddressingExtensionTest.php @@ -0,0 +1,81 @@ +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 = <<parse($yaml); + } +} \ No newline at end of file diff --git a/src/Sylius/Bundle/AddressingBundle/Tests/autoload.php.dist b/src/Sylius/Bundle/AddressingBundle/Tests/autoload.php.dist new file mode 100644 index 0000000000..f804c3dd45 --- /dev/null +++ b/src/Sylius/Bundle/AddressingBundle/Tests/autoload.php.dist @@ -0,0 +1,35 @@ +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; + } +}); diff --git a/src/Sylius/Bundle/AddressingBundle/Tests/bootstrap.php b/src/Sylius/Bundle/AddressingBundle/Tests/bootstrap.php new file mode 100644 index 0000000000..bdd92d0475 --- /dev/null +++ b/src/Sylius/Bundle/AddressingBundle/Tests/bootstrap.php @@ -0,0 +1,16 @@ + + + + + + + ./Tests + + + + + + ./ + + ./Resources + ./Tests + + + +