Skip to content

Instantly share code, notes, and snippets.

@viccherubini
Created December 20, 2015 06:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save viccherubini/98c550970439e6e3f409 to your computer and use it in GitHub Desktop.
Save viccherubini/98c550970439e6e3f409 to your computer and use it in GitHub Desktop.
ProductImport Test Suite With Mocks
<?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