1 | <?php |
||||||
2 | |||||||
3 | declare(strict_types=1); |
||||||
4 | |||||||
5 | namespace SimpleSAML\XML\TestUtils; |
||||||
6 | |||||||
7 | use DOMDocument; |
||||||
8 | use PHPUnit\Framework\Attributes\Depends; |
||||||
0 ignored issues
–
show
|
|||||||
9 | |||||||
10 | use function class_exists; |
||||||
11 | |||||||
12 | /** |
||||||
13 | * Test for Serializable XML classes to perform default serialization tests. |
||||||
14 | * |
||||||
15 | * @package simplesamlphp\xml-common |
||||||
16 | * @phpstan-ignore trait.unused |
||||||
17 | */ |
||||||
18 | trait SerializableElementTestTrait |
||||||
19 | { |
||||||
20 | /** @var class-string */ |
||||||
0 ignored issues
–
show
|
|||||||
21 | protected static string $testedClass; |
||||||
22 | |||||||
23 | /** @var \DOMDocument */ |
||||||
24 | protected static DOMDocument $xmlRepresentation; |
||||||
25 | |||||||
26 | |||||||
27 | /** |
||||||
28 | * Test creating XML from a class. |
||||||
29 | */ |
||||||
30 | abstract public function testMarshalling(): void; |
||||||
31 | |||||||
32 | |||||||
33 | /** |
||||||
34 | * Test creating a class from XML. |
||||||
35 | */ |
||||||
36 | public function testUnmarshalling(): void |
||||||
37 | { |
||||||
38 | if (!class_exists(self::$testedClass)) { |
||||||
39 | $this->markTestSkipped( |
||||||
0 ignored issues
–
show
It seems like
markTestSkipped() must be provided by classes using this trait. How about adding it as abstract method to this trait?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||||
40 | 'Unable to run ' . self::class . '::testUnmarshalling(). Please set ' . self::class |
||||||
41 | . ':$testedClass to a class-string representing the XML-class being tested', |
||||||
42 | ); |
||||||
43 | } elseif (empty(self::$xmlRepresentation)) { |
||||||
44 | $this->markTestSkipped( |
||||||
45 | 'Unable to run ' . self::class . '::testUnmarshalling(). Please set ' . self::class |
||||||
46 | . ':$xmlRepresentation to a DOMDocument representing the XML-class being tested', |
||||||
47 | ); |
||||||
48 | } else { |
||||||
49 | $elt = self::$testedClass::fromXML(self::$xmlRepresentation->documentElement); |
||||||
50 | |||||||
51 | $this->assertEquals( |
||||||
0 ignored issues
–
show
It seems like
assertEquals() must be provided by classes using this trait. How about adding it as abstract method to this trait?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||||
52 | self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement), |
||||||
53 | strval($elt), |
||||||
54 | ); |
||||||
55 | } |
||||||
56 | } |
||||||
57 | |||||||
58 | |||||||
59 | /** |
||||||
60 | * Test serialization / unserialization. |
||||||
61 | */ |
||||||
62 | #[Depends('testMarshalling')] |
||||||
63 | #[Depends('testUnmarshalling')] |
||||||
64 | public function testSerialization(): void |
||||||
65 | { |
||||||
66 | if (!class_exists(self::$testedClass)) { |
||||||
67 | $this->markTestSkipped( |
||||||
68 | 'Unable to run ' . self::class . '::testSerialization(). Please set ' . self::class |
||||||
69 | . ':$testedClass to a class-string representing the XML-class being tested', |
||||||
70 | ); |
||||||
71 | } elseif (empty(self::$xmlRepresentation)) { |
||||||
72 | $this->markTestSkipped( |
||||||
73 | 'Unable to run ' . self::class . '::testSerialization(). Please set ' . self::class |
||||||
74 | . ':$xmlRepresentation to a DOMDocument representing the XML-class being tested', |
||||||
75 | ); |
||||||
76 | } else { |
||||||
77 | $this->assertEquals( |
||||||
78 | self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement), |
||||||
79 | strval(unserialize(serialize(self::$testedClass::fromXML(self::$xmlRepresentation->documentElement)))), |
||||||
80 | ); |
||||||
81 | } |
||||||
82 | } |
||||||
83 | } |
||||||
84 |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths