-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#40 Sender instance passed to the Factory
- Loading branch information
1 parent
974458f
commit 33bf5b3
Showing
4 changed files
with
81 additions
and
8 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<?php | ||
|
||
interface WPNotify_SenderFactory { | ||
|
||
/** | ||
* Create a new instance of notification sender | ||
* | ||
* @param string $name | ||
* | ||
* @return WPNotify_Sender | ||
*/ | ||
public function create( string $name ): WPNotify_Sender; | ||
} |
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 |
---|---|---|
|
@@ -4,4 +4,3 @@ | |
|
||
require dirname( __FILE__ ) . '/stubs.php'; | ||
require dirname( __FILE__ ) . '/TestCase.php'; | ||
|
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,38 @@ | ||
<?php | ||
|
||
class Test_WPNotify_Factory extends WPNotify_TestCase { | ||
|
||
|
||
public function test_create_with_vendor_sender() { | ||
|
||
$vendor_sender = $this->createMock( 'WPNotify_Sender' ); | ||
|
||
$message_factory = $this->getMockBuilder( 'WPNotify_MessageFactory' ) | ||
->setMethods( array( 'create', 'accepts' ) ) | ||
->getMock(); | ||
|
||
$message_factory->method( 'create' )->willReturn( $this->createMock( 'WPNotify_Message' ) ); | ||
$message_factory->method( 'accepts' )->willReturn( true ); | ||
|
||
$sender_factory = $this->getMockBuilder( 'WPNotify_SenderFactory' ) | ||
->setMethods( array( 'create' ) ) | ||
->getMock(); | ||
|
||
$sender_factory->method( 'create' )->willReturn( $this->createMock( 'WPNotify_Sender' ) ); | ||
|
||
$factory = new WPNotify_Factory( | ||
$message_factory, | ||
$this->createMock( 'WPNotify_RecipientFactory' ), | ||
$sender_factory | ||
); | ||
|
||
$args = array( | ||
array(), | ||
array(), | ||
array(), | ||
); | ||
|
||
$notification = $factory->create( $args ); | ||
$this->assertEquals( $vendor_sender, $notification->get_sender() ); | ||
} | ||
} |