Skip to content

Commit 3085b77

Browse files
authored
Merge pull request #29 from tattersoftware/export-test
Add export test
2 parents 0ee8595 + db0b20b commit 3085b77

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

tests/unit/ControllerTest.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
use CodeIgniter\Config\Config;
44
use CodeIgniter\Files\Exceptions\FileNotFoundException;
5+
use CodeIgniter\HTTP\DownloadResponse;
56
use CodeIgniter\Test\ControllerTestTrait;
67
use Tatter\Files\Controllers\Files;
78
use Tatter\Files\Entities\File;
@@ -229,4 +230,19 @@ public function humanize()
229230
$result = $controller->display();
230231
$this->assertStringContainsString($file->filename, $result);
231232
}
233+
234+
//--------------------------------------------------------------------
235+
236+
public function testExportCreatesRecord()
237+
{
238+
$file = fake(FileFaker::class, [
239+
'localname' => 'image.jpg',
240+
]);
241+
242+
$this->controller(Files::class);
243+
$result = $this->execute('export', 'download', $file->id);
244+
245+
$this->assertInstanceOf(DownloadResponse::class, $result->response());
246+
$this->seeInDatabase('exports', ['file_id' => $file->id]);
247+
}
232248
}

0 commit comments

Comments
 (0)