@@ -65,19 +65,12 @@ public function testNormalize(FlattenException $exception)
65
65
public function provideFlattenException (): array
66
66
{
67
67
return [
68
- 'instance from constructor ' => [new FlattenException ()],
69
68
'instance from exception ' => [FlattenException::createFromThrowable (new \RuntimeException ('foo ' , 42 ))],
70
69
'instance with previous exception ' => [FlattenException::createFromThrowable (new \RuntimeException ('foo ' , 42 , new \Exception ()))],
71
70
'instance with headers ' => [FlattenException::createFromThrowable (new \RuntimeException ('foo ' , 42 ), 404 , ['Foo ' => 'Bar ' ])],
72
71
];
73
72
}
74
-
75
- public function testNormalizeBadObjectTypeThrowsException ()
76
- {
77
- $ this ->expectException (InvalidArgumentException::class);
78
- $ this ->normalizer ->normalize (new \stdClass ());
79
- }
80
-
73
+
81
74
public function testSupportsDenormalization ()
82
75
{
83
76
$ this ->assertTrue ($ this ->normalizer ->supportsDenormalization (null , FlattenException::class));
@@ -86,21 +79,6 @@ public function testSupportsDenormalization()
86
79
87
80
public function testDenormalizeValidData ()
88
81
{
89
- $ normalized = [];
90
- $ exception = $ this ->normalizer ->denormalize ($ normalized , FlattenException::class);
91
-
92
- $ this ->assertInstanceOf (FlattenException::class, $ exception );
93
- $ this ->assertNull ($ exception ->getMessage ());
94
- $ this ->assertNull ($ exception ->getCode ());
95
- $ this ->assertNull ($ exception ->getStatusCode ());
96
- $ this ->assertNull ($ exception ->getHeaders ());
97
- $ this ->assertNull ($ exception ->getClass ());
98
- $ this ->assertNull ($ exception ->getFile ());
99
- $ this ->assertNull ($ exception ->getLine ());
100
- $ this ->assertNull ($ exception ->getPrevious ());
101
- $ this ->assertNull ($ exception ->getTrace ());
102
- $ this ->assertNull ($ exception ->getTraceAsString ());
103
-
104
82
$ normalized = [
105
83
'message ' => 'Something went foobar. ' ,
106
84
'code ' => 42 ,
@@ -112,6 +90,16 @@ public function testDenormalizeValidData()
112
90
'previous ' => [
113
91
'message ' => 'Previous exception ' ,
114
92
'code ' => 0 ,
93
+ 'class ' => FlattenException::class,
94
+ 'file ' => 'foo.php ' ,
95
+ 'line ' => 123 ,
96
+ 'headers ' => ['Content-Type ' => 'application/json ' ],
97
+ 'trace ' => [
98
+ [
99
+ 'namespace ' => '' , 'short_class ' => '' , 'class ' => '' , 'type ' => '' , 'function ' => '' , 'file ' => 'foo.php ' , 'line ' => 123 , 'args ' => [],
100
+ ],
101
+ ],
102
+ 'trace_as_string ' => '#0 foo.php(123): foo() ' .PHP_EOL .'#1 bar.php(456): bar() ' ,
115
103
],
116
104
'trace ' => [
117
105
[
@@ -121,7 +109,7 @@ public function testDenormalizeValidData()
121
109
'trace_as_string ' => '#0 foo.php(123): foo() ' .PHP_EOL .'#1 bar.php(456): bar() ' ,
122
110
];
123
111
$ exception = $ this ->normalizer ->denormalize ($ normalized , FlattenException::class);
124
-
112
+
125
113
$ this ->assertInstanceOf (FlattenException::class, $ exception );
126
114
$ this ->assertSame ($ normalized ['message ' ], $ exception ->getMessage ());
127
115
$ this ->assertSame ($ normalized ['code ' ], $ exception ->getCode ());
@@ -137,23 +125,4 @@ public function testDenormalizeValidData()
137
125
$ this ->assertSame ($ normalized ['previous ' ]['message ' ], $ previous ->getMessage ());
138
126
$ this ->assertSame ($ normalized ['previous ' ]['code ' ], $ previous ->getCode ());
139
127
}
140
-
141
- /**
142
- * @dataProvider provideInvalidNormalizedData
143
- */
144
- public function testDenormalizeInvalidDataThrowsException ($ normalized )
145
- {
146
- $ this ->expectException (NotNormalizableValueException::class);
147
- $ this ->normalizer ->denormalize ($ normalized , FlattenException::class);
148
- }
149
-
150
- public function provideInvalidNormalizedData (): array
151
- {
152
- return [
153
- 'null ' => [null ],
154
- 'string ' => ['foo ' ],
155
- 'integer ' => [42 ],
156
- 'object ' => [new \stdClass ()],
157
- ];
158
- }
159
128
}
0 commit comments