Skip to content

Add upload testing - #157

Merged
kenjis merged 3 commits into
masterfrom
upload
Dec 8, 2016
Merged

Add upload testing#157
kenjis merged 3 commits into
masterfrom
upload

Conversation

@kenjis

@kenjis kenjis commented Dec 6, 2016

Copy link
Copy Markdown
Owner

This PR enables you can write tests for file uploading like this:

class Upload_test extends TestCase
{
	public function test_post_do_upload()
	{
		$filename = 'ci-phpuni-test-downloads-777.png';
		$filepath = APPPATH.'tests/fixtures/'.$filename;

		$files = [
			'userfile' => [
				'name'     => $filename,
				'type'     => 'image/png',
				'tmp_name' => $filepath,
			],
		];
		$this->request->setFiles($files);
		$output = $this->request('POST', 'upload/do_upload');
		$this->assertContains('<h3>Your file was successfully uploaded!</h3>', $output);
	}
}

See https://github.com/kenjis/ci-app-for-ci-phpunit-test/blob/master/application/tests/controllers/Upload_test.php.

[ci skip]
[ci skip]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant