Cerys
4 weeks ago
7 changed files with 62 additions and 3 deletions
@ -0,0 +1,10 @@ |
|||||
|
<phpunit |
||||
|
colors="true" |
||||
|
bootstrap="tests/bootstrap.php" |
||||
|
> |
||||
|
<testsuites> |
||||
|
<testsuite name="Darksparrow/AuxiliumSchemaBuilder Tests"> |
||||
|
<directory>tests</directory> |
||||
|
</testsuite> |
||||
|
</testsuites> |
||||
|
</phpunit> |
@ -0,0 +1,24 @@ |
|||||
|
<?php |
||||
|
|
||||
|
namespace Darksparrow\AuxiliumSchemaBuilder\Utilities; |
||||
|
|
||||
|
use Darksparrow\AuxiliumSchemaBuilder\Attributes\SchemaDocument; |
||||
|
use ReflectionClass; |
||||
|
|
||||
|
class URLHandling |
||||
|
{ |
||||
|
public static string $URLBase = "https://schemas.auxiliumsoftware.co.uk/v1/"; |
||||
|
public static function GetURLForSchema(string $targetSchemaClassName): string |
||||
|
{ |
||||
|
$reflection = new ReflectionClass(new $targetSchemaClassName()); |
||||
|
foreach($reflection->getAttributes() as $attribute) |
||||
|
{ |
||||
|
if($attribute->getName() === SchemaDocument::class) |
||||
|
{ |
||||
|
$name = $attribute->getArguments()["Name"]; |
||||
|
return self::$URLBase . $name . ".json"; |
||||
|
} |
||||
|
} |
||||
|
die(); |
||||
|
} |
||||
|
} |
@ -0,0 +1,20 @@ |
|||||
|
<?php |
||||
|
|
||||
|
require_once __DIR__ . "/../examples/Schemas/Message.php"; |
||||
|
require_once __DIR__ . "/../examples/Schemas/Organisation.php"; |
||||
|
|
||||
|
use Darksparrow\AuxiliumSchemaBuilder\Examples\SchemaBuilder\Schemas\Message; |
||||
|
use Darksparrow\AuxiliumSchemaBuilder\Utilities\URLHandling; |
||||
|
use PHPUnit\Framework\TestCase; |
||||
|
|
||||
|
final class SchemaURITest extends TestCase |
||||
|
{ |
||||
|
public function test0() |
||||
|
{ |
||||
|
URLHandling::$URLBase = "https://schemas.auxiliumsoftware.co.uk/v1/"; |
||||
|
self::assertEquals( |
||||
|
expected: "https://schemas.auxiliumsoftware.co.uk/v1/message.json", |
||||
|
actual: URLHandling::GetURLForSchema(Message::class), |
||||
|
); |
||||
|
} |
||||
|
} |
@ -0,0 +1,3 @@ |
|||||
|
<?php |
||||
|
|
||||
|
namespace tests; |
Loading…
Reference in new issue