product photos controller test fixes, test out

This commit is contained in:
2025-08-11 23:35:46 -07:00
parent 3a47f09e8c
commit 0181c48907
3 changed files with 50 additions and 32 deletions

View File

@@ -273,17 +273,19 @@ class ProductPhotosControllerTest extends BaseControllerTest
$id,
];
$data = [
// test new data here
'enabled' => 1,
'primary_photo' => 1,
'photo_position' => 999,
];
// $this->put($url, $data);
$this->put($url, $data);
$this->assertResponseCode(302);
$this->assertRedirectContains('product-photos');
$after = $this->ProductPhotos->get($id);
$this->assertEquals($data['photo_position'], $after->photo_position);
$this->assertTrue($after->primary_photo);
$this->assertTrue($after->enabled);
// assert saved properly below
}
@@ -308,10 +310,16 @@ class ProductPhotosControllerTest extends BaseControllerTest
'action' => 'edit',
$id,
];
$data = [];
$data = [
'enabled' => 1,
'primary_photo' => 1,
'photo_position' => 'not-valid',
];
$this->put($url, $data);
$this->assertResponseCode(200);
$after = $this->ProductPhotos->get($id);
$this->assertEquals($before->modified, $after->modified);
$this->assertEquals($before->photo_position, $after->photo_position);
// assert save failed below
}