From ebf31fb75ce1a92fd8f7b45188a4b0eb0edcabe2 Mon Sep 17 00:00:00 2001 From: Marc Prior Date: Fri, 9 Apr 2021 11:03:51 +0100 Subject: [PATCH 01/11] - Adding basic test for multiply function --- tests/Mutators/MultiplyFunctionTest.php | 74 +++++++++++++++++++++++++ 1 file changed, 74 insertions(+) create mode 100644 tests/Mutators/MultiplyFunctionTest.php diff --git a/tests/Mutators/MultiplyFunctionTest.php b/tests/Mutators/MultiplyFunctionTest.php new file mode 100644 index 0000000..ebb3727 --- /dev/null +++ b/tests/Mutators/MultiplyFunctionTest.php @@ -0,0 +1,74 @@ +mutatorType = new Multiply; + $this->mutatorType->setModel(new Mutator([ + Mutator::ATTRIBUTE_NAME => self::MUTATOR_NAME, + Mutator::ATTRIBUTE_ARGUMENTS => [], + ])); + + } + + /** @test */ + function it_multiplies_data_by_first_argument() + { + $originalValue = 12; + $multiplyBy = 5; // could use Faker to make both of these random in the future... + + $multipliedValue = $this->mutatorType->apply($originalValue,[$multiplyBy]); + $this->assertSame( ( $originalValue * $multiplyBy ), $multipliedValue,"The mutator applies the multiplication" ); + $this->assertNotSame( $originalValue, $multipliedValue,"The original value should be changed" ); + + } //EOF it_multiplies_data_by_first_argument + + /** @test */ + function it_does_not_multiply_subsequent_arguments() + { + $originalValue = 21; + $multiplyBy = 7; + $doNotMultiplyBy = 8; + $norMultiplyBy = 9; + + $multipliedValue = $this->mutatorType->apply($originalValue,[$multiplyBy,$doNotMultiplyBy,$norMultiplyBy]); + $this->assertSame(( $originalValue * $multiplyBy ), $multipliedValue,"The mutator multiplies by first argument"); + $this->assertNotSame(( $originalValue * $doNotMultiplyBy ), $multipliedValue,"The mutator ignores the second argument"); + $this->assertNotSame(( $originalValue * $norMultiplyBy ), $multipliedValue,"The mutator ignores the third argument"); + + } //EOF it_does_not_multiply_subsequent_arguments + + /** @test */ + function it_multiplies_decimals() + { + $originalValue = 12.345; + $multiplyBy = 5.67; // could use Faker to make both of these random in the future... + + $multipliedValue = $this->mutatorType->apply($originalValue,[$multiplyBy]); + $this->assertSame( ( $originalValue * $multiplyBy ), $multipliedValue,"The mutator works with decimals and floating point numbers" ); + } //EOF it_multiplies_decimals + + /** @test */ + function it_can_multiply_string_arguments() + { + $originalValue = "24"; + $multiplyBy = "5"; // could use Faker to make both of these random in the future... + + $multipliedValue = $this->mutatorType->apply($originalValue,[$multiplyBy]); + $this->assertSame( ( (int)$originalValue * (int) $multiplyBy ), $multipliedValue,"The mutator casts strings to numbers" ); + } //EOF it_can_multiply_string_arguments +} \ No newline at end of file From 5de41d6d1dff9145227bc8477bd5ac5a70bc6f62 Mon Sep 17 00:00:00 2001 From: Marc Prior Date: Fri, 9 Apr 2021 11:32:34 +0100 Subject: [PATCH 02/11] - Adding base convert mutator and tests --- src/Mutator/BaseConvert.php | 40 ++++++++++++++++++ tests/Mutators/BaseConvertFunctionTest.php | 47 ++++++++++++++++++++++ 2 files changed, 87 insertions(+) create mode 100644 src/Mutator/BaseConvert.php create mode 100644 tests/Mutators/BaseConvertFunctionTest.php diff --git a/src/Mutator/BaseConvert.php b/src/Mutator/BaseConvert.php new file mode 100644 index 0000000..2950263 --- /dev/null +++ b/src/Mutator/BaseConvert.php @@ -0,0 +1,40 @@ +model = $model; + return $this; + } + + public function apply($originalValue, array $arguments = []) + { + $fromBase = (int) $arguments[0]; + $toBase = ( isset($arguments[1]) && (int) $arguments[1] > 0 ) ? (int) $arguments[1]:$this->defaultToBase; + return base_convert($originalValue,$fromBase,$toBase); + } +} diff --git a/tests/Mutators/BaseConvertFunctionTest.php b/tests/Mutators/BaseConvertFunctionTest.php new file mode 100644 index 0000000..b1c6be8 --- /dev/null +++ b/tests/Mutators/BaseConvertFunctionTest.php @@ -0,0 +1,47 @@ +mutatorType = new BaseConvert; + $this->mutatorType->setModel(new Mutator([ + Mutator::ATTRIBUTE_NAME => self::MUTATOR_NAME, + Mutator::ATTRIBUTE_ARGUMENTS => [], + ])); + } + + /** @test */ + function it_converts_a_number_to_different_base() + { + $originalValue = 'a37334'; // hexadecimal + $fromBase = 16; + $toBase = 2; + + $rebasedValue = $this->mutatorType->apply($originalValue,[$fromBase, $toBase]); + $this->assertSame( base_convert($originalValue,$fromBase,$toBase), $rebasedValue,"It converts base" ); + $this->assertNotSame( $originalValue, $rebasedValue,"The original value should have changed base" ); + } //EOF it_converts_a_number_to_different_base + + /** @test */ + function it_defaults_to_base_ten_if_missing_second_argument() + { + $originalValue = 'a37334'; // hexadecimal + $fromBase = 16; + $rebasedValue = $this->mutatorType->apply($originalValue,[$fromBase]); + $this->assertSame( base_convert($originalValue,$fromBase,10), $rebasedValue,"It defaults to base into base 10" ); + + } //EOF it_converts_a_number_to_different_base +} \ No newline at end of file From 58735f435fe9aa9d48f9b4ecdf8089632f9c9d7a Mon Sep 17 00:00:00 2001 From: Marc Prior Date: Fri, 9 Apr 2021 11:32:49 +0100 Subject: [PATCH 03/11] - Adding modulo mutator and tests --- src/Mutator/Modulo.php | 36 ++++++++++++++++++++ tests/Mutators/ModuloFunctionTest.php | 48 +++++++++++++++++++++++++++ 2 files changed, 84 insertions(+) create mode 100644 src/Mutator/Modulo.php create mode 100644 tests/Mutators/ModuloFunctionTest.php diff --git a/src/Mutator/Modulo.php b/src/Mutator/Modulo.php new file mode 100644 index 0000000..88e38d1 --- /dev/null +++ b/src/Mutator/Modulo.php @@ -0,0 +1,36 @@ +model = $model; + return $this; + } + + public function apply($originalValue, array $arguments = []) + { + return fmod(floatval($originalValue),floatval($arguments[0])); + } +} diff --git a/tests/Mutators/ModuloFunctionTest.php b/tests/Mutators/ModuloFunctionTest.php new file mode 100644 index 0000000..a02eb7a --- /dev/null +++ b/tests/Mutators/ModuloFunctionTest.php @@ -0,0 +1,48 @@ +mutatorType = new Modulo; + $this->mutatorType->setModel(new Mutator([ + Mutator::ATTRIBUTE_NAME => self::MUTATOR_NAME, + Mutator::ATTRIBUTE_ARGUMENTS => [], + ])); + } + + /** @test */ + function it_returns_the_modulo_of_both_numbers() + { + $firstNumber = 5.7; + $secondNumber = 1.3; + + $modulo = $this->mutatorType->apply($firstNumber,[$secondNumber]); + $this->assertSame(fmod($firstNumber,$secondNumber), $modulo,"It returns the remainder of the original value divided by the second" ); + $this->assertNotSame( $firstNumber, $modulo,"The original value should have changed" ); + } //EOF it_returns_the_modulo_of_both_numbers + + /** @test */ + function it_returns_the_modulo_if_numeric_strings() + { + $firstNumber = "5.7"; + $secondNumber = "1.3"; + + $modulo = $this->mutatorType->apply($firstNumber,[$secondNumber]); + $this->assertSame(fmod(floatval($firstNumber),floatval($secondNumber)), $modulo,"It converts string arguments to floating point numbers" ); + } //EOF it_returns_the_modulo_if_numeric_strings + +} \ No newline at end of file From 4a6f8416fafd70dd40fd95785d542bd77768f062 Mon Sep 17 00:00:00 2001 From: Marc Prior Date: Fri, 9 Apr 2021 12:38:04 +0100 Subject: [PATCH 04/11] - Adding Addition mutator plus tests --- src/Mutator/Add.php | 40 ++++++++++++++++++++ tests/Mutators/AdditionFunctionTest.php | 49 +++++++++++++++++++++++++ 2 files changed, 89 insertions(+) create mode 100644 src/Mutator/Add.php create mode 100644 tests/Mutators/AdditionFunctionTest.php diff --git a/src/Mutator/Add.php b/src/Mutator/Add.php new file mode 100644 index 0000000..e6261fc --- /dev/null +++ b/src/Mutator/Add.php @@ -0,0 +1,40 @@ +model = $model; + return $this; + } + + public function apply($originalValue, array $arguments = []) + { + $newValue = $originalValue; + for($i=0; $i < count($arguments); $i++) { + $newValue += $arguments[$i]; + } + return $newValue; + } +} diff --git a/tests/Mutators/AdditionFunctionTest.php b/tests/Mutators/AdditionFunctionTest.php new file mode 100644 index 0000000..a12696d --- /dev/null +++ b/tests/Mutators/AdditionFunctionTest.php @@ -0,0 +1,49 @@ +mutatorType = new Add; + $this->mutatorType->setModel(new Mutator([ + Mutator::ATTRIBUTE_NAME => self::MUTATOR_NAME, + Mutator::ATTRIBUTE_ARGUMENTS => [], + ])); + } + + /** @test */ + function it_can_add_to_original_value() + { + $originalValue = 12; + $add = 5; + + $addedValue = $this->mutatorType->apply($originalValue,[$add]); + $this->assertSame( ($originalValue + $add), $addedValue, "Original value should be correctly added together"); + $this->assertNotSame( $originalValue, $addedValue, "Original value should have mutated"); + } //EOF it_can_add_to_original_value + + /** @test */ + + function it_can_add_original_value_multiple_times() + { + $originalValue = 12; + $add = 5; + $thenAnd = 12; + $finallyAdd = 43; + + $addedValue = $this->mutatorType->apply($originalValue,[$add,$thenAnd,$finallyAdd]); + $this->assertNotSame( ($originalValue + $add), $addedValue, "Value not just adding the first argument"); + $this->assertSame( ( $originalValue + $add + $thenAnd + $finallyAdd), $addedValue, "Original value should add each argument supplied"); + } //EOF it_can_add_original_value_multiple_times +} \ No newline at end of file From d1274c93956bd5901bed795c3853a37f914ef4d2 Mon Sep 17 00:00:00 2001 From: Marc Prior Date: Fri, 9 Apr 2021 12:38:20 +0100 Subject: [PATCH 05/11] - Adding Divide mutator, plus tests --- src/Mutator/Divide.php | 40 +++++++++++++++++++++++ tests/Mutators/DivideFunctionTest.php | 47 +++++++++++++++++++++++++++ 2 files changed, 87 insertions(+) create mode 100644 src/Mutator/Divide.php create mode 100644 tests/Mutators/DivideFunctionTest.php diff --git a/src/Mutator/Divide.php b/src/Mutator/Divide.php new file mode 100644 index 0000000..d146b84 --- /dev/null +++ b/src/Mutator/Divide.php @@ -0,0 +1,40 @@ +model = $model; + return $this; + } + + public function apply($originalValue, array $arguments = []) + { + $newValue = $originalValue; + for($i=0; $i < count($arguments); $i++) { + $newValue /= $arguments[$i]; + } + return $newValue; + } +} diff --git a/tests/Mutators/DivideFunctionTest.php b/tests/Mutators/DivideFunctionTest.php new file mode 100644 index 0000000..6876595 --- /dev/null +++ b/tests/Mutators/DivideFunctionTest.php @@ -0,0 +1,47 @@ +mutatorType = new Divide; + $this->mutatorType->setModel(new Mutator([ + Mutator::ATTRIBUTE_NAME => self::MUTATOR_NAME, + Mutator::ATTRIBUTE_ARGUMENTS => [], + ])); + } + + /** @test */ + function it_can_divide_original_value() + { + $originalValue = 12; + $divideBy = 5; + + $dividedValue = $this->mutatorType->apply($originalValue,[$divideBy]); + $this->assertSame( ($originalValue / $divideBy), $dividedValue, "Original value should be correctly divided"); + $this->assertNotSame( $originalValue, $dividedValue, "Original value should have mutated"); + } //EOF it_can_divide_original_value + + /** @test */ + function it_can_divide_original_value_multiple_times() + { + $originalValue = 12; + $divideBy = 5; + $thenDivideBy = 2; + + $dividedValue = $this->mutatorType->apply($originalValue,[$divideBy,$thenDivideBy]); + $this->assertNotSame( ($originalValue / $divideBy), $dividedValue, "Value not just divided by first argument"); + $this->assertSame( ( $originalValue / $divideBy / $thenDivideBy), $dividedValue, "Original value should be divided by each argument supplied"); + } //EOF it_can_divide_original_value_multiple_times +} \ No newline at end of file From 10742697c6dc7aa3f3918cfeb92791a2531b81bd Mon Sep 17 00:00:00 2001 From: Marc Prior Date: Fri, 9 Apr 2021 12:38:32 +0100 Subject: [PATCH 06/11] - Adding Subtract mutator, plus tests --- src/Mutator/Subtract.php | 40 ++++++++++++++++++++ tests/Mutators/SubtractFunctionTest.php | 49 +++++++++++++++++++++++++ 2 files changed, 89 insertions(+) create mode 100644 src/Mutator/Subtract.php create mode 100644 tests/Mutators/SubtractFunctionTest.php diff --git a/src/Mutator/Subtract.php b/src/Mutator/Subtract.php new file mode 100644 index 0000000..319c6a9 --- /dev/null +++ b/src/Mutator/Subtract.php @@ -0,0 +1,40 @@ +model = $model; + return $this; + } + + public function apply($originalValue, array $arguments = []) + { + $newValue = $originalValue; + for($i=0; $i < count($arguments); $i++) { + $newValue -= $arguments[$i]; + } + return $newValue; + } +} diff --git a/tests/Mutators/SubtractFunctionTest.php b/tests/Mutators/SubtractFunctionTest.php new file mode 100644 index 0000000..ee4b67c --- /dev/null +++ b/tests/Mutators/SubtractFunctionTest.php @@ -0,0 +1,49 @@ +mutatorType = new Subtract; + $this->mutatorType->setModel(new Mutator([ + Mutator::ATTRIBUTE_NAME => self::MUTATOR_NAME, + Mutator::ATTRIBUTE_ARGUMENTS => [], + ])); + } + + /** @test */ + function it_can_subtract_from_original_value() + { + $originalValue = 12; + $subtract = 5; + + $subtractedValue = $this->mutatorType->apply($originalValue,[$subtract]); + $this->assertSame( ($originalValue - $subtract), $subtractedValue, "Original value should be correctly subtracted"); + $this->assertNotSame( $originalValue, $subtractedValue, "Original value should have mutated"); + } //EOF it_can_subtract_from_original_value + + /** @test */ + + function it_can_subtract_from_original_value_multiple_times() + { + $originalValue = 12; + $subtract = 5; + $thenSubtract = 12; + $finallySubtract = 43; + + $subtractedValue = $this->mutatorType->apply($originalValue,[$subtract,$thenSubtract,$finallySubtract]); + $this->assertNotSame( ($originalValue - $subtract), $subtractedValue, "Value not just subtracting the first argument"); + $this->assertSame( ( $originalValue - $subtract - $thenSubtract - $finallySubtract), $subtractedValue, "Original value should subtract each argument supplied"); + } //EOF it_can_subtract_from_original_value_multiple_times +} \ No newline at end of file From aae629c328a79e43f90b705732295ac578e4f6e2 Mon Sep 17 00:00:00 2001 From: Marc Prior Date: Fri, 9 Apr 2021 12:39:32 +0100 Subject: [PATCH 07/11] - wip. removed unused class import in test --- tests/Mutators/ModuloFunctionTest.php | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/Mutators/ModuloFunctionTest.php b/tests/Mutators/ModuloFunctionTest.php index a02eb7a..3262c1c 100644 --- a/tests/Mutators/ModuloFunctionTest.php +++ b/tests/Mutators/ModuloFunctionTest.php @@ -6,7 +6,6 @@ use PHPUnit\Framework\TestCase; use Zahran\Mapper\Model\Mutator; -use Zahran\Mapper\Mutator\BaseConvert; use Zahran\Mapper\Mutator\Modulo; class ModuloFunctionTest extends TestCase From 5283c13f097d6a612a065f01339440cb9ff0e051 Mon Sep 17 00:00:00 2001 From: Marc Prior Date: Fri, 9 Apr 2021 12:48:34 +0100 Subject: [PATCH 08/11] - added exponential mutator and tests --- src/Mutator/Exponential.php | 40 ++++++++++++++++++ tests/Mutators/ExponentialFunctionTest.php | 48 ++++++++++++++++++++++ 2 files changed, 88 insertions(+) create mode 100644 src/Mutator/Exponential.php create mode 100644 tests/Mutators/ExponentialFunctionTest.php diff --git a/src/Mutator/Exponential.php b/src/Mutator/Exponential.php new file mode 100644 index 0000000..107cab5 --- /dev/null +++ b/src/Mutator/Exponential.php @@ -0,0 +1,40 @@ +model = $model; + return $this; + } + + public function apply($originalValue, array $arguments = []) + { + $newValue = $originalValue; + for($i=0; $i < count($arguments); $i++) { + $newValue **= $arguments[$i]; + } + return $newValue; + } +} diff --git a/tests/Mutators/ExponentialFunctionTest.php b/tests/Mutators/ExponentialFunctionTest.php new file mode 100644 index 0000000..1129172 --- /dev/null +++ b/tests/Mutators/ExponentialFunctionTest.php @@ -0,0 +1,48 @@ +mutatorType = new Exponential; + $this->mutatorType->setModel(new Mutator([ + Mutator::ATTRIBUTE_NAME => self::MUTATOR_NAME, + Mutator::ATTRIBUTE_ARGUMENTS => [], + ])); + } + + /** @test */ + function it_can_raise_the_power_of_original_value() + { + $originalValue = 12; + $raisedToPowerOf = 3; + + $mutatedValue = $this->mutatorType->apply($originalValue,[$raisedToPowerOf]); + $this->assertSame( ($originalValue ** $raisedToPowerOf), $mutatedValue, "Original value should be correctly raised to the power"); + $this->assertNotSame( $originalValue, $mutatedValue, "Original value should have mutated"); + } //EOF it_can_raise_the_power_of_original_value + + /** @test */ + + function it_can_raise_the_power_of_the_original_value_multiple_times() + { + $originalValue = 34; + $raiseToThePowerOf = 2; + $thenRaiseTo = 2; + + $mutatedValue = $this->mutatorType->apply($originalValue,[$raiseToThePowerOf,$thenRaiseTo]); + $this->assertNotSame( ($originalValue ** $raiseToThePowerOf), $mutatedValue, "Value not just raising the power of the first argument"); + $this->assertSame( ( $originalValue ** $raiseToThePowerOf ** $thenRaiseTo), $mutatedValue, "Original value should raise to the power of each argument supplied"); + } //EOF it_can_raise_the_power_of_the_original_value_multiple_times +} \ No newline at end of file From e1b74640f1e834974859eb8a3618c9cd9c31ee0a Mon Sep 17 00:00:00 2001 From: Marc Prior Date: Fri, 9 Apr 2021 13:05:44 +0100 Subject: [PATCH 09/11] - wip. Added boolean cast test --- tests/CastTypes/BooleanCastTypeTest.php | 52 +++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 tests/CastTypes/BooleanCastTypeTest.php diff --git a/tests/CastTypes/BooleanCastTypeTest.php b/tests/CastTypes/BooleanCastTypeTest.php new file mode 100644 index 0000000..2605890 --- /dev/null +++ b/tests/CastTypes/BooleanCastTypeTest.php @@ -0,0 +1,52 @@ +castType = new Boolean; + $this->castType->setModel(new CastType([ + CastType::ATTRIBUTE_TYPE => "boolean" + ])); + } + + /** @test */ + function it_can_cast_numerals_as_a_boolean() + { + $originalNumeral = 1; + $castTo = $this->castType->cast($originalNumeral); + $this->assertSame(boolval($originalNumeral),$castTo,"Converts numerals to booleans"); + $this->assertNotSame($originalNumeral,$castTo,"Original value casting should have changed"); + $this->assertTrue( $castTo ,"Original value should now equate to true"); + } //EOF it_can_cast_numerals_as_a_boolean + + /** @test */ + function it_can_cast_strings_as_a_boolean() + { + $originalNumeral = "1"; + $castTo = $this->castType->cast($originalNumeral); + $this->assertSame(boolval($originalNumeral),$castTo,"Converts strings to booleans"); + $this->assertNotSame($originalNumeral,$castTo,"Original value casting should have changed"); + $this->assertTrue( $castTo ,"Original value should now equate to true"); + } //EOF it_can_cast_strings_as_a_boolean + + /** @test */ + function it_keeps_booleans_as_booleans() + { + $originalNumeral = true; + $castTo = $this->castType->cast($originalNumeral); + $this->assertSame($originalNumeral,$castTo,"Original value casting should match the output"); + $this->assertTrue( $castTo ,"Original value should still equate to true"); + } //EOF it_keeps_booleans_as_booleans + +} \ No newline at end of file From faab289347a2d28ba7c1632e9ceddc2ad7d92a05 Mon Sep 17 00:00:00 2001 From: Marc Prior Date: Fri, 9 Apr 2021 13:25:51 +0100 Subject: [PATCH 10/11] - bugfix. Removed translation helper from Exception causing undefined function error --- src/CastType/Date.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/CastType/Date.php b/src/CastType/Date.php index 07a2524..6685bff 100644 --- a/src/CastType/Date.php +++ b/src/CastType/Date.php @@ -32,7 +32,7 @@ public function setModel(CastType $model): CastTypeInterface public function cast($originalValue) { if (!$this->model->getFormat()) { - throw new \InvalidArgumentException(__('The format must be provided!')); + throw new \InvalidArgumentException('The format must be provided!'); } $date = new \DateTime($originalValue); return $date->format($this->model->getFormat()); From 6a3a52b9dea687fd879863173a61dac7bdee9998 Mon Sep 17 00:00:00 2001 From: Marc Prior Date: Fri, 9 Apr 2021 13:26:17 +0100 Subject: [PATCH 11/11] - Added basic date cast type tests. --- tests/CastTypes/DateCastTypeTest.php | 73 ++++++++++++++++++++++++++++ 1 file changed, 73 insertions(+) create mode 100644 tests/CastTypes/DateCastTypeTest.php diff --git a/tests/CastTypes/DateCastTypeTest.php b/tests/CastTypes/DateCastTypeTest.php new file mode 100644 index 0000000..2f6aca4 --- /dev/null +++ b/tests/CastTypes/DateCastTypeTest.php @@ -0,0 +1,73 @@ +castType = new Date; + + } + + /** @test */ + function it_can_format_date_to_string_supplied() + { + $originalValue = "2021-03-21 09:34:15"; + $format = "d/m/Y H:i"; + + $this->castType->setModel(new CastType([ + CastType::ATTRIBUTE_TYPE => self::ATTRIBUTE_TYPE, + CastType::ATTRIBUTE_FORMAT => $format, + ])); + + $reformattedDate = $this->castType->cast($originalValue); + + $this->assertSame( ( new \DateTime($originalValue))->format($format), $reformattedDate, "Original value should now be in new date format"); + $this->assertNotSame($originalValue,$reformattedDate,"Original value should have changed"); + + } //EOF it_can_format_date_to_string_supplied + + /** @test */ + function it_can_format_date_to_constant_supplied() + { + $originalValue = "2021-03-21 09:34:15"; + $format = \DateTimeInterface::ISO8601; + + $this->castType->setModel(new CastType([ + CastType::ATTRIBUTE_TYPE => self::ATTRIBUTE_TYPE, + CastType::ATTRIBUTE_FORMAT => $format, + ])); + + $reformattedDate = $this->castType->cast($originalValue); + + $this->assertSame( ( new \DateTime($originalValue))->format($format), $reformattedDate, "Original value should now be in new date format"); + $this->assertNotSame($originalValue,$reformattedDate,"Original value should have changed"); + + } //EOF it_can_format_date_to_constant_supplied + + /** @test */ + function it_throws_exception_if_format_missing() + { + $originalValue = "2021-03-21 09:34:15"; + + $this->expectExceptionObject(new \InvalidArgumentException('The format must be provided!')); + + $this->castType->setModel(new CastType([ + CastType::ATTRIBUTE_TYPE => self::ATTRIBUTE_TYPE, + ])); + + $this->castType->cast($originalValue); + + } //EOF it_throws_exception_if_format_missing +} \ No newline at end of file