diff --git a/src/Eloquent/Image.php b/src/Eloquent/Image.php index d4cf5c8..55ae639 100644 --- a/src/Eloquent/Image.php +++ b/src/Eloquent/Image.php @@ -208,9 +208,6 @@ public function isFullyRemoved() public function remove() { - if ($this->path == '') { - throw new \RuntimeException('Called remove on an image that has no path'); - } $this->exists = false; $this->flush = true; $this->removeAtPathOnFlush = $this->path; @@ -286,4 +283,4 @@ public function __clone() { $this->metadata = clone $this->metadata; } -} \ No newline at end of file +} diff --git a/tests/Unit/Eloquent/ImageTest.php b/tests/Unit/Eloquent/ImageTest.php new file mode 100644 index 0000000..79f885f --- /dev/null +++ b/tests/Unit/Eloquent/ImageTest.php @@ -0,0 +1,44 @@ +make(Kernel::class)->bootstrap(); + } + + public function testRemoveCanBeCalledMultipleTimes() + { + $foo = new TestAssets\FooModel(); + $foo->image->setStateProperties([ + 'path' => 'foo/bar.jpg', + 'extension' => 'jpg', + 'width' => 1, + 'height' => 1, + 'hash' => '1234', + 'timestamp' => 12345, + 'metadata' => [] + ]); + $foo->image->remove(); + $foo->image->remove(); + + $expected = [ + "path" => "", + "extension" => "", + "width" => null, + "height" => null, + "hash" => "", + "timestamp" => 0, + "metadata" => [] + ]; + + $this->assertSame($expected, $foo->image->getStateProperties()); + } +} +