| @@ 43-63 (lines=21) @@ | ||
| 40 | * @param string $sku A SKU |
|
| 41 | * @param string $expectedExceptionMessage The expected exception message |
|
| 42 | */ |
|
| 43 | public function validateSKU_invalidSKUs_ExceptionIsThrown($sku, $expectedExceptionMessage) |
|
| 44 | { |
|
| 45 | // act |
|
| 46 | $exceptionThrown = false; |
|
| 47 | try { |
|
| 48 | ||
| 49 | new SKU($sku); |
|
| 50 | $exceptionThrown = false; |
|
| 51 | ||
| 52 | } catch (Exception $validationException) { |
|
| 53 | ||
| 54 | // assert |
|
| 55 | $exceptionThrown = true; |
|
| 56 | $this->assertContains($expectedExceptionMessage, $validationException->getMessage(), |
|
| 57 | "validateSKU('$sku') should have thrown an exception with the message: $expectedExceptionMessage"); |
|
| 58 | ||
| 59 | } |
|
| 60 | ||
| 61 | // assert |
|
| 62 | $this->assertTrue($exceptionThrown, "validateSKU('$sku') should have thrown an exception"); |
|
| 63 | } |
|
| 64 | ||
| 65 | /** |
|
| 66 | * Get a list of valid SKUs |
|
| @@ 43-63 (lines=21) @@ | ||
| 40 | * @param string $sku A Slug |
|
| 41 | * @param string $expectedExceptionMessage The expected exception message |
|
| 42 | */ |
|
| 43 | public function validateSlug_invalidSlugs_ExceptionIsThrown($sku, $expectedExceptionMessage) |
|
| 44 | { |
|
| 45 | // act |
|
| 46 | $exceptionThrown = false; |
|
| 47 | try { |
|
| 48 | ||
| 49 | new Slug($sku); |
|
| 50 | $exceptionThrown = false; |
|
| 51 | ||
| 52 | } catch (Exception $validationException) { |
|
| 53 | ||
| 54 | // assert |
|
| 55 | $exceptionThrown = true; |
|
| 56 | $this->assertContains($expectedExceptionMessage, $validationException->getMessage(), |
|
| 57 | "validateSlug('$sku') should have thrown an exception with the message: $expectedExceptionMessage"); |
|
| 58 | ||
| 59 | } |
|
| 60 | ||
| 61 | // assert |
|
| 62 | $this->assertTrue($exceptionThrown, "validateSlug('$sku') should have thrown an exception"); |
|
| 63 | } |
|
| 64 | ||
| 65 | /** |
|
| 66 | * Get a list of valid Slugs |
|