feat(miniapi): add Android visa catalog endpoints
This commit is contained in:
4
tests/bootstrap.php
Normal file
4
tests/bootstrap.php
Normal file
@@ -0,0 +1,4 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
require dirname(__DIR__) . '/vendor/autoload.php';
|
||||
60
tests/unit/AppCatalogServiceTest.php
Normal file
60
tests/unit/AppCatalogServiceTest.php
Normal file
@@ -0,0 +1,60 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace tests\unit;
|
||||
|
||||
use app\miniapi\service\Product\AppCatalogService;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
final class AppCatalogServiceTest extends TestCase
|
||||
{
|
||||
public function testCatalogKeepsServerPriceTextAndSellableFlag(): void
|
||||
{
|
||||
$items = (new AppCatalogService())->normalize([
|
||||
[
|
||||
'id' => 'evus',
|
||||
'name' => '美国 EVUS',
|
||||
'price_display' => '¥299',
|
||||
'sellable' => true,
|
||||
],
|
||||
]);
|
||||
|
||||
self::assertSame('¥299', $items[0]['price_display']);
|
||||
self::assertTrue($items[0]['sellable']);
|
||||
}
|
||||
|
||||
public function testCatalogDerivesCheapestPriceFromExistingPackages(): void
|
||||
{
|
||||
$items = (new AppCatalogService())->normalize([
|
||||
[
|
||||
'id' => 'evus',
|
||||
'name' => '美国 EVUS',
|
||||
'packages' => [
|
||||
['value' => '49900', 'name' => '加急登记'],
|
||||
['value' => '29900', 'name' => '标准登记'],
|
||||
],
|
||||
],
|
||||
]);
|
||||
|
||||
self::assertSame('¥299', $items[0]['price_display']);
|
||||
self::assertSame('¥499', $items[0]['packages'][0]['price_display']);
|
||||
self::assertTrue($items[0]['sellable']);
|
||||
}
|
||||
|
||||
public function testCatalogUsesPackagesForMatchingProductOnly(): void
|
||||
{
|
||||
$items = (new AppCatalogService())->build(
|
||||
[
|
||||
['id' => 'evus', 'name' => '美国 EVUS'],
|
||||
['id' => 'korea', 'name' => '韩国电子签'],
|
||||
],
|
||||
[
|
||||
'evus' => [['value' => '29900', 'name' => '标准登记']],
|
||||
],
|
||||
);
|
||||
|
||||
self::assertTrue($items[0]['sellable']);
|
||||
self::assertFalse($items[1]['sellable']);
|
||||
self::assertSame([], $items[1]['packages']);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user