Test ByTrying transformation.
More...
|
const | ERROR = 'error_expected' |
|
Test ByTrying transformation.
Definition at line 15 of file ByTryingTransformTest.php.
◆ NullOrNumericDataProvider()
ByTryingTransformationTest::NullOrNumericDataProvider |
( |
| ) |
|
Definition at line 26 of file ByTryingTransformTest.php.
29 'empty string' => [
'', null],
30 'empty string - one space' => [
' ', null],
31 'empty string - more spaces' => [
' ', null],
32 'null' => [null, null],
33 'string' => [
'str', self::ERROR],
35 'negative int' => [-1, -1],
37 'array' => [[], self::ERROR],
38 'bool (false)' => [
false, self::ERROR],
39 'bool (true)' => [
true, self::ERROR]
◆ NullOrNumericOrStringDataProvider()
ByTryingTransformationTest::NullOrNumericOrStringDataProvider |
( |
| ) |
|
Definition at line 61 of file ByTryingTransformTest.php.
64 'string' => [
'str',
'str'],
65 'null' => [null, null],
66 'empty string' => [
'', null],
68 'bool (true)' => [
true, self::ERROR],
69 'array' => [[], self::ERROR]
◆ setUp()
ByTryingTransformationTest::setUp |
( |
| ) |
|
◆ StringOrNullDataProvider()
ByTryingTransformationTest::StringOrNullDataProvider |
( |
| ) |
|
Definition at line 91 of file ByTryingTransformTest.php.
94 'string' => [
'str',
'str'],
95 'null' => [null, null],
96 'empty string' => [
'',
''],
97 'int' => [1, self::ERROR],
98 'array' => [[], self::ERROR]
◆ testNullOrNumeric()
ByTryingTransformationTest::testNullOrNumeric |
( |
|
$value, |
|
|
|
$expected |
|
) |
| |
NullOrNumericDataProvider
Definition at line 46 of file ByTryingTransformTest.php.
48 $transformation = $this->refine->byTrying([
49 $this->refine->numeric()->isNumeric(),
50 $this->refine->kindlyTo()->null()
53 if ($expected === self::ERROR) {
54 $this->expectException(ConstraintViolationException::class);
56 $transformed = $transformation->transform($value);
57 $this->assertEquals($expected, $transformed);
◆ testNullOrNumericOrString()
ByTryingTransformationTest::testNullOrNumericOrString |
( |
|
$value, |
|
|
|
$expected |
|
) |
| |
NullOrNumericOrStringDataProvider
Definition at line 76 of file ByTryingTransformTest.php.
78 $transformation = $this->refine->byTrying([
79 $this->refine->kindlyTo()->null(),
80 $this->refine->numeric()->isNumeric(),
81 $this->refine->to()->string()
84 if ($expected === self::ERROR) {
85 $this->expectException(ConstraintViolationException::class);
87 $transformed = $transformation->transform($value);
88 $this->assertEquals($expected, $transformed);
◆ testStringOrNull()
ByTryingTransformationTest::testStringOrNull |
( |
|
$value, |
|
|
|
$expected |
|
) |
| |
StringOrNullDataProvider
Definition at line 105 of file ByTryingTransformTest.php.
107 $transformation = $this->refine->byTrying([
108 $this->refine->to()->string(),
109 $this->refine->kindlyTo()->null()
112 if ($expected === self::ERROR) {
113 $this->expectException(ConstraintViolationException::class);
115 $transformed = $transformation->transform($value);
116 $this->assertEquals($expected, $transformed);
◆ ERROR
const ByTryingTransformationTest::ERROR = 'error_expected' |
The documentation for this class was generated from the following file: