Skip to content

Commit

Permalink
- test exception added to be used in mocked tests
Browse files Browse the repository at this point in the history
- warnings removed
  • Loading branch information
mateikki committed Oct 7, 2024
1 parent ebbc5be commit 7927df4
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?php

namespace EwStarter\Exceptions;

use \Exception;

class Test_Exception extends Exception {
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
use Mockery\Adapter\Phpunit\MockeryPHPUnitIntegration;
use Brain\Monkey;

class Unit_Test_Case extends Test_Case {
abstract class Unit_Test_Case extends Test_Case {
use MockeryPHPUnitIntegration;

protected function setUp(): void {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

use DI\DependencyException;
use DI\NotFoundException;
use EwStarter\Exceptions\Test_Exception;
use EwStarter\Exceptions\Validation_Exception;
use EwStarter\Repositories\User_Applications_Repository;
use EwStarter\Services\Files_Service;
Expand Down Expand Up @@ -67,7 +68,7 @@ public function test_create_user_application_invalid_request() {
* @throws Validation_Exception
*/
public function test_create_user_application_failed_save_to_uploads() {
$this->expectException( ErrorException::class );
$this->expectException( Test_Exception::class );

$request_data = $this->entity_helper->get_test_user_application_request_data();

Expand All @@ -77,7 +78,7 @@ function ( MockInterface $mock ) {
$mock
->shouldReceive( 'check_filetype_and_ext' )
->withAnyArgs()
->andThrow( ErrorException::class );
->andThrow( Test_Exception::class );
}
);
$service->create_user_application( $request_data );
Expand All @@ -93,7 +94,7 @@ function ( MockInterface $mock ) {
* @throws Validation_Exception
*/
public function test_create_user_application_failed_db_save() {
$this->expectException( ErrorException::class );
$this->expectException( Test_Exception::class );

$request_data = $this->entity_helper->get_test_user_application_request_data();

Expand All @@ -102,7 +103,7 @@ function ( MockInterface $mock ) {
$mock
->shouldReceive( 'save' )
->withAnyArgs()
->andThrow( ErrorException::class );
->andThrow( Test_Exception::class);
},
function ( MockInterface $mock ) {
$mock
Expand Down

0 comments on commit 7927df4

Please sign in to comment.