Skip to content

Commit

Permalink
Merge pull request #29 from tattersoftware/export-test
Browse files Browse the repository at this point in the history
Add export test
  • Loading branch information
MGatner authored May 21, 2021
2 parents 0ee8595 + db0b20b commit 3085b77
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions tests/unit/ControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

use CodeIgniter\Config\Config;
use CodeIgniter\Files\Exceptions\FileNotFoundException;
use CodeIgniter\HTTP\DownloadResponse;
use CodeIgniter\Test\ControllerTestTrait;
use Tatter\Files\Controllers\Files;
use Tatter\Files\Entities\File;
Expand Down Expand Up @@ -229,4 +230,19 @@ public function humanize()
$result = $controller->display();
$this->assertStringContainsString($file->filename, $result);
}

//--------------------------------------------------------------------

public function testExportCreatesRecord()
{
$file = fake(FileFaker::class, [
'localname' => 'image.jpg',
]);

$this->controller(Files::class);
$result = $this->execute('export', 'download', $file->id);

$this->assertInstanceOf(DownloadResponse::class, $result->response());
$this->seeInDatabase('exports', ['file_id' => $file->id]);
}
}

0 comments on commit 3085b77

Please sign in to comment.