Skip to content

Commit 6b36008

Browse files
committed
Add AbstractTestContainer class
1 parent 35ae212 commit 6b36008

File tree

3 files changed

+43
-1
lines changed

3 files changed

+43
-1
lines changed

composer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@
1212
],
1313
"autoload": {
1414
"psr-4": {
15-
"SimpleSAML\\TestUtils\\": "lib/"
15+
"SimpleSAML\\TestUtils\\": "lib/",
16+
"SimpleSAML\\TestUtils\\": "src/"
1617
}
1718
},
1819
"autoload-dev": {

src/AbstractTestContainer.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace SimpleSAML\TestUtils;
6+
7+
/**
8+
* Class \SimpleSAML\TestUtils\AbstractTestContainer
9+
*/
10+
abstract class AbstractTestContainer
11+
{
12+
}

src/TestContainerSingleton.php

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace SimpleSAML\TestUtils;
6+
7+
use SimpleSAML\XML\Assert\Assert;
8+
9+
/**
10+
* Class \SimpleSAML\TestUtils\TestContainerSingleton
11+
*/
12+
final class TestContainerSingleton
13+
{
14+
protected static AbstractTestContainer $testContainer;
15+
16+
17+
/** Set a container to use. */
18+
public static function setContainer(AbstractTestContainer $testContainer): void
19+
{
20+
self::$testContainer = $testContainer;
21+
}
22+
23+
24+
public static function getContainer(): AbstractTestContainer
25+
{
26+
Assert::notNull(self::$testContainer, 'No container set.');
27+
return self::$testContainer;
28+
}
29+
}

0 commit comments

Comments
 (0)