diff --git a/tests/ServerTest.php b/tests/ServerTest.php index 400163fd..9bdfbe6e 100644 --- a/tests/ServerTest.php +++ b/tests/ServerTest.php @@ -70,6 +70,10 @@ public function testGetSourcePathWithBaseUrl() { $this->server->setBaseUrl('img/'); $this->assertEquals('image.jpg', $this->server->getSourcePath('img/image.jpg')); + + // Test for a bug where if the path starts with the same substring as the base url, the source + // path would trim the base url off the filename. eg, the following would've returned 'ur.jpg' + $this->assertEquals('imgur.jpg', $this->server->getSourcePath('imgur.jpg')); } public function testGetSourcePathWithPrefix() @@ -78,16 +82,6 @@ public function testGetSourcePathWithPrefix() $this->assertEquals('img/image.jpg', $this->server->getSourcePath('image.jpg')); } - public function testGetsSourcePathWithBaseUrl() - { - $this->server->setBaseUrl('img/'); - $this->assertEquals('image.jpg', $this->server->getSourcePath('image.jpg')); - - // Test for a bug where if the path starts with the same substring as the base url, the source - // path would trim the base url off the filename. eg, the following would've returned 'ur.jpg' - $this->assertEquals('imgur.jpg', $this->server->getSourcePath('imgur.jpg')); - } - public function testGetSourcePathWithMissingPath() { $this->setExpectedException( @@ -198,34 +192,34 @@ public function testGetCachePathWithSourcePrefix() $this->server->setSourcePathPrefix('img/'); $this->assertEquals('image.jpg/75094881e9fd2b93063d6a5cb083091c', $this->server->getCachePath('image.jpg', [])); } - + public function testGetCachePathWithExtension() { $this->server->setCacheWithFileExtensions(true); $this->assertEquals('image.jpg/75094881e9fd2b93063d6a5cb083091c.jpg', $this->server->getCachePath('image.jpg', [])); } - + public function testGetCachePathWithExtensionAndFmParam() { $this->server->setCacheWithFileExtensions(true); $this->assertEquals('image.jpg/eb6091e07fb06219634a3c82afb88239.gif', $this->server->getCachePath('image.jpg', ['fm' => 'gif'])); } - + public function testGetCachePathWithExtensionAndFmFromDefaults() { $this->server->setCacheWithFileExtensions(true); $this->server->setDefaults(['fm' => 'gif']); $this->assertEquals('image.jpg/eb6091e07fb06219634a3c82afb88239.gif', $this->server->getCachePath('image.jpg', [])); } - + public function testGetCachePathWithExtensionAndFmFromPreset() { $this->server->setCacheWithFileExtensions(true); - + $this->server->setPresets(['gif' => [ - 'fm' => 'gif' + 'fm' => 'gif', ]]); - + $this->assertEquals('image.jpg/eb6091e07fb06219634a3c82afb88239.gif', $this->server->getCachePath('image.jpg', ['p' => 'gif'])); }