Skip to content

Commit

Permalink
Merge pull request #32 from KickAssCommerce/check-type-casting-on-mapper
Browse files Browse the repository at this point in the history
Add test for the TypeError exception on Product map construct
  • Loading branch information
adam-paterson committed Feb 17, 2017
2 parents d2db05b + 6b8fede commit 04d892a
Showing 1 changed file with 35 additions and 3 deletions.
38 changes: 35 additions & 3 deletions tests/Product/Map/ProductTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,43 @@

final class ProductTest extends TestCase
{
public function testGetSku()
/**
* @dataProvider providerTestGetSku
*/
public function testGetSku($input, $expected)
{
$product = new Product(
'sample-sku'
$input
);
$this->assertEquals('sample-sku', $product->getSku());
$this->assertEquals($expected, $product->getSku());
}

public function providerTestGetSku()
{
return [
['sample-sku', 'sample-sku'],
[123, '123'],
[9.87, '9.87']
];
}

/**
* @throws \PHPUnit\Framework\Exception
* @dataProvider providerTestSkuType
*/
public function testSkuType($sku)
{
$this->expectException(\TypeError::class);
new Product(
$sku
);
}

public function providerTestSkuType()
{
return [
[new \stdClass()],
[['something']]
];
}
}

0 comments on commit 04d892a

Please sign in to comment.