rpcii-php/tests/ScopedServerTest.php
flashwave 93ec139171 Rename and a set of reworks.
- Aiwass -> RPCii
 - Swapped the meaning of "Procedure" and "Action"
 - IRpcActionHandler is now RpcHandler, abstract class no longer exists like Index
 - Anything suffixed by Trait is now suffixed by Common
 - All I prefixes on interfaces are gone
 - A PHP StreamWrapper implementation of HttpRequest added as a fallback for when cURL isnt installed
 - HttpRpcServer now hosts on /_rpcii instead of /_aiwass
 - Packagist package is now flashii/rpcii instead of flashwave/aiwass

That's probably all of it but I probably forgor.
2024-11-13 23:17:29 +00:00

42 lines
1.6 KiB
PHP

<?php
// ScopedServerTest.php
// Created: 2024-08-16
// Updated: 2024-11-13
declare(strict_types=1);
use PHPUnit\Framework\TestCase;
use PHPUnit\Framework\Attributes\{CoversClass,UsesClass};
use RPCii\Server\{HttpRpcServer,ScopedRpcServer};
#[CoversClass(ScopedRpcServer::class)]
#[UsesClass(HttpRpcServer::class)]
final class ScopedServerTest extends TestCase {
public function testServerScoping(): void {
$base = new HttpRpcServer;
$base->registerQueryProcedure('test', fn() => 'test');
$scopedToBeans = $base->scopeTo('beans:');
$scopedToBeans->registerQueryProcedure('test', fn() => 'test in beans');
$scopedToGarf = $base->scopeTo('garf:');
$scopedToGarfield = $scopedToGarf->scopeTo('ield:');
$scopedToGarfield->registerQueryProcedure('test', fn() => 'test in garfield');
$baseTest = $base->getProcedureInfo('test');
$this->assertNotNull($baseTest);
$this->assertEquals('test', $baseTest->getName());
$baseBeansTest = $base->getProcedureInfo('beans:test');
$scopedBeansTest = $scopedToBeans->getProcedureInfo('test');
$this->assertNotNull($baseBeansTest);
$this->assertSame($baseBeansTest, $scopedBeansTest);
$this->assertEquals('beans:test', $scopedBeansTest->getName());
$baseGarfieldTest = $base->getProcedureInfo('garf:ield:test');
$scopedGarfieldTest = $scopedToGarfield->getProcedureInfo('test');
$this->assertNotNull($baseGarfieldTest);
$this->assertSame($baseGarfieldTest, $scopedGarfieldTest);
$this->assertEquals('garf:ield:test', $scopedGarfieldTest->getName());
}
}