Skip to content

Commit

Permalink
Fixes to accommodate for @Depends
Browse files Browse the repository at this point in the history
  • Loading branch information
tvdijen committed May 28, 2023
1 parent 7b42d0d commit 197cc98
Show file tree
Hide file tree
Showing 4 changed files with 147 additions and 26 deletions.
73 changes: 73 additions & 0 deletions tests/XML/ExtendableAttributesTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
<?php

declare(strict_types=1);

namespace SimpleSAML\Test\XML;

use PHPUnit\Framework\TestCase;
use SimpleSAML\Test\XML\ExtendableAttributesElement;
use SimpleSAML\XML\DOMDocumentFactory;
use SimpleSAML\XML\TestUtils\SchemaValidationTestTrait;
use SimpleSAML\XML\TestUtils\SerializableElementTestTrait;
use SimpleSAML\XML\Attribute;

use function dirname;

/**
* Class \SimpleSAML\XML\ExtendableAttributesTest
*
* @covers \SimpleSAML\XML\TestUtils\SchemaValidationTestTrait
* @covers \SimpleSAML\XML\TestUtils\SerializableElementTestTrait
*
* @package simplesamlphp\xml-common
*/
final class ExtendableAttributesTest extends TestCase
{
use SchemaValidationTestTrait;
use SerializableElementTestTrait;


/**
*/
public static function setUpBeforeClass(): void
{
self::$schemaFile = dirname(__FILE__, 2) . '/resources/schemas/simplesamlphp.xsd';

self::$testedClass = ExtendableAttributesElement::class;

self::$xmlRepresentation = DOMDocumentFactory::fromFile(
dirname(__FILE__, 2) . '/resources/xml/ssp_ExtendableAttributesElement.xml',
);
}


/**
*/
public function testMarshalling(): void
{
$extendableElement = new ExtendableAttributesElement(
[
new Attribute('urn:x-simplesamlphp:namespace', 'ssp', 'attr1', 'testval1'),
new Attribute('urn:x-simplesamlphp:namespace', 'ssp', 'attr2', 'testval2'),
],
);

$this->assertEquals(
self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement),
strval($extendableElement),
);
}


/**
*/
public function testUnmarshalling(): void
{
$extendableElement = ExtendableAttributesElement::fromXML(self::$xmlRepresentation->documentElement);

$this->assertEquals(
self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement),
strval($extendableElement),
);
}
}
13 changes: 0 additions & 13 deletions tests/XML/ExtendableAttributesTraitTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@
use SimpleSAML\Test\XML\ExtendableAttributesTestTrait;
use SimpleSAML\XML\Constants as C;
use SimpleSAML\XML\DOMDocumentFactory;
use SimpleSAML\XML\TestUtils\SchemaValidationTestTrait;
use SimpleSAML\XML\TestUtils\SerializableElementTestTrait;
use SimpleSAML\XML\Attribute;

use function dirname;
Expand All @@ -28,9 +26,6 @@
*/
final class ExtendableAttributesTraitTest extends TestCase
{
use SerializableElementTestTrait;
use SchemaValidationTestTrait;

/** @var \SimpleSAML\XML\Attribute */
protected static Attribute $local;

Expand All @@ -45,14 +40,6 @@ final class ExtendableAttributesTraitTest extends TestCase
*/
public static function setUpBeforeClass(): void
{
self::$schemaFile = dirname(__FILE__, 2) . '/resources/schemas/simplesamlphp.xsd';

self::$testedClass = ExtendableAttributesElement::class;

self::$xmlRepresentation = DOMDocumentFactory::fromFile(
dirname(__FILE__, 2) . '/resources/xml/ssp_ExtendableAttributesElement.xml',
);

self::$local = new Attribute(null, '', 'some', 'localValue');

self::$target = new Attribute('urn:x-simplesamlphp:namespace', '', 'some', 'targetValue');
Expand Down
74 changes: 74 additions & 0 deletions tests/XML/ExtendableElementTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
<?php

declare(strict_types=1);

namespace SimpleSAML\Test\XML;

use PHPUnit\Framework\TestCase;
use SimpleSAML\Test\XML\ExtendableElementElement;
use SimpleSAML\XML\Chunk;
use SimpleSAML\XML\DOMDocumentFactory;
use SimpleSAML\XML\TestUtils\SchemaValidationTestTrait;
use SimpleSAML\XML\TestUtils\SerializableElementTestTrait;
use SimpleSAML\XML\Attribute;

use function dirname;

/**
* Class \SimpleSAML\XML\ExtendableElementTest
*
* @covers \SimpleSAML\XML\TestUtils\SchemaValidationTestTrait
* @covers \SimpleSAML\XML\TestUtils\SerializableElementTestTrait
*
* @package simplesamlphp\xml-common
*/
final class ExtendableElementTest extends TestCase
{
use SchemaValidationTestTrait;
use SerializableElementTestTrait;


/**
*/
public static function setUpBeforeClass(): void
{
self::$schemaFile = dirname(__FILE__, 2) . '/resources/schemas/simplesamlphp.xsd';

self::$testedClass = ExtendableElement::class;

self::$xmlRepresentation = DOMDocumentFactory::fromFile(
dirname(__FILE__, 2) . '/resources/xml/ssp_ExtendableElement.xml',
);
}


/**
*/
public function testMarshalling(): void
{
$extendableElement = new ExtendableElement(
[
new Chunk(DOMDocumentFactory::fromString('<ssp:Chunk xmlns:ssp="urn:x-simplesamlphp:namespace">some</ssp:Chunk>')->documentElement),
new Chunk(DOMDocumentFactory::fromString('<dummy:Chunk xmlns:dummy="urn:custom:dummy">some</dummy:Chunk>')->documentElement),
],
);

$this->assertEquals(
self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement),
strval($extendableElement),
);
}


/**
*/
public function testUnmarshalling(): void
{
$extendableElement = ExtendableElement::fromXML(self::$xmlRepresentation->documentElement);

$this->assertEquals(
self::$xmlRepresentation->saveXML(self::$xmlRepresentation->documentElement),
strval($extendableElement),
);
}
}
13 changes: 0 additions & 13 deletions tests/XML/ExtendableElementTraitTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@
use SimpleSAML\XML\Constants as C;
use SimpleSAML\XML\DOMDocumentFactory;
use SimpleSAML\XML\ElementInterface;
use SimpleSAML\XML\TestUtils\SchemaValidationTestTrait;
use SimpleSAML\XML\TestUtils\SerializableElementTestTrait;

use function dirname;

Expand All @@ -27,9 +25,6 @@
*/
final class ExtendableElementTraitTest extends TestCase
{
use SerializableElementTestTrait;
use SchemaValidationTestTrait;

/** @var \SimpleSAML\XML\ElementInterface */
protected static ElementInterface $empty;

Expand All @@ -47,14 +42,6 @@ final class ExtendableElementTraitTest extends TestCase
*/
public static function setUpBeforeClass(): void
{
self::$schemaFile = dirname(__FILE__, 2) . '/resources/schemas/simplesamlphp.xsd';

self::$testedClass = ExtendableElement::class;

self::$xmlRepresentation = DOMDocumentFactory::fromFile(
dirname(__FILE__, 2) . '/resources/xml/ssp_ExtendableElement.xml',
);

self::$empty = new Chunk(DOMDocumentFactory::fromString(<<<XML
<chunk/>
XML
Expand Down

0 comments on commit 197cc98

Please sign in to comment.