From bf82d1e2fd328a8278b10c5641dd75c15f5f4014 Mon Sep 17 00:00:00 2001 From: edalzell Date: Wed, 29 May 2024 15:33:29 -0700 Subject: [PATCH] tests --- tests/Assets/AssetContainerTest.php | 12 ++++++++++++ tests/Feature/Assets/StoreAssetTest.php | 12 ++++++++++++ 2 files changed, 24 insertions(+) diff --git a/tests/Assets/AssetContainerTest.php b/tests/Assets/AssetContainerTest.php index 40c2b53996..5e76b1794d 100644 --- a/tests/Assets/AssetContainerTest.php +++ b/tests/Assets/AssetContainerTest.php @@ -230,6 +230,18 @@ public function it_gets_and_sets_whether_downloading_is_allowed() $this->assertFalse($container->allowDownloading()); } + /** @test */ + public function it_gets_and_sets_the_validation_rules() + { + $container = new AssetContainer; + $this->assertNull($container->validation()); + + $return = $container->validation(['max:5120']); + + $this->assertEquals($container, $return); + $this->assertEquals(['max:5120'], $container->validation()); + } + /** @test */ public function it_gets_and_sets_glide_source_preset_for_upload_processing() { diff --git a/tests/Feature/Assets/StoreAssetTest.php b/tests/Feature/Assets/StoreAssetTest.php index 5c059e8243..acd11648ec 100644 --- a/tests/Feature/Assets/StoreAssetTest.php +++ b/tests/Feature/Assets/StoreAssetTest.php @@ -93,6 +93,18 @@ public function it_doesnt_upload_without_a_folder() ])->assertStatus(422); } + /** @test */ + public function it_doesnt_upload_when_validation_fails() + { + + $this->container->validation(['extensions:png'])->save(); + + $this + ->actingAs($this->userWithPermission()) + ->submit() + ->assertStatus(422); + } + private function submit($overrides = []) { return $this->postJson(cp_route('assets.store'), $this->validPayload($overrides));