Skip to content

Commit

Permalink
Merge pull request #2 from zumba/psr4
Browse files Browse the repository at this point in the history
Implemented PSR-4 support and added trait test coverage.
  • Loading branch information
jrbasso committed Mar 30, 2014
2 parents ac23858 + 6f4ebbd commit f8e840f
Show file tree
Hide file tree
Showing 10 changed files with 72 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ before_script:
- composer install --dev


script: ./bin/phpunit --coverage-text
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
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
"bin-dir": "bin"
},
"autoload": {
"psr-0": {
"psr-4": {
"Zumba\\PHPUnit\\Extensions\\Mongo\\": "src/"
}
}
Expand Down
44 changes: 44 additions & 0 deletions examples/PizzaTraitTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<?php

/**
* @group 5.4
*/
class PizzaTraitTest extends \PHPUnit_Framework_TestCase {
use \Zumba\PHPUnit\Extensions\Mongo\TestTrait;

const DEFAULT_DATABASE = 'mongounit_test';

protected $connection;

protected $dataset;

protected $fixture = [
'orders' => [
['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'
)));
}
}
26 changes: 26 additions & 0 deletions phpunit.5.3.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?xml version="1.0" encoding="UTF-8" ?>
<phpunit backupGlobals="false"
backupStaticAttributes="false"
bootstrap="vendor/autoload.php"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false"
syntaxCheck="true"
strict="true"
colors="true">
<testsuites>
<testsuite name="Core Test Suite">
<directory suffix="Test.php">./tests</directory>
</testsuite>
<testsuite name="Sample Test">
<file>./examples/PizzaTest.php</file>
</testsuite>
</testsuites>
<filter>
<whitelist addUncoveredFilesFromWhitelist="true">
<directory>./src</directory>
</whitelist>
</filter>
</phpunit>
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit f8e840f

Please sign in to comment.