-
Notifications
You must be signed in to change notification settings - Fork 163
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#2766 respect caldera_forms_upload_directory when uploading cf2 file …
…field file
- Loading branch information
Josh Pollock
committed
Oct 25, 2018
1 parent
d215155
commit 757fbce
Showing
9 changed files
with
197 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
<?php | ||
|
||
namespace calderawp\calderaforms\Tests\Integration\Handlers; | ||
|
||
use calderawp\calderaforms\cf2\Fields\Handlers\Cf1FileUploader; | ||
use calderawp\calderaforms\Tests\Integration\TestCase; | ||
|
||
class Cf1FileUploaderTest extends TestCase | ||
{ | ||
protected $test_file; | ||
|
||
|
||
public function setUp() | ||
{ | ||
$orig_file = __DIR__ . '/screenshot.jpeg'; | ||
$this->test_file = '/tmp/screenshot.jpg'; | ||
copy($orig_file, $this->test_file); | ||
parent::setUp(); | ||
} | ||
|
||
|
||
/** | ||
* | ||
* @since 1.8.0 | ||
* | ||
* @covers \calderawp\calderaforms\cf2\Fields\Handlers\Cf1FileUploader::upload() | ||
* | ||
* @group file | ||
*/ | ||
public function testUpload() | ||
{ | ||
$file = [ | ||
'file' => file_get_contents($this->test_file), | ||
'name' => 'screenshot.jpeg', | ||
'size' => filesize($this->test_file), | ||
'tmp_name' => $this->test_file, | ||
]; | ||
$uploadArgs = [ | ||
'private' => true, | ||
'field_id' => 'fld1', | ||
'form_id' => 'cf1' | ||
]; | ||
|
||
$uploader = new Cf1FileUploader(); | ||
$uploads = $uploader->upload($file, $uploadArgs); | ||
$this->assertTrue( is_array( $uploads ) ); | ||
$this->assertFalse( is_wp_error( $uploads ) ); | ||
|
||
} | ||
/** | ||
* | ||
* @since 1.8.0 | ||
* | ||
* @covers \calderawp\calderaforms\cf2\Fields\Handlers\Cf1FileUploader::addFilter() | ||
* | ||
* @group file | ||
*/ | ||
public function testAddFilter() | ||
{ | ||
$uploader = new Cf1FileUploader(); | ||
$uploader->addFilter('f', 'c', true ); | ||
$this->assertTrue( has_filter( 'upload_dir'), array( \Caldera_Forms_Files::class, 'uploads_filter' )); | ||
} | ||
/** | ||
* | ||
* @since 1.8.0 | ||
* | ||
* @covers \calderawp\calderaforms\cf2\Fields\Handlers\Cf1FileUploader::addFilter() | ||
* @covers \calderawp\calderaforms\cf2\Fields\Handlers\Cf1FileUploader::removeFilter() | ||
* | ||
* @group file | ||
*/ | ||
public function testRemoveFilter() | ||
{ | ||
$uploader = new Cf1FileUploader(); | ||
$uploader->addFilter('f', 'c', true ); | ||
$uploader->removeFilter(); | ||
$this->assertFalse( has_filter( 'upload_dir'), array( \Caldera_Forms_Files::class, 'uploads_filter' )); | ||
} | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters