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 | */ |
||||||
17 | trait SerializableElementTestTrait |
||||||
18 | { |
||||||
19 | /** @var class-string */ |
||||||
0 ignored issues
–
show
|
|||||||
20 | protected static string $testedClass; |
||||||
21 | |||||||
22 | /** @var \DOMDocument */ |
||||||
23 | protected static DOMDocument $xmlRepresentation; |
||||||
24 | |||||||
25 | |||||||
26 | /** |
||||||
27 | * Test creating XML from a class. |
||||||
28 | */ |
||||||
29 | abstract public function testMarshalling(): void; |
||||||
30 | |||||||
31 | |||||||
32 | /** |
||||||
33 | * Test creating a class from XML. |
||||||
34 | */ |
||||||
35 | public function testUnmarshalling(): void |
||||||
36 | { |
||||||
37 | if (!class_exists(self::$testedClass)) { |
||||||
38 | $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
![]() |
|||||||
39 | 'Unable to run ' . self::class . '::testUnmarshalling(). Please set ' . self::class |
||||||
40 | . ':$testedClass to a class-string representing the XML-class being tested', |
||||||
41 | ); |
||||||
42 | } elseif (empty(self::$xmlRepresentation)) { |
||||||
43 | $this->markTestSkipped( |
||||||
44 | 'Unable to run ' . self::class . '::testUnmarshalling(). Please set ' . self::class |
||||||
45 | . ':$xmlRepresentation to a DOMDocument representing the XML-class being tested', |
||||||
46 | ); |
||||||
47 | } else { |
||||||
48 | $elt = self::$testedClass::fromXML(self::$xmlRepresentation->documentElement); |
||||||
49 | |||||||
50 | $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
![]() |
|||||||
51 | self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement), |
||||||
52 | strval($elt), |
||||||
53 | ); |
||||||
54 | } |
||||||
55 | } |
||||||
56 | |||||||
57 | |||||||
58 | /** |
||||||
59 | * Test serialization / unserialization. |
||||||
60 | */ |
||||||
61 | #[Depends('testMarshalling')] |
||||||
62 | #[Depends('testUnmarshalling')] |
||||||
63 | public function testSerialization(): void |
||||||
64 | { |
||||||
65 | if (!class_exists(self::$testedClass)) { |
||||||
66 | $this->markTestSkipped( |
||||||
67 | 'Unable to run ' . self::class . '::testSerialization(). Please set ' . self::class |
||||||
68 | . ':$testedClass to a class-string representing the XML-class being tested', |
||||||
69 | ); |
||||||
70 | } elseif (empty(self::$xmlRepresentation)) { |
||||||
71 | $this->markTestSkipped( |
||||||
72 | 'Unable to run ' . self::class . '::testSerialization(). Please set ' . self::class |
||||||
73 | . ':$xmlRepresentation to a DOMDocument representing the XML-class being tested', |
||||||
74 | ); |
||||||
75 | } else { |
||||||
76 | $this->assertEquals( |
||||||
77 | self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement), |
||||||
78 | strval(unserialize(serialize(self::$testedClass::fromXML(self::$xmlRepresentation->documentElement)))), |
||||||
79 | ); |
||||||
80 | } |
||||||
81 | } |
||||||
82 | } |
||||||
83 |
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