Passed
Push — main ( c6b105...31af8b )
by Thierry
07:02
created

MetadataCacheTest::testClassExcludeWriteCache()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 14
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 9
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 14
rs 9.9666
1
<?php
2
declare(strict_types=1);
3
4
namespace Jaxon\Attributes\Tests\TestAttributes;
5
6
use Jaxon\Attributes\Tests\AttributeTrait;
7
use Jaxon\Attributes\Tests\Attr\Ajax\Attribute;
8
use Jaxon\Attributes\Tests\Attr\Ajax\ClassAttribute;
9
use Jaxon\Attributes\Tests\Attr\Ajax\ClassExcluded;
10
use Jaxon\Exception\SetupException;
11
use PHPUnit\Framework\TestCase;
12
13
use function Jaxon\Attributes\_register;
14
use function Jaxon\jaxon;
15
use function realpath;
16
17
class MetadataCacheTest extends TestCase
18
{
19
    use AttributeTrait;
20
21
    /**
22
     * @var string
23
     */
24
    private $sCacheDir;
25
26
    /**
27
     * @throws SetupException
28
     */
29
    public function setUp(): void
30
    {
31
        $this->sCacheDir = realpath(__DIR__ . '/../cache');
32
        @mkdir($this->sCacheDir);
0 ignored issues
show
Security Best Practice introduced by
It seems like you do not handle an error condition for mkdir(). This can introduce security issues, and is generally not recommended. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unhandled  annotation

32
        /** @scrutinizer ignore-unhandled */ @mkdir($this->sCacheDir);

If you suppress an error, we recommend checking for the error condition explicitly:

// For example instead of
@mkdir($dir);

// Better use
if (@mkdir($dir) === false) {
    throw new \RuntimeException('The directory '.$dir.' could not be created.');
}
Loading history...
33
34
        jaxon()->di()->getPluginManager()->registerPlugins();
35
        _register();
36
37
        jaxon()->di()->val('jaxon_metadata_cache_dir', $this->sCacheDir);
38
    }
39
40
    /**
41
     * @throws SetupException
42
     */
43
    public function tearDown(): void
44
    {
45
        jaxon()->reset();
46
        parent::tearDown();
47
48
        // Delete the temp dir and all its content
49
        // $aFiles = scandir($this->sCacheDir);
50
        // foreach ($aFiles as $sFile)
51
        // {
52
        //     if($sFile !== '.' && $sFile !== '..')
53
        //     {
54
        //         @unlink($this->sCacheDir . DIRECTORY_SEPARATOR . $sFile);
55
        //     }
56
        // }
57
        // @rmdir($this->sCacheDir);
58
    }
59
60
    /**
61
     * @throws SetupException
62
     */
63
    public function testUploadAndExcludeWriteCache()
64
    {
65
        $xMetadata = $this->getAttributes(Attribute::class, ['saveFiles', 'doNot']);
66
        $bExcluded = $xMetadata->isExcluded();
67
        $aProperties = $xMetadata->getProperties();
68
        $aProtected = $xMetadata->getProtectedMethods();
69
70
        // Save the class metadata in the cache.
71
        $xMetadataCache = jaxon()->di()->getMetadataCache();
72
        $xMetadataCache->save(Attribute::class, $xMetadata);
0 ignored issues
show
Bug introduced by
It seems like $xMetadata can also be of type null; however, parameter $xMetadata of Jaxon\App\Metadata\MetadataCache::save() does only seem to accept Jaxon\App\Metadata\Metadata, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

72
        $xMetadataCache->save(Attribute::class, /** @scrutinizer ignore-type */ $xMetadata);
Loading history...
73
74
        $this->assertFalse($bExcluded);
75
76
        $this->assertCount(1, $aProtected);
77
        $this->assertEquals('doNot', $aProtected[0]);
78
79
        $this->assertCount(1, $aProperties);
80
        $this->assertArrayHasKey('saveFiles', $aProperties);
81
        $this->assertCount(1, $aProperties['saveFiles']);
82
        $this->assertEquals("'user-files'", $aProperties['saveFiles']['upload']);
83
    }
84
85
    /**
86
     * @throws SetupException
87
     */
88
    public function testUploadAndExcludeReadCache()
89
    {
90
        // Read the class metadata from the cache, and run the same tests.
91
        $xMetadataCache = jaxon()->di()->getMetadataCache();
92
        $xMetadata = $xMetadataCache->read(Attribute::class);
93
94
        $bExcluded = $xMetadata->isExcluded();
95
        $aProperties = $xMetadata->getProperties();
96
        $aProtected = $xMetadata->getProtectedMethods();
97
98
        $this->assertFalse($bExcluded);
99
100
        $this->assertCount(1, $aProtected);
101
        $this->assertEquals('doNot', $aProtected[0]);
102
103
        $this->assertCount(1, $aProperties);
104
        $this->assertArrayHasKey('saveFiles', $aProperties);
105
        $this->assertCount(1, $aProperties['saveFiles']);
106
        $this->assertEquals("'user-files'", $aProperties['saveFiles']['upload']);
107
    }
108
109
    /**
110
     * @throws SetupException
111
     */
112
    public function testDataBagWriteCache()
113
    {
114
        $xMetadata = $this->getAttributes(Attribute::class, ['withBags']);
115
        $bExcluded = $xMetadata->isExcluded();
116
        $aProperties = $xMetadata->getProperties();
117
118
        // Save the class metadata in the cache.
119
        $xMetadataCache = jaxon()->di()->getMetadataCache();
120
        $xMetadataCache->save(Attribute::class, $xMetadata);
0 ignored issues
show
Bug introduced by
It seems like $xMetadata can also be of type null; however, parameter $xMetadata of Jaxon\App\Metadata\MetadataCache::save() does only seem to accept Jaxon\App\Metadata\Metadata, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

120
        $xMetadataCache->save(Attribute::class, /** @scrutinizer ignore-type */ $xMetadata);
Loading history...
121
122
        $this->assertFalse($bExcluded);
123
124
        $this->assertCount(1, $aProperties);
125
        $this->assertArrayHasKey('withBags', $aProperties);
126
        $this->assertCount(1, $aProperties['withBags']);
127
        $this->assertCount(2, $aProperties['withBags']['bags']);
128
        $this->assertEquals('user.name', $aProperties['withBags']['bags'][0]);
129
        $this->assertEquals('page.number', $aProperties['withBags']['bags'][1]);
130
    }
131
132
    /**
133
     * @throws SetupException
134
     */
135
    public function testDataBagReadCache()
136
    {
137
        // Read the class metadata from the cache, and run the same tests.
138
        $xMetadataCache = jaxon()->di()->getMetadataCache();
139
        $xMetadata = $xMetadataCache->read(Attribute::class);
140
141
        $bExcluded = $xMetadata->isExcluded();
142
        $aProperties = $xMetadata->getProperties();
143
144
        $this->assertFalse($bExcluded);
145
146
        $this->assertCount(1, $aProperties);
147
        $this->assertArrayHasKey('withBags', $aProperties);
148
        $this->assertCount(1, $aProperties['withBags']);
149
        $this->assertCount(2, $aProperties['withBags']['bags']);
150
        $this->assertEquals('user.name', $aProperties['withBags']['bags'][0]);
151
        $this->assertEquals('page.number', $aProperties['withBags']['bags'][1]);
152
    }
153
154
    /**
155
     * @throws SetupException
156
     */
157
    public function testCallbacksWriteCache()
158
    {
159
        $xMetadata = $this->getAttributes(Attribute::class, ['cbSingle', 'cbMultiple', 'cbParams']);
160
        $bExcluded = $xMetadata->isExcluded();
161
        $aProperties = $xMetadata->getProperties();
162
163
        // Save the class metadata in the cache.
164
        $xMetadataCache = jaxon()->di()->getMetadataCache();
165
        $xMetadataCache->save(Attribute::class, $xMetadata);
0 ignored issues
show
Bug introduced by
It seems like $xMetadata can also be of type null; however, parameter $xMetadata of Jaxon\App\Metadata\MetadataCache::save() does only seem to accept Jaxon\App\Metadata\Metadata, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

165
        $xMetadataCache->save(Attribute::class, /** @scrutinizer ignore-type */ $xMetadata);
Loading history...
166
167
        $this->assertFalse($bExcluded);
168
169
        $this->assertCount(3, $aProperties);
170
        $this->assertArrayHasKey('cbSingle', $aProperties);
171
        $this->assertArrayHasKey('cbMultiple', $aProperties);
172
        $this->assertArrayHasKey('cbParams', $aProperties);
173
174
        $this->assertCount(1, $aProperties['cbSingle']['__before']);
175
        $this->assertCount(2, $aProperties['cbMultiple']['__before']);
176
        $this->assertCount(2, $aProperties['cbParams']['__before']);
177
        $this->assertArrayHasKey('funcBefore', $aProperties['cbSingle']['__before']);
178
        $this->assertArrayHasKey('funcBefore1', $aProperties['cbMultiple']['__before']);
179
        $this->assertArrayHasKey('funcBefore2', $aProperties['cbMultiple']['__before']);
180
        $this->assertArrayHasKey('funcBefore1', $aProperties['cbParams']['__before']);
181
        $this->assertArrayHasKey('funcBefore2', $aProperties['cbParams']['__before']);
182
        $this->assertIsArray($aProperties['cbSingle']['__before']['funcBefore']);
183
        $this->assertIsArray($aProperties['cbMultiple']['__before']['funcBefore1']);
184
        $this->assertIsArray($aProperties['cbMultiple']['__before']['funcBefore2']);
185
        $this->assertIsArray($aProperties['cbParams']['__before']['funcBefore1']);
186
        $this->assertIsArray($aProperties['cbParams']['__before']['funcBefore2']);
187
188
        $this->assertCount(1, $aProperties['cbSingle']['__after']);
189
        $this->assertCount(3, $aProperties['cbMultiple']['__after']);
190
        $this->assertCount(1, $aProperties['cbParams']['__after']);
191
        $this->assertArrayHasKey('funcAfter', $aProperties['cbSingle']['__after']);
192
        $this->assertArrayHasKey('funcAfter1', $aProperties['cbMultiple']['__after']);
193
        $this->assertArrayHasKey('funcAfter2', $aProperties['cbMultiple']['__after']);
194
        $this->assertArrayHasKey('funcAfter3', $aProperties['cbMultiple']['__after']);
195
        $this->assertArrayHasKey('funcAfter1', $aProperties['cbParams']['__after']);
196
        $this->assertIsArray($aProperties['cbSingle']['__after']['funcAfter']);
197
        $this->assertIsArray($aProperties['cbMultiple']['__after']['funcAfter1']);
198
        $this->assertIsArray($aProperties['cbMultiple']['__after']['funcAfter2']);
199
        $this->assertIsArray($aProperties['cbMultiple']['__after']['funcAfter3']);
200
        $this->assertIsArray($aProperties['cbParams']['__after']['funcAfter1']);
201
    }
202
203
    /**
204
     * @throws SetupException
205
     */
206
    public function testCallbacksReadCache()
207
    {
208
        // Read the class metadata from the cache, and run the same tests.
209
        $xMetadataCache = jaxon()->di()->getMetadataCache();
210
        $xMetadata = $xMetadataCache->read(Attribute::class);
211
212
        $bExcluded = $xMetadata->isExcluded();
213
        $aProperties = $xMetadata->getProperties();
214
215
        $this->assertFalse($bExcluded);
216
217
        $this->assertCount(3, $aProperties);
218
        $this->assertArrayHasKey('cbSingle', $aProperties);
219
        $this->assertArrayHasKey('cbMultiple', $aProperties);
220
        $this->assertArrayHasKey('cbParams', $aProperties);
221
222
        $this->assertCount(1, $aProperties['cbSingle']['__before']);
223
        $this->assertCount(2, $aProperties['cbMultiple']['__before']);
224
        $this->assertCount(2, $aProperties['cbParams']['__before']);
225
        $this->assertArrayHasKey('funcBefore', $aProperties['cbSingle']['__before']);
226
        $this->assertArrayHasKey('funcBefore1', $aProperties['cbMultiple']['__before']);
227
        $this->assertArrayHasKey('funcBefore2', $aProperties['cbMultiple']['__before']);
228
        $this->assertArrayHasKey('funcBefore1', $aProperties['cbParams']['__before']);
229
        $this->assertArrayHasKey('funcBefore2', $aProperties['cbParams']['__before']);
230
        $this->assertIsArray($aProperties['cbSingle']['__before']['funcBefore']);
231
        $this->assertIsArray($aProperties['cbMultiple']['__before']['funcBefore1']);
232
        $this->assertIsArray($aProperties['cbMultiple']['__before']['funcBefore2']);
233
        $this->assertIsArray($aProperties['cbParams']['__before']['funcBefore1']);
234
        $this->assertIsArray($aProperties['cbParams']['__before']['funcBefore2']);
235
236
        $this->assertCount(1, $aProperties['cbSingle']['__after']);
237
        $this->assertCount(3, $aProperties['cbMultiple']['__after']);
238
        $this->assertCount(1, $aProperties['cbParams']['__after']);
239
        $this->assertArrayHasKey('funcAfter', $aProperties['cbSingle']['__after']);
240
        $this->assertArrayHasKey('funcAfter1', $aProperties['cbMultiple']['__after']);
241
        $this->assertArrayHasKey('funcAfter2', $aProperties['cbMultiple']['__after']);
242
        $this->assertArrayHasKey('funcAfter3', $aProperties['cbMultiple']['__after']);
243
        $this->assertArrayHasKey('funcAfter1', $aProperties['cbParams']['__after']);
244
        $this->assertIsArray($aProperties['cbSingle']['__after']['funcAfter']);
245
        $this->assertIsArray($aProperties['cbMultiple']['__after']['funcAfter1']);
246
        $this->assertIsArray($aProperties['cbMultiple']['__after']['funcAfter2']);
247
        $this->assertIsArray($aProperties['cbMultiple']['__after']['funcAfter3']);
248
        $this->assertIsArray($aProperties['cbParams']['__after']['funcAfter1']);
249
    }
250
251
    /**
252
     * @throws SetupException
253
     */
254
    public function testContainerWriteCache()
255
    {
256
        $xMetadata = $this->getAttributes(Attribute::class, ['di1', 'di2']);
257
        $bExcluded = $xMetadata->isExcluded();
258
        $aProperties = $xMetadata->getProperties();
259
260
        // Save the class metadata in the cache.
261
        $xMetadataCache = jaxon()->di()->getMetadataCache();
262
        $xMetadataCache->save(Attribute::class, $xMetadata);
0 ignored issues
show
Bug introduced by
It seems like $xMetadata can also be of type null; however, parameter $xMetadata of Jaxon\App\Metadata\MetadataCache::save() does only seem to accept Jaxon\App\Metadata\Metadata, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

262
        $xMetadataCache->save(Attribute::class, /** @scrutinizer ignore-type */ $xMetadata);
Loading history...
263
264
        $this->assertFalse($bExcluded);
265
266
        $this->assertCount(2, $aProperties);
267
        $this->assertArrayHasKey('di1', $aProperties);
268
        $this->assertArrayHasKey('di2', $aProperties);
269
        $this->assertCount(2, $aProperties['di1']['__di']);
270
        $this->assertCount(2, $aProperties['di2']['__di']);
271
        $this->assertEquals('Jaxon\Attributes\Tests\Service\ColorService', $aProperties['di1']['__di']['colorService']);
272
        $this->assertEquals('Jaxon\Attributes\Tests\Attr\Ajax\FontService', $aProperties['di1']['__di']['fontService']);
273
        $this->assertEquals('Jaxon\Attributes\Tests\Service\ColorService', $aProperties['di2']['__di']['colorService']);
274
        $this->assertEquals('Jaxon\Attributes\Tests\Service\TextService', $aProperties['di2']['__di']['textService']);
275
    }
276
277
    /**
278
     * @throws SetupException
279
     */
280
    public function testContainerReadCache()
281
    {
282
        // Read the class metadata from the cache, and run the same tests.
283
        $xMetadataCache = jaxon()->di()->getMetadataCache();
284
        $xMetadata = $xMetadataCache->read(Attribute::class);
285
286
        $bExcluded = $xMetadata->isExcluded();
287
        $aProperties = $xMetadata->getProperties();
288
289
        $this->assertFalse($bExcluded);
290
291
        $this->assertCount(2, $aProperties);
292
        $this->assertArrayHasKey('di1', $aProperties);
293
        $this->assertArrayHasKey('di2', $aProperties);
294
        $this->assertCount(2, $aProperties['di1']['__di']);
295
        $this->assertCount(2, $aProperties['di2']['__di']);
296
        $this->assertEquals('Jaxon\Attributes\Tests\Service\ColorService', $aProperties['di1']['__di']['colorService']);
297
        $this->assertEquals('Jaxon\Attributes\Tests\Attr\Ajax\FontService', $aProperties['di1']['__di']['fontService']);
298
        $this->assertEquals('Jaxon\Attributes\Tests\Service\ColorService', $aProperties['di2']['__di']['colorService']);
299
        $this->assertEquals('Jaxon\Attributes\Tests\Service\TextService', $aProperties['di2']['__di']['textService']);
300
    }
301
302
    /**
303
     * @throws SetupException
304
     */
305
    public function testClassWriteCache()
306
    {
307
        $xMetadata = $this->getAttributes(ClassAttribute::class, []);
308
        $bExcluded = $xMetadata->isExcluded();
309
        $aProperties = $xMetadata->getProperties();
310
311
        // Save the class metadata in the cache.
312
        $xMetadataCache = jaxon()->di()->getMetadataCache();
313
        $xMetadataCache->save(ClassAttribute::class, $xMetadata);
0 ignored issues
show
Bug introduced by
It seems like $xMetadata can also be of type null; however, parameter $xMetadata of Jaxon\App\Metadata\MetadataCache::save() does only seem to accept Jaxon\App\Metadata\Metadata, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

313
        $xMetadataCache->save(ClassAttribute::class, /** @scrutinizer ignore-type */ $xMetadata);
Loading history...
314
315
        $this->assertFalse($bExcluded);
316
317
        $this->assertCount(1, $aProperties);
318
        $this->assertArrayHasKey('*', $aProperties);
319
        $this->assertCount(4, $aProperties['*']);
320
        $this->assertArrayHasKey('bags', $aProperties['*']);
321
        $this->assertArrayHasKey('__before', $aProperties['*']);
322
        $this->assertArrayHasKey('__after', $aProperties['*']);
323
324
        $this->assertCount(2, $aProperties['*']['bags']);
325
        $this->assertEquals('user.name', $aProperties['*']['bags'][0]);
326
        $this->assertEquals('page.number', $aProperties['*']['bags'][1]);
327
328
        $this->assertCount(2, $aProperties['*']['__before']);
329
        $this->assertArrayHasKey('funcBefore1', $aProperties['*']['__before']);
330
        $this->assertArrayHasKey('funcBefore2', $aProperties['*']['__before']);
331
        $this->assertIsArray($aProperties['*']['__before']['funcBefore1']);
332
        $this->assertIsArray($aProperties['*']['__before']['funcBefore2']);
333
334
        $this->assertCount(3, $aProperties['*']['__after']);
335
        $this->assertArrayHasKey('funcAfter1', $aProperties['*']['__after']);
336
        $this->assertArrayHasKey('funcAfter2', $aProperties['*']['__after']);
337
        $this->assertArrayHasKey('funcAfter3', $aProperties['*']['__after']);
338
        $this->assertIsArray($aProperties['*']['__after']['funcAfter1']);
339
        $this->assertIsArray($aProperties['*']['__after']['funcAfter2']);
340
        $this->assertIsArray($aProperties['*']['__after']['funcAfter3']);
341
342
        $this->assertCount(3, $aProperties['*']['__di']);
343
        $this->assertArrayHasKey('colorService', $aProperties['*']['__di']);
344
        $this->assertArrayHasKey('textService', $aProperties['*']['__di']);
345
        $this->assertArrayHasKey('fontService', $aProperties['*']['__di']);
346
        $this->assertEquals('Jaxon\Attributes\Tests\Service\ColorService', $aProperties['*']['__di']['colorService']);
347
        $this->assertEquals('Jaxon\Attributes\Tests\Service\TextService', $aProperties['*']['__di']['textService']);
348
        $this->assertEquals('Jaxon\Attributes\Tests\Attr\Ajax\FontService', $aProperties['*']['__di']['fontService']);
349
    }
350
351
    /**
352
     * @throws SetupException
353
     */
354
    public function testClassReadCache()
355
    {
356
        // Read the class metadata from the cache, and run the same tests.
357
        $xMetadataCache = jaxon()->di()->getMetadataCache();
358
        $xMetadata = $xMetadataCache->read(ClassAttribute::class);
359
360
        $bExcluded = $xMetadata->isExcluded();
361
        $aProperties = $xMetadata->getProperties();
362
363
        $this->assertFalse($bExcluded);
364
365
        $this->assertCount(1, $aProperties);
366
        $this->assertArrayHasKey('*', $aProperties);
367
        $this->assertCount(4, $aProperties['*']);
368
        $this->assertArrayHasKey('bags', $aProperties['*']);
369
        $this->assertArrayHasKey('__before', $aProperties['*']);
370
        $this->assertArrayHasKey('__after', $aProperties['*']);
371
372
        $this->assertCount(2, $aProperties['*']['bags']);
373
        $this->assertEquals('user.name', $aProperties['*']['bags'][0]);
374
        $this->assertEquals('page.number', $aProperties['*']['bags'][1]);
375
376
        $this->assertCount(2, $aProperties['*']['__before']);
377
        $this->assertArrayHasKey('funcBefore1', $aProperties['*']['__before']);
378
        $this->assertArrayHasKey('funcBefore2', $aProperties['*']['__before']);
379
        $this->assertIsArray($aProperties['*']['__before']['funcBefore1']);
380
        $this->assertIsArray($aProperties['*']['__before']['funcBefore2']);
381
382
        $this->assertCount(3, $aProperties['*']['__after']);
383
        $this->assertArrayHasKey('funcAfter1', $aProperties['*']['__after']);
384
        $this->assertArrayHasKey('funcAfter2', $aProperties['*']['__after']);
385
        $this->assertArrayHasKey('funcAfter3', $aProperties['*']['__after']);
386
        $this->assertIsArray($aProperties['*']['__after']['funcAfter1']);
387
        $this->assertIsArray($aProperties['*']['__after']['funcAfter2']);
388
        $this->assertIsArray($aProperties['*']['__after']['funcAfter3']);
389
390
        $this->assertCount(3, $aProperties['*']['__di']);
391
        $this->assertArrayHasKey('colorService', $aProperties['*']['__di']);
392
        $this->assertArrayHasKey('textService', $aProperties['*']['__di']);
393
        $this->assertArrayHasKey('fontService', $aProperties['*']['__di']);
394
        $this->assertEquals('Jaxon\Attributes\Tests\Service\ColorService', $aProperties['*']['__di']['colorService']);
395
        $this->assertEquals('Jaxon\Attributes\Tests\Service\TextService', $aProperties['*']['__di']['textService']);
396
        $this->assertEquals('Jaxon\Attributes\Tests\Attr\Ajax\FontService', $aProperties['*']['__di']['fontService']);
397
    }
398
399
    /**
400
     * @throws SetupException
401
     */
402
    public function testClassExcludeWriteCache()
403
    {
404
        $xMetadata = $this->getAttributes(ClassExcluded::class, ['doNot', 'withBags', 'cbSingle']);
405
        $bExcluded = $xMetadata->isExcluded();
406
        $aProperties = $xMetadata->getProperties();
407
        $aProtected = $xMetadata->getProtectedMethods();
408
409
        // Save the class metadata in the cache.
410
        $xMetadataCache = jaxon()->di()->getMetadataCache();
411
        $xMetadataCache->save(ClassExcluded::class, $xMetadata);
0 ignored issues
show
Bug introduced by
It seems like $xMetadata can also be of type null; however, parameter $xMetadata of Jaxon\App\Metadata\MetadataCache::save() does only seem to accept Jaxon\App\Metadata\Metadata, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

411
        $xMetadataCache->save(ClassExcluded::class, /** @scrutinizer ignore-type */ $xMetadata);
Loading history...
412
413
        $this->assertTrue($bExcluded);
414
        $this->assertEmpty($aProperties);
415
        $this->assertEmpty($aProtected);
416
    }
417
418
    /**
419
     * @throws SetupException
420
     */
421
    public function testClassExcludeReadCache()
422
    {
423
        // Read the class metadata from the cache, and run the same tests.
424
        $xMetadataCache = jaxon()->di()->getMetadataCache();
425
        $xMetadata = $xMetadataCache->read(ClassExcluded::class);
426
427
        $bExcluded = $xMetadata->isExcluded();
428
        $aProperties = $xMetadata->getProperties();
429
        $aProtected = $xMetadata->getProtectedMethods();
430
431
        $this->assertTrue($bExcluded);
432
        $this->assertEmpty($aProperties);
433
        $this->assertEmpty($aProtected);
434
    }
435
}
436