Files
huangjingfen/pro_v3.5.1_副本/vendor/guzzlehttp/guzzle-services/tests/ParameterTest.php
apple 434aa8c69d feat(fsgx): 完成全部24项开发任务 Phase1-7
Phase1 后端核心:
- 新增 fsgx_v1.sql 迁移脚本(is_queue_goods/frozen_points/available_points/no_assess)
- SystemConfigServices 返佣设置扩展(周期人数/分档比例/范围/时机)
- StoreOrderCreateServices 周期循环佣金计算
- StoreOrderTakeServices 佣金发放后同步冻结积分
- StoreProductServices/StoreProduct 保存 is_queue_goods

Phase2 后端接口:
- GET /api/hjf/brokerage/progress 佣金周期进度
- GET /api/hjf/assets/overview 资产总览
- HjfPointsServices 每日 frozen_points 0.4‰ 释放定时任务
- PUT /adminapi/hjf/member/{uid}/no_assess 不考核接口
- GET /adminapi/hjf/points/release_log 积分日志接口

Phase3 前端清理:
- hjfCustom.js 路由精简(仅保留 points/log)
- hjfQueue.js/hjfMember.js API 清理/重定向至 CRMEB 原生接口
- pages.json 公排→推荐佣金/佣金记录/佣金规则

Phase4-5 前端改造:
- queue/status.vue 推荐佣金进度页整体重写
- 商品详情/订单确认/支付结果页文案与逻辑改造
- 个人中心/资产页/引导页/规则页文案改造
- HjfQueueProgress/HjfRefundNotice/HjfAssetCard 组件改造
- 推广中心嵌入佣金进度摘要
- hjfMockData.js 全量更新(公排字段→佣金字段)

Phase6 Admin 增强:
- 用户列表新增 frozen_points/available_points 列及不考核操作按钮
- hjfPoints.js USE_MOCK=false 对接真实积分日志接口

Phase7 配置文档:
- docs/fsgx-phase7-config-checklist.md 后台配置与全链路验收清单

Made-with: Cursor
2026-03-23 22:32:19 +08:00

374 lines
12 KiB
PHP
Executable File

<?php
namespace GuzzleHttp\Tests\Command\Guzzle;
use GuzzleHttp\Command\Guzzle\Description;
use GuzzleHttp\Command\Guzzle\Parameter;
use PHPUnit\Framework\TestCase;
/**
* @covers \GuzzleHttp\Command\Guzzle\Parameter
*/
class ParameterTest extends TestCase
{
protected $data = [
'name' => 'foo',
'type' => 'bar',
'required' => true,
'default' => '123',
'description' => '456',
'minLength' => 2,
'maxLength' => 5,
'location' => 'body',
'static' => true,
'filters' => ['trim', 'json_encode'],
];
public function testCreatesParamFromArray()
{
$p = new Parameter($this->data);
$this->assertEquals('foo', $p->getName());
$this->assertEquals('bar', $p->getType());
$this->assertTrue($p->isRequired());
$this->assertEquals('123', $p->getDefault());
$this->assertEquals('456', $p->getDescription());
$this->assertEquals(2, $p->getMinLength());
$this->assertEquals(5, $p->getMaxLength());
$this->assertEquals('body', $p->getLocation());
$this->assertTrue($p->isStatic());
$this->assertEquals(['trim', 'json_encode'], $p->getFilters());
$p->setName('abc');
$this->assertEquals('abc', $p->getName());
}
public function testValidatesDescription()
{
$this->expectException(\InvalidArgumentException::class);
new Parameter($this->data, ['description' => 'foo']);
}
public function testCanConvertToArray()
{
$p = new Parameter($this->data);
$this->assertEquals($this->data, $p->toArray());
}
public function testUsesStatic()
{
$d = $this->data;
$d['default'] = 'booboo';
$d['static'] = true;
$p = new Parameter($d);
$this->assertEquals('booboo', $p->getValue('bar'));
}
public function testUsesDefault()
{
$d = $this->data;
$d['default'] = 'foo';
$d['static'] = null;
$p = new Parameter($d);
$this->assertEquals('foo', $p->getValue(null));
}
public function testReturnsYourValue()
{
$d = $this->data;
$d['static'] = null;
$p = new Parameter($d);
$this->assertEquals('foo', $p->getValue('foo'));
}
public function testZeroValueDoesNotCauseDefaultToBeReturned()
{
$d = $this->data;
$d['default'] = '1';
$d['static'] = null;
$p = new Parameter($d);
$this->assertEquals('0', $p->getValue('0'));
}
public function testFiltersValues()
{
$d = $this->data;
$d['static'] = null;
$d['filters'] = 'strtoupper';
$p = new Parameter($d);
$this->assertEquals('FOO', $p->filter('foo'));
}
public function testRequiresServiceDescriptionForFormatting()
{
$this->expectExceptionMessage('No service description');
$this->expectException(\RuntimeException::class);
$d = $this->data;
$d['format'] = 'foo';
$p = new Parameter($d);
$p->filter('bar');
}
public function testConvertsBooleans()
{
$p = new Parameter(['type' => 'boolean']);
$this->assertEquals(true, $p->filter('true'));
$this->assertEquals(false, $p->filter('false'));
}
public function testUsesArrayByDefaultForFilters()
{
$d = $this->data;
$d['filters'] = null;
$p = new Parameter($d);
$this->assertEquals([], $p->getFilters());
}
public function testAllowsSimpleLocationValue()
{
$p = new Parameter(['name' => 'myname', 'location' => 'foo', 'sentAs' => 'Hello']);
$this->assertEquals('foo', $p->getLocation());
$this->assertEquals('Hello', $p->getSentAs());
}
public function testParsesTypeValues()
{
$p = new Parameter(['type' => 'foo']);
$this->assertEquals('foo', $p->getType());
}
public function testValidatesComplexFilters()
{
$this->expectExceptionMessage('A [method] value must be specified for each complex filter');
$this->expectException(\InvalidArgumentException::class);
$p = new Parameter(['filters' => [['args' => 'foo']]]);
}
public function testAllowsComplexFilters()
{
$that = $this;
$param = new Parameter([
'filters' => [
[
'method' => function ($a, $b, $c, $d) use ($that, &$param) {
$that->assertEquals('test', $a);
$that->assertEquals('my_value!', $b);
$that->assertEquals('bar', $c);
$that->assertSame($param, $d);
return 'abc'.$b;
},
'args' => ['test', '@value', 'bar', '@api'],
],
],
]);
$this->assertEquals('abcmy_value!', $param->filter('my_value!'));
}
public function testAddsAdditionalProperties()
{
$p = new Parameter([
'type' => 'object',
'additionalProperties' => ['type' => 'string'],
]);
$this->assertInstanceOf('GuzzleHttp\Command\Guzzle\Parameter', $p->getAdditionalProperties());
$this->assertNull($p->getAdditionalProperties()->getAdditionalProperties());
$p = new Parameter(['type' => 'object']);
$this->assertTrue($p->getAdditionalProperties());
}
public function testAddsItems()
{
$p = new Parameter([
'type' => 'array',
'items' => ['type' => 'string'],
]);
$this->assertInstanceOf('GuzzleHttp\Command\Guzzle\Parameter', $p->getItems());
$out = $p->toArray();
$this->assertEquals('array', $out['type']);
$this->assertIsArray($out['items']);
}
public function testCanRetrieveKnownPropertiesUsingDataMethod()
{
$p = new Parameter(['data' => ['name' => 'test'], 'extra' => 'hi!']);
$this->assertEquals('test', $p->getData('name'));
$this->assertEquals(['name' => 'test'], $p->getData());
$this->assertNull($p->getData('fjnweefe'));
$this->assertEquals('hi!', $p->getData('extra'));
}
public function testHasPattern()
{
$p = new Parameter(['pattern' => '/[0-9]+/']);
$this->assertEquals('/[0-9]+/', $p->getPattern());
}
public function testHasEnum()
{
$p = new Parameter(['enum' => ['foo', 'bar']]);
$this->assertEquals(['foo', 'bar'], $p->getEnum());
}
public function testSerializesItems()
{
$p = new Parameter([
'type' => 'object',
'additionalProperties' => ['type' => 'string'],
]);
$this->assertEquals([
'type' => 'object',
'additionalProperties' => ['type' => 'string'],
], $p->toArray());
}
public function testResolvesRefKeysRecursively()
{
$description = new Description([
'models' => [
'JarJar' => ['type' => 'string', 'default' => 'Mesa address tha senate!'],
'Anakin' => ['type' => 'array', 'items' => ['$ref' => 'JarJar']],
],
]);
$p = new Parameter(['$ref' => 'Anakin', 'description' => 'added'], ['description' => $description]);
$this->assertEquals([
'description' => 'added',
'$ref' => 'Anakin',
], $p->toArray());
}
public function testResolvesExtendsRecursively()
{
$jarJar = ['type' => 'string', 'default' => 'Mesa address tha senate!', 'description' => 'a'];
$anakin = ['type' => 'array', 'items' => ['extends' => 'JarJar', 'description' => 'b']];
$description = new Description([
'models' => ['JarJar' => $jarJar, 'Anakin' => $anakin],
]);
// Description attribute will be updated, and format added
$p = new Parameter(['extends' => 'Anakin', 'format' => 'date'], ['description' => $description]);
$this->assertEquals([
'format' => 'date',
'extends' => 'Anakin',
], $p->toArray());
}
public function testHasKeyMethod()
{
$p = new Parameter(['name' => 'foo', 'sentAs' => 'bar']);
$this->assertEquals('bar', $p->getWireName());
}
public function testIncludesNameInToArrayWhenItemsAttributeHasName()
{
$p = new Parameter([
'type' => 'array',
'name' => 'Abc',
'items' => [
'name' => 'Foo',
'type' => 'object',
],
]);
$result = $p->toArray();
$this->assertEquals([
'type' => 'array',
'name' => 'Abc',
'items' => [
'name' => 'Foo',
'type' => 'object',
],
], $result);
}
public function dateTimeProvider()
{
$d = 'October 13, 2012 16:15:46 UTC';
return [
[$d, 'date-time', '2012-10-13T16:15:46Z'],
[$d, 'date', '2012-10-13'],
[$d, 'timestamp', strtotime($d)],
[new \DateTime($d), 'timestamp', strtotime($d)],
];
}
/**
* @dataProvider dateTimeProvider
*/
public function testAppliesFormat($d, $format, $result)
{
$p = new Parameter(['format' => $format], ['description' => new Description([])]);
$this->assertEquals($format, $p->getFormat());
$this->assertEquals($result, $p->filter($d));
}
public function testHasMinAndMax()
{
$p = new Parameter([
'minimum' => 2,
'maximum' => 3,
'minItems' => 4,
'maxItems' => 5,
]);
$this->assertEquals(2, $p->getMinimum());
$this->assertEquals(3, $p->getMaximum());
$this->assertEquals(4, $p->getMinItems());
$this->assertEquals(5, $p->getMaxItems());
}
public function testHasProperties()
{
$data = [
'type' => 'object',
'properties' => [
'foo' => ['type' => 'string'],
'bar' => ['type' => 'string'],
],
];
$p = new Parameter($data);
$this->assertInstanceOf('GuzzleHttp\\Command\\Guzzle\\Parameter', $p->getProperty('foo'));
$this->assertSame($p->getProperty('foo'), $p->getProperty('foo'));
$this->assertNull($p->getProperty('wefwe'));
$properties = $p->getProperties();
$this->assertIsArray($properties);
foreach ($properties as $prop) {
$this->assertInstanceOf('GuzzleHttp\\Command\\Guzzle\\Parameter', $prop);
}
$this->assertEquals($data, $p->toArray());
}
public function testThrowsWhenNotPassString()
{
$this->expectExceptionMessage('Expected a string. Got: array');
$this->expectException(\InvalidArgumentException::class);
$emptyParam = new Parameter();
$this->assertFalse($emptyParam->has([]));
$this->assertFalse($emptyParam->has(new \stdClass()));
$this->assertFalse($emptyParam->has('1'));
$this->assertFalse($emptyParam->has(1));
}
public function testHasReturnsFalseForWrongOrEmptyValues()
{
$emptyParam = new Parameter();
$this->assertFalse($emptyParam->has(''));
$this->assertFalse($emptyParam->has('description'));
$this->assertFalse($emptyParam->has('noExisting'));
}
public function testHasReturnsTrueForCorrectValues()
{
$p = new Parameter([
'minimum' => 2,
'maximum' => 3,
'minItems' => 4,
'maxItems' => 5,
]);
$this->assertTrue($p->has('minimum'));
$this->assertTrue($p->has('maximum'));
$this->assertTrue($p->has('minItems'));
$this->assertTrue($p->has('maxItems'));
}
}