paymentCycle(7)->create([ 'contact' => '张三', 'phone' => '13800138000', 'address' => '幸福路 1 号', ]); $this->actingAsMiniStore($store); $this->getJson('/mini/store/info') ->assertOk() ->assertJsonPath('success', true) ->assertJsonPath('data.id', $store->id) ->assertJsonPath('data.contact', '张三') ->assertJsonPath('data.phone', '13800138000') ->assertJsonPath('data.address', '幸福路 1 号') ->assertJsonPath('data.payment_cycle_days', 7); } /** 修改门店信息:联系人 / 电话 / 地址 */ public function test_update_info(): void { $store = StoreModel::factory()->create(); $this->actingAsMiniStore($store); $this->putJson('/mini/store/info', [ 'contact' => '李四', 'phone' => '13900139000', 'address' => '建设路 88 号', ]) ->assertOk() ->assertJsonPath('success', true) ->assertJsonPath('data.contact', '李四') ->assertJsonPath('data.phone', '13900139000') ->assertJsonPath('data.address', '建设路 88 号'); $store->refresh(); $this->assertSame('李四', $store->contact); $this->assertSame('13900139000', $store->phone); $this->assertSame('建设路 88 号', $store->address); } /** 白名单更新:名称 / 编码 / 回款周期等字段提交后被忽略 */ public function test_update_info_ignores_readonly_fields(): void { $store = StoreModel::factory()->paymentCycle(5)->create([ 'name' => '原门店', 'code' => 'ST100', ]); $this->actingAsMiniStore($store); $this->putJson('/mini/store/info', [ 'contact' => '王五', 'name' => '改名门店', 'code' => 'HACK', 'payment_cycle_days' => 99, ]) ->assertOk() ->assertJsonPath('success', true); $store->refresh(); $this->assertSame('王五', $store->contact); $this->assertSame('原门店', $store->name); $this->assertSame('ST100', $store->code); $this->assertSame(5, $store->payment_cycle_days); } /** 停用门店 → 拒绝访问 */ public function test_disabled_store_rejected(): void { $store = StoreModel::factory()->disabled()->create(); $this->actingAsMiniStore($store); $this->getJson('/mini/store/info') ->assertOk() ->assertJsonPath('success', false) ->assertJsonPath('msg', '账号不存在或已被停用'); $this->putJson('/mini/store/info', ['contact' => '路人']) ->assertOk() ->assertJsonPath('success', false); } /** 字段长度校验:联系人超过 50 字符 → 校验失败 */ public function test_update_info_validates_length(): void { $store = StoreModel::factory()->create(); $this->actingAsMiniStore($store); $this->putJson('/mini/store/info', ['contact' => str_repeat('长', 51)]) ->assertOk() ->assertJsonPath('success', false) ->assertJsonPath('msg', '联系人最长 50 个字符'); $this->assertSame($store->contact, $store->refresh()->contact, '校验失败不应落库'); } }