Skip to content

Instantly share code, notes, and snippets.

@viccherubini
Created December 20, 2015 06:11
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/88c29bec6fe651853e97 to your computer and use it in GitHub Desktop.
Save viccherubini/88c29bec6fe651853e97 to your computer and use it in GitHub Desktop.
ProductImport Test Suite With Data Provider
<?php
use MyApp\Tests\TestCase;
class ProductImporterTest extends TestCase
{
/**
* @dataProvider providerProductFile
*/
public function testImportingProducts($file, $recordCount, $hasError)
{
$fileContents = file_get_contents(__DIR__ . '/' . $file);
$importer = $this->getContainer()
->get('my_app.product_importer')
->import($fileContents);
$this->assertEquals($recordCount, $importer->getRecordCount());
$this->assertEquals($hasError, $importer->hasError());
}
public function providerProductFile()
{
$provider = [
['products.invalid.json', 0, true],
['products.small.json', 1, false],
['products.large.json', 1000, false]
];
return $provider;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment