Created
December 20, 2015 06:07
-
-
Save viccherubini/98c550970439e6e3f409 to your computer and use it in GitHub Desktop.
ProductImport Test Suite With Mocks
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
<?php | |
use MyApp\Library\Feeds\ProductImporter; | |
class ProductImporterTest extends PHPUnit_Framework_TestCase | |
{ | |
public function testImportingProducts() | |
{ | |
// Imagine this was a sample array of data. | |
$results = []; | |
// Spend the next N lines mocking all of your DOCs. | |
$db = Mockery::mock('Doctrine\DBAL\Connection') | |
->shouldReceive('fetchAll') | |
->andReturn($results); | |
$importer = new ProductImporter($db); | |
$importer->import('{"fake":"data"}'); | |
$this->assertEquals(4, $importer->getRecordCount()); | |
$this->assertFalse($importer->hasError()); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment