|
|
@@ -163,6 +163,33 @@ class ActivityCatalogTest extends TestCase
|
|
|
$this->assertSame(0, DB::table('activity_reward_recipients')->count());
|
|
|
}
|
|
|
|
|
|
+ public function test_removed_banners_are_not_required_saved_or_returned_and_images_remain(): void
|
|
|
+ {
|
|
|
+ $input = $this->form(); unset($input['detail_banner'], $input['pc_banner']);
|
|
|
+ $this->request('submit', $input, 'POST');
|
|
|
+ $body = (new AdminActivityReward())->store()->getData(true);
|
|
|
+ $this->assertSame(HttpStatus::OK, $body['code']);
|
|
|
+ $id = (int) DB::table('activity_rewards')->value('id');
|
|
|
+ $this->assertSame('', DB::table('activity_rewards')->where('id', $id)->value('detail_banner'));
|
|
|
+ $this->assertSame('', DB::table('activity_rewards')->where('id', $id)->value('pc_banner'));
|
|
|
+ $this->assertSame('/app.png', DB::table('activity_rewards')->where('id', $id)->value('detail_image'));
|
|
|
+ $this->assertSame('/pc.png', DB::table('activity_rewards')->where('id', $id)->value('pc_image'));
|
|
|
+ DB::table('activity_rewards')->where('id', $id)->update(['detail_banner' => '/old.png', 'pc_banner' => '/old-pc.png']);
|
|
|
+ $body = $this->save(['id' => $id, 'detail_banner' => ['ignored legacy input'], 'pc_banner' => ['ignored legacy input']]);
|
|
|
+ $this->assertSame(HttpStatus::OK, $body['code']);
|
|
|
+ $this->assertSame('/old.png', DB::table('activity_rewards')->where('id', $id)->value('detail_banner'));
|
|
|
+ $this->assertSame('/old-pc.png', DB::table('activity_rewards')->where('id', $id)->value('pc_banner'));
|
|
|
+ foreach (['detail_image', 'pc_image'] as $required) {
|
|
|
+ $missing = $this->form(['id' => $id]); unset($missing[$required]);
|
|
|
+ $this->request('submit', $missing, 'POST');
|
|
|
+ $this->assertSame(HttpStatus::CUSTOM_ERROR, (new AdminActivityReward())->store()->getData(true)['code']);
|
|
|
+ }
|
|
|
+ foreach ([ActivityReward::findOrFail($id)->toArray(), $this->listing()['data'][0]] as $row) {
|
|
|
+ $this->assertArrayNotHasKey('detail_banner', $row); $this->assertArrayNotHasKey('pc_banner', $row);
|
|
|
+ $this->assertArrayHasKey('detail_image', $row); $this->assertArrayHasKey('pc_image', $row);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
public function test_activity_click_behavior_saves_preserves_and_clears_for_normal_and_type_two_activities(): void
|
|
|
{
|
|
|
$this->request('options');
|