mirror of
http://124.126.16.154:8888/singularity/HyperfDevelopmentKitCore.git
synced 2026-01-15 07:15:06 +08:00
46 lines
1.3 KiB
PHP
46 lines
1.3 KiB
PHP
<?php
|
|
/**
|
|
* ExtendServiceTest.php@HDK-Core
|
|
*
|
|
* @author 李东云 <Dongyun.Li@LuxCreo.Ai>
|
|
* Powered by PhpStorm
|
|
* Created on 2022/12/20
|
|
*/
|
|
|
|
namespace Singularity\HDK\Test\Core\Unit;
|
|
|
|
use Hyperf\Utils\ApplicationContext;
|
|
use Singularity\HDK\Core\Service\ExtendService;
|
|
use Singularity\HDK\Core\Service\UtilsService;
|
|
|
|
/** @var ExtendService $service */
|
|
$service = make(ExtendService::class, ['utils' => new UtilsService()]);
|
|
it('asserts query parameters can be parsed.', function () use ($service) {
|
|
$result = $service->parse(
|
|
null,
|
|
[
|
|
'id' => 5,
|
|
'extends' => 'a,b',
|
|
]
|
|
);
|
|
expect($result)->toBeArray()->toHaveCount(2)->toBe(['a', 'b']);
|
|
});
|
|
|
|
it('asserts has extends', function () use ($service) {
|
|
expect($service->hasExtends())->toBeTrue();
|
|
});
|
|
|
|
it('asserts has specify extend', function () use ($service) {
|
|
expect($service->hasExtend('a'))->toBeTrue()
|
|
->and($service->hasExtend('b'))->toBeTrue()
|
|
->and($service->hasExtend('c'))->toBeFalse();
|
|
})->depends('it asserts query parameters can be parsed.');
|
|
|
|
it('asserts parsed extends', function () use ($service) {
|
|
$extends = $service->getExtends();
|
|
expect($extends)->toBeArray()->toMatchArray([
|
|
'a',
|
|
'b',
|
|
]);
|
|
})->depends('it asserts query parameters can be parsed.');
|