From e74180781babbd66e35ceaf68e258e58cc8ed931 Mon Sep 17 00:00:00 2001 From: Matt Farina Date: Tue, 25 Mar 2014 15:20:34 -0400 Subject: [PATCH] Fixing a bug where PHPUnit is not included in the require-dev to run the test suite. PHPUnit 4 added and the test suite passes. Change-Id: I57f9860127d0a0ac037e31776e5d8a6f233a350e Closes-Bug: 1295358 --- .gitignore | 2 + composer.json | 3 + test/README.md | 87 ++++++++--------------------- test/TestCase.php | 4 -- test/Tests/ACLTest.php | 1 - test/Tests/CURLTransportTest.php | 1 - test/Tests/ContainerTest.php | 1 - test/Tests/IdentityServicesTest.php | 1 - test/Tests/ObjectStorageTest.php | 1 - test/Tests/ObjectTest.php | 1 - test/Tests/RemoteObjectTest.php | 1 - test/Tests/StreamWrapperFSTest.php | 1 - test/Tests/StreamWrapperTest.php | 1 - 13 files changed, 29 insertions(+), 76 deletions(-) diff --git a/.gitignore b/.gitignore index f8c2648..10626aa 100644 --- a/.gitignore +++ b/.gitignore @@ -1,8 +1,10 @@ bin/build/* dist/* +build/ mageekguy.atoum.phar test/settings.ini* .DS_Store doc/api curl-output.txt vendor +composer.lock diff --git a/composer.json b/composer.json index 66f502e..432cd83 100644 --- a/composer.json +++ b/composer.json @@ -7,6 +7,9 @@ "require": { "php": ">=5.3.0" }, + "require-dev": { + "phpunit/phpunit": "4.*" + }, "suggest": { "curl": ">=7.0.0" }, diff --git a/test/README.md b/test/README.md index 2ab9c06..edbc01b 100644 --- a/test/README.md +++ b/test/README.md @@ -61,65 +61,36 @@ Cloud credentials, along with your preferred testing parameters. The easiest way to do this is to copy the example settings file, and then make the necessary changes: -``` -$ cd test/ -$ cp example.settings.ini settings.ini -$ edit settings.ini -``` + $ cd test/ + $ cp example.settings.ini settings.ini + $ edit settings.ini -### Running Tests with Make +### Running Tests -The `Makefile` included with the PHP-Client library can run the tests. -Beginning from the root directory of the project, simply type the -following: +The test suite uses PHPUnit and can generate a code coverage report if +xdebug is installed. To run the test suite make sure PHPUnit is installed +via composer by using `composer install` or `composer update`. Once PHPUnit is +installed execute the following command from the root of the project. -``` -$ make test -``` - -By default, this will run ALL of the unit tests. However, you can run -a subset of the tests using the TESTS argument: - -``` -$ make test TESTS="test/Tests/BootstrapTest.php test/Tests/ACLTest.php" -``` - -If you know which *group* of tests you want to run, you can run just -a select group of tests using the `test-group` target: - -``` -$ make test-group GROUP=deprecated -``` - -The above will run all of the unit tests in the `@group deprecated` group. -(Note: the library does not use group tests very often, so this is -unlikely to be a commonly required feature.) - -### Running Tests Using `phpunit` - -If for some reason the Makefile doesn't suite your needs, you have the -option of running the tests directly using `phpunit`. - -Beginning from the root directory of the project (you should see `src/` -and `test/` in that directory), run this command to execute all of the -tests: - -``` -$ phpunit test/Tests -``` + $ ./vendor/bin/phpunit This should generate output looking something like this: -``` -phpunit test/Tests -PHPUnit 3.7.24 by Sebastian Bergmann. + PHPUnit 4.0.13 by Sebastian Bergmann. -.................................................. - -Time: 01:24, Memory: 6.50Mb - -OK (50 tests, 125 assertions) -``` + Configuration read from /path/to/openstack-sdk-php/phpunit.xml.dist + + ............................................................... 63 / 146 ( 43%) + ............................................................... 126 / 146 ( 86%) + .................... + + Time: 4.94 minutes, Memory: 17.50Mb + + OK (146 tests, 413 assertions) + + Generating code coverage report in Clover XML format ... done + + Generating code coverage report in HTML format ... done If the tests fail, detailed information about the failure will be displayed. @@ -131,14 +102,4 @@ reports and analyses can be done using those. Tests should be written according to the PHPUnit documentation. Tests should follow the same coding standards as all other parts of the -library, with one caveat: The namespaces for tests are still -non-standard. - -The different namespacing is an historical relic resulting from two things: - -* Originally, we used Atoum, which ascribes additional semantic (testing) value to - namespaces. -* PHPUnit's namespacing support is relatively new. - -Eventually, the namespaces for the unit tests will all be standardized, -too. +library. diff --git a/test/TestCase.php b/test/TestCase.php index 12f8346..707a7e5 100644 --- a/test/TestCase.php +++ b/test/TestCase.php @@ -29,10 +29,6 @@ namespace OpenStack\Tests; -require_once 'PHPUnit/Autoload.php'; -require_once 'src/OpenStack/Autoloader.php'; -require_once 'src/OpenStack/Bootstrap.php'; - /** * @ingroup Tests */ diff --git a/test/Tests/ACLTest.php b/test/Tests/ACLTest.php index b1a18e4..c5e0ef3 100644 --- a/test/Tests/ACLTest.php +++ b/test/Tests/ACLTest.php @@ -21,7 +21,6 @@ */ namespace OpenStack\Tests\Storage\ObjectStorage; -require_once 'src/OpenStack/Bootstrap.php'; require_once 'test/TestCase.php'; use \OpenStack\Storage\ObjectStorage\ACL; diff --git a/test/Tests/CURLTransportTest.php b/test/Tests/CURLTransportTest.php index 2cd049c..f33cebd 100644 --- a/test/Tests/CURLTransportTest.php +++ b/test/Tests/CURLTransportTest.php @@ -21,7 +21,6 @@ */ namespace OpenStack\Tests\Transport; -require_once 'src/OpenStack/Bootstrap.php'; require_once 'test/TestCase.php'; use \OpenStack\Transport; diff --git a/test/Tests/ContainerTest.php b/test/Tests/ContainerTest.php index c6ccec6..a97a3ea 100644 --- a/test/Tests/ContainerTest.php +++ b/test/Tests/ContainerTest.php @@ -21,7 +21,6 @@ */ namespace OpenStack\Tests\Storage\ObjectStorage; -require_once 'src/OpenStack/Bootstrap.php'; require_once 'test/TestCase.php'; use \OpenStack\Storage\ObjectStorage\Container; diff --git a/test/Tests/IdentityServicesTest.php b/test/Tests/IdentityServicesTest.php index a6a7558..7a1100f 100644 --- a/test/Tests/IdentityServicesTest.php +++ b/test/Tests/IdentityServicesTest.php @@ -21,7 +21,6 @@ */ namespace OpenStack\Tests\Services; -require_once 'src/OpenStack/Bootstrap.php'; require_once 'test/TestCase.php'; use \OpenStack\Services\IdentityService; diff --git a/test/Tests/ObjectStorageTest.php b/test/Tests/ObjectStorageTest.php index 1f2a9fe..e280942 100644 --- a/test/Tests/ObjectStorageTest.php +++ b/test/Tests/ObjectStorageTest.php @@ -21,7 +21,6 @@ */ namespace OpenStack\Tests\Storage; -require_once 'src/OpenStack/Bootstrap.php'; require_once 'test/TestCase.php'; use \OpenStack\Storage\ObjectStorage\Object; diff --git a/test/Tests/ObjectTest.php b/test/Tests/ObjectTest.php index 0e2e2d9..edd5e9a 100644 --- a/test/Tests/ObjectTest.php +++ b/test/Tests/ObjectTest.php @@ -21,7 +21,6 @@ */ namespace OpenStack\Tests\Storage; -require_once 'src/OpenStack/Bootstrap.php'; require_once 'test/TestCase.php'; use \OpenStack\Storage\ObjectStorage\Object; diff --git a/test/Tests/RemoteObjectTest.php b/test/Tests/RemoteObjectTest.php index 419bd1d..5b76ccd 100644 --- a/test/Tests/RemoteObjectTest.php +++ b/test/Tests/RemoteObjectTest.php @@ -21,7 +21,6 @@ */ namespace OpenStack\Tests\Storage\ObjectStorage; -require_once 'src/OpenStack/Bootstrap.php'; require_once 'test/TestCase.php'; use \OpenStack\Storage\ObjectStorage\RemoteObject; diff --git a/test/Tests/StreamWrapperFSTest.php b/test/Tests/StreamWrapperFSTest.php index 0650767..2d0087e 100644 --- a/test/Tests/StreamWrapperFSTest.php +++ b/test/Tests/StreamWrapperFSTest.php @@ -21,7 +21,6 @@ */ namespace OpenStack\Tests\Storage\ObjectStorage; -require_once 'src/OpenStack/Bootstrap.php'; require_once 'test/TestCase.php'; use \OpenStack\Storage\ObjectStorage\StreamWrapperFS; diff --git a/test/Tests/StreamWrapperTest.php b/test/Tests/StreamWrapperTest.php index 24e53bc..fa47868 100644 --- a/test/Tests/StreamWrapperTest.php +++ b/test/Tests/StreamWrapperTest.php @@ -21,7 +21,6 @@ */ namespace OpenStack\Tests\Storage\ObjectStorage; -require_once 'src/OpenStack/Bootstrap.php'; require_once 'test/TestCase.php'; use \OpenStack\Storage\ObjectStorage\StreamWrapper;