upload test passing + file not getting deleted every time - well it is but we now use a copy lol
This commit is contained in:
@@ -162,8 +162,16 @@ class ProductPhotosControllerTest extends BaseControllerTest
|
||||
'controller' => 'ProductPhotos',
|
||||
'action' => 'add',
|
||||
];
|
||||
$file = Configure::readOrFail('App.paths.testWebroot') . 'images' . DS . 'cake_icon.png';
|
||||
$toUseFile = Configure::readOrFail('App.paths.testWebroot') . 'images' . DS . 'cake_icon_copy.png';
|
||||
if (!file_exists($file)) {
|
||||
$this->fail('Test image did not exist');
|
||||
}
|
||||
if (!copy($file, $toUseFile)) {
|
||||
$this->fail('Failed to copy test image');
|
||||
}
|
||||
$image = new UploadedFile(
|
||||
Configure::readOrFail('App.paths.webroot') . 'images' . DS . 'cake_icon.png', // stream or path to file representing the temp file
|
||||
$toUseFile, // stream or path to file representing the temp file
|
||||
12345, // the filesize in bytes
|
||||
UPLOAD_ERR_OK, // the upload/error status
|
||||
'cake_icon.png', // the filename as sent by the client
|
||||
@@ -209,7 +217,8 @@ class ProductPhotosControllerTest extends BaseControllerTest
|
||||
'controller' => 'ProductPhotos',
|
||||
'action' => 'add',
|
||||
];
|
||||
$data = [];
|
||||
$data = [
|
||||
];
|
||||
$this->post($url, $data);
|
||||
$this->assertResponseCode(200);
|
||||
|
||||
|
||||
@@ -48,6 +48,7 @@ Configure::write('App', [
|
||||
'namespace' => 'TestApp',
|
||||
'encoding' => 'UTF-8',
|
||||
'paths' => [
|
||||
'testWebroot' => PLUGIN_ROOT . DS . 'tests' . DS . 'test_app' . DS . 'webroot' . DS,
|
||||
'webroot' => PLUGIN_ROOT . DS . 'webroot' . DS,
|
||||
'templates' => [
|
||||
PLUGIN_ROOT . DS . 'tests' . DS . 'test_app' . DS . 'templates' . DS,
|
||||
|
||||
BIN
tests/test_app/webroot/images/cake_icon.png
Normal file
BIN
tests/test_app/webroot/images/cake_icon.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 943 B |
Reference in New Issue
Block a user