-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from zumba/psr4
Implemented PSR-4 support and added trait test coverage.
- Loading branch information
Showing
10 changed files
with
72 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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' | ||
))); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.