Skip to content

Commit 23e4993

Browse files
author
Marcin Morawski
committed
Test for downloading picsum image
1 parent 93b340a commit 23e4993

1 file changed

Lines changed: 17 additions & 2 deletions

File tree

test/Faker/PicsumProviderTest.php

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,23 @@ public function testPicsumUrlAddsARandomGetParameterByDefault()
8989
$this->assertRegexp('#random=\d{5}#', $splitUrl[1]);
9090
}
9191

92+
public function testPicsumDownloadWithDefaults()
93+
{
94+
$file = PicsumProvider::picsum(sys_get_temp_dir());
95+
$this->assertFileExists($file);
96+
if (function_exists('getimagesize')) {
97+
list($width, $height, $type) = getimagesize($file);
98+
$this->assertEquals(640, $width);
99+
$this->assertEquals(480, $height);
100+
$this->assertEquals(constant('IMAGETYPE_JPEG'), $type);
101+
} else {
102+
$this->assertEquals('jpg', pathinfo($file, PATHINFO_EXTENSION));
103+
}
104+
if (file_exists($file)) {
105+
unlink($file);
106+
}
107+
}
108+
92109
/**
93110
* @dataProvider picusmImageExtensionsProvider
94111
*/
@@ -100,8 +117,6 @@ public function testPicsumDownloadWithExtension($extension)
100117
list($width, $height) = getimagesize($file);
101118
$this->assertEquals(640, $width);
102119
$this->assertEquals(480, $height);
103-
} else {
104-
$this->assertEquals('jpg', pathinfo($file, PATHINFO_EXTENSION));
105120
}
106121
$this->assertEquals($extension, pathinfo($file, PATHINFO_EXTENSION));
107122
if (file_exists($file)) {

0 commit comments

Comments
 (0)