Skip to content

Commit

Permalink
test fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
bsessions85 committed Oct 4, 2023
1 parent d6fc89e commit 306cdcf
Showing 1 changed file with 19 additions and 4 deletions.
23 changes: 19 additions & 4 deletions tests/files/test-vip-filesystem.php
Original file line number Diff line number Diff line change
Expand Up @@ -266,8 +266,12 @@ public function test__filter_validate_file__valid_file() {
$basepath = $this->get_upload_path();

$stub = $this->getMockBuilder( VIP_Filesystem::class )
->setMethods( [ 'validate_file_type' ] )
->setMethods( [ 'validate_file_unique_name', 'validate_file_type' ] )
->getMock();

$stub->expects( $this->once() )
->method( 'validate_file_unique_name' )
->will( $this->returnValue( true ) );

$stub->expects( $this->once() )
->method( 'validate_file_type' )
Expand All @@ -287,13 +291,16 @@ public function test__filter_validate_file__file_exists() {
$basepath = $this->get_upload_path();

$stub = $this->getMockBuilder( VIP_Filesystem::class )
->setMethods( [ 'validate_file_unique_name' ] )
->setMethods( [ 'validate_file_unique_name', 'validate_file_type' ] )
->getMock();

$stub->expects( $this->once() )
->method( 'validate_file_unique_name' )
->with( $file['name'], $basepath . '/' )
->will( $this->returnValue( 'testfile_1696439069.txt' ) );

$stub->expects( $this->once() )
->method( 'validate_file_type' );

$actual = $stub->filter_validate_file( $file );

Expand All @@ -306,8 +313,12 @@ public function test__filter_validate_file__invalid_file_length() {
];

$stub = $this->getMockBuilder( VIP_Filesystem::class )
->setMethods( [ 'validate_file_type' ] )
->setMethods( [ 'validate_file_unique_name', 'validate_file_type' ] )
->getMock();

$stub->expects( $this->once() )
->method( 'validate_file_unique_name' )
->will( $this->returnValue( true ) );

$stub->expects( $this->once() )
->method( 'validate_file_type' );
Expand All @@ -328,9 +339,13 @@ public function test__filter_validate_file__invalid_file_type() {
$basepath = $this->get_upload_path();

$stub = $this->getMockBuilder( VIP_Filesystem::class )
->setMethods( [ 'validate_file_type' ] )
->setMethods( [ 'validate_file_unique_name', 'validate_file_type' ] )
->getMock();

$stub->expects( $this->once() )
->method( 'validate_file_unique_name' )
->will( $this->returnValue( true ) );

$stub->expects( $this->once() )
->method( 'validate_file_type' )
->with( $basepath . '/' . $file['name'] )
Expand Down

0 comments on commit 306cdcf

Please sign in to comment.