Created
December 20, 2015 06:11
-
-
Save viccherubini/88c29bec6fe651853e97 to your computer and use it in GitHub Desktop.
ProductImport Test Suite With Data Provider
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\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