-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(options): enhance the options for better testing
- Loading branch information
Showing
5 changed files
with
87 additions
and
9 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<?php | ||
|
||
namespace Craftsys\Tests\Msg91\OTP; | ||
|
||
use Craftsys\Msg91\OTP\Options; | ||
use Craftsys\Tests\Msg91\TestCase; | ||
|
||
class OptionsTest extends TestCase | ||
{ | ||
public function test_init_with_int_will_set_otp() | ||
{ | ||
$options = (new Options(1234)); | ||
$this->assertEquals(1234, $options->getPayloadForKey('otp')); | ||
} | ||
|
||
public function test_can_merge_with_another_options() | ||
{ | ||
$options = (new Options())->mergeWith(new Options(1234)); | ||
$this->assertEquals(1234, $options->getPayloadForKey('otp')); | ||
} | ||
} |
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 | ||
|
||
namespace Craftsys\Tests\Msg91; | ||
|
||
use Craftsys\Msg91\Options as AbstractOptions; | ||
|
||
class OptionsTest extends TestCase | ||
{ | ||
public function test_can_merge_with_a_string() | ||
{ | ||
$options = (new Options)->mergeWith('string'); | ||
$this->assertEquals('string', $options->getPayloadForKey('message')); | ||
} | ||
|
||
public function test_can_merge_with_another_options() | ||
{ | ||
$options = (new Options)->mergeWith((new Options())->from('this')); | ||
$this->assertEquals('this', $options->getPayloadForKey('sender')); | ||
} | ||
|
||
public function test_be_merged_with_a_closure() | ||
{ | ||
$options = (new Options)->mergeWith(function ($options) { | ||
$options->from('this'); | ||
}); | ||
$this->assertEquals('this', $options->getPayloadForKey('sender')); | ||
} | ||
|
||
public function test_can_merge_an_array() | ||
{ | ||
$options = (new Options)->mergeWith(['template_id' => 'this']); | ||
$this->assertEquals('this', $options->getPayloadForKey('template_id')); | ||
} | ||
} | ||
|
||
class Options extends AbstractOptions | ||
{ | ||
} |