From 4d406aa3e69b067c56076fd46475a360f7834bb9 Mon Sep 17 00:00:00 2001 From: Chris Saylor Date: Sat, 15 Mar 2014 19:29:23 -0400 Subject: [PATCH 1/7] Added psr-4 autoload configuration and flattened directories. --- composer.json | 2 +- src/{Zumba/PHPUnit/Extensions/Mongo => }/Base/Connector.php | 0 src/{Zumba/PHPUnit/Extensions/Mongo => }/Client/Connector.php | 0 src/{Zumba/PHPUnit/Extensions/Mongo => }/DataSet/DataSet.php | 0 src/{Zumba/PHPUnit/Extensions/Mongo => }/TestCase.php | 0 src/{Zumba/PHPUnit/Extensions/Mongo => }/TestTrait.php | 0 .../PHPUnit/Extensions/Mongo/Client => }/ConnectorTest.php | 0 7 files changed, 1 insertion(+), 1 deletion(-) rename src/{Zumba/PHPUnit/Extensions/Mongo => }/Base/Connector.php (100%) rename src/{Zumba/PHPUnit/Extensions/Mongo => }/Client/Connector.php (100%) rename src/{Zumba/PHPUnit/Extensions/Mongo => }/DataSet/DataSet.php (100%) rename src/{Zumba/PHPUnit/Extensions/Mongo => }/TestCase.php (100%) rename src/{Zumba/PHPUnit/Extensions/Mongo => }/TestTrait.php (100%) rename tests/{Zumba/PHPUnit/Extensions/Mongo/Client => }/ConnectorTest.php (100%) diff --git a/composer.json b/composer.json index 9db7413..ead5cad 100644 --- a/composer.json +++ b/composer.json @@ -31,7 +31,7 @@ "bin-dir": "bin" }, "autoload": { - "psr-0": { + "psr-4": { "Zumba\\PHPUnit\\Extensions\\Mongo\\": "src/" } } diff --git a/src/Zumba/PHPUnit/Extensions/Mongo/Base/Connector.php b/src/Base/Connector.php similarity index 100% rename from src/Zumba/PHPUnit/Extensions/Mongo/Base/Connector.php rename to src/Base/Connector.php diff --git a/src/Zumba/PHPUnit/Extensions/Mongo/Client/Connector.php b/src/Client/Connector.php similarity index 100% rename from src/Zumba/PHPUnit/Extensions/Mongo/Client/Connector.php rename to src/Client/Connector.php diff --git a/src/Zumba/PHPUnit/Extensions/Mongo/DataSet/DataSet.php b/src/DataSet/DataSet.php similarity index 100% rename from src/Zumba/PHPUnit/Extensions/Mongo/DataSet/DataSet.php rename to src/DataSet/DataSet.php diff --git a/src/Zumba/PHPUnit/Extensions/Mongo/TestCase.php b/src/TestCase.php similarity index 100% rename from src/Zumba/PHPUnit/Extensions/Mongo/TestCase.php rename to src/TestCase.php diff --git a/src/Zumba/PHPUnit/Extensions/Mongo/TestTrait.php b/src/TestTrait.php similarity index 100% rename from src/Zumba/PHPUnit/Extensions/Mongo/TestTrait.php rename to src/TestTrait.php diff --git a/tests/Zumba/PHPUnit/Extensions/Mongo/Client/ConnectorTest.php b/tests/ConnectorTest.php similarity index 100% rename from tests/Zumba/PHPUnit/Extensions/Mongo/Client/ConnectorTest.php rename to tests/ConnectorTest.php From 677d695dde7e62bc2c66caaafe848b2e40eff882 Mon Sep 17 00:00:00 2001 From: Chris Saylor Date: Sat, 15 Mar 2014 19:30:01 -0400 Subject: [PATCH 2/7] Added example test case using trait. Modified travis config to not run that test if not 5.4. --- .travis.yml | 7 +++++- examples/PizzaTraitTest.php | 44 +++++++++++++++++++++++++++++++++++++ 2 files changed, 50 insertions(+), 1 deletion(-) create mode 100644 examples/PizzaTraitTest.php diff --git a/.travis.yml b/.travis.yml index 250a14c..ffa5b79 100644 --- a/.travis.yml +++ b/.travis.yml @@ -11,7 +11,12 @@ before_script: - composer install --dev -script: ./bin/phpunit --coverage-text +script: + if [ $php = 5.3 ]; then + ./bin/phpunit --coverage-text --exclude-group 5.4 + else + ./bin/phpunit --coverage-text + fi notifications: email: false diff --git a/examples/PizzaTraitTest.php b/examples/PizzaTraitTest.php new file mode 100644 index 0000000..5709c8b --- /dev/null +++ b/examples/PizzaTraitTest.php @@ -0,0 +1,44 @@ + [ + ['size' => 'large', 'toppings' => ['cheese', 'ham']], + ['size' => 'medium', 'toppings' => ['cheese']] + ] + ]; + + public function getMongoConnection() { + if (empty($this->connection)) { + $this->connection = new \Zumba\PHPUnit\Extensions\Mongo\Client\Connector(new \MongoClient()); + $this->connection->setDb(static::DEFAULT_DATABASE); + } + return $this->connection; + } + + public function getMongoDataSet() { + if (empty($this->dataSet)) { + $this->dataSet = new \Zumba\PHPUnit\Extensions\Mongo\DataSet\DataSet($this->getMongoConnection()); + $this->dataSet->setFixture($this->fixture); + } + return $this->dataSet; + } + + public function testSizesFromFixture() { + $this->assertCount(2, $this->getMongoConnection()->collection('orders')->find()); + $this->assertCount(1, $this->getMongoConnection()->collection('orders')->find(array( + 'size' => 'medium' + ))); + } +} From c789c5252c7148c48cf06ec08e7c5d220700db4a Mon Sep 17 00:00:00 2001 From: Chris Saylor Date: Sat, 15 Mar 2014 19:31:08 -0400 Subject: [PATCH 3/7] Remove tab characters from travis yml. --- .travis.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.travis.yml b/.travis.yml index ffa5b79..6746777 100644 --- a/.travis.yml +++ b/.travis.yml @@ -12,11 +12,11 @@ before_script: script: - if [ $php = 5.3 ]; then - ./bin/phpunit --coverage-text --exclude-group 5.4 - else - ./bin/phpunit --coverage-text - fi + if [ $php = 5.3 ]; then + ./bin/phpunit --coverage-text --exclude-group 5.4 + else + ./bin/phpunit --coverage-text + fi notifications: email: false From f80118f664fe5f3f2a2dbf5a64375d2567899e1d Mon Sep 17 00:00:00 2001 From: Chris Saylor Date: Sat, 15 Mar 2014 19:35:40 -0400 Subject: [PATCH 4/7] Fixed bash command. --- .travis.yml | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/.travis.yml b/.travis.yml index 6746777..4a75e57 100644 --- a/.travis.yml +++ b/.travis.yml @@ -11,12 +11,7 @@ before_script: - composer install --dev -script: - if [ $php = 5.3 ]; then - ./bin/phpunit --coverage-text --exclude-group 5.4 - else - ./bin/phpunit --coverage-text - fi +script: if [ $php = 5.3 ]; then ./bin/phpunit --coverage-text --exclude-group 5.4; else ./bin/phpunit --coverage-text; fi notifications: email: false From df8bb5f45a506b752edac0d20630b7e9568eadbd Mon Sep 17 00:00:00 2001 From: Chris Saylor Date: Sat, 15 Mar 2014 19:46:44 -0400 Subject: [PATCH 5/7] Check travis php version. --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 4a75e57..c9c5fa7 100644 --- a/.travis.yml +++ b/.travis.yml @@ -11,7 +11,7 @@ before_script: - composer install --dev -script: if [ $php = 5.3 ]; then ./bin/phpunit --coverage-text --exclude-group 5.4; else ./bin/phpunit --coverage-text; fi +script: if [ $TRAVIS_PHP_VERSION = 5.3 ]; then ./bin/phpunit --coverage-text --exclude-group 5.4; else ./bin/phpunit --coverage-text; fi notifications: email: false From 897a08a290113c384a42992f3c40dd3e7f9284e8 Mon Sep 17 00:00:00 2001 From: Chris Saylor Date: Sat, 15 Mar 2014 19:53:18 -0400 Subject: [PATCH 6/7] Trying a different variable check. --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index c9c5fa7..5d446c4 100644 --- a/.travis.yml +++ b/.travis.yml @@ -11,7 +11,7 @@ before_script: - composer install --dev -script: if [ $TRAVIS_PHP_VERSION = 5.3 ]; then ./bin/phpunit --coverage-text --exclude-group 5.4; else ./bin/phpunit --coverage-text; fi +script: if [ $(phpenv version-name) = "5.3" ]; then ./bin/phpunit --coverage-text --exclude-group 5.4; else ./bin/phpunit --coverage-text; fi notifications: email: false From 6f4ebbd4b2c20aed829d4960b634ce2c3ed18f2d Mon Sep 17 00:00:00 2001 From: Chris Saylor Date: Sat, 15 Mar 2014 21:39:58 -0400 Subject: [PATCH 7/7] Explicitly defined test file for 5.3 under examples. --- .travis.yml | 2 +- phpunit.5.3.xml | 26 ++++++++++++++++++++++++++ 2 files changed, 27 insertions(+), 1 deletion(-) create mode 100644 phpunit.5.3.xml diff --git a/.travis.yml b/.travis.yml index 5d446c4..7dcf82b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -11,7 +11,7 @@ before_script: - composer install --dev -script: if [ $(phpenv version-name) = "5.3" ]; then ./bin/phpunit --coverage-text --exclude-group 5.4; else ./bin/phpunit --coverage-text; fi +script: if [ $(phpenv version-name) = "5.3" ]; then ./bin/phpunit -c phpunit.5.3.xml --coverage-text; else ./bin/phpunit --coverage-text; fi notifications: email: false diff --git a/phpunit.5.3.xml b/phpunit.5.3.xml new file mode 100644 index 0000000..906d81d --- /dev/null +++ b/phpunit.5.3.xml @@ -0,0 +1,26 @@ + + + + + ./tests + + + ./examples/PizzaTest.php + + + + + ./src + + +