mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-05 08:59:14 +08:00
use Mockery
This commit is contained in:
parent
77c170713d
commit
ae2ce64b70
6 changed files with 38 additions and 31 deletions
|
@ -5,30 +5,31 @@ namespace Inpsyde\PayPalCommerce\ApiClient\Entity;
|
|||
|
||||
|
||||
use Inpsyde\PayPalCommerce\ApiClient\TestCase;
|
||||
use Mockery;
|
||||
|
||||
class AmountBreakdownTest extends TestCase
|
||||
{
|
||||
|
||||
public function test() {
|
||||
$itemTotal = \Mockery::mock(Money::class);
|
||||
$itemTotal = Mockery::mock(Money::class);
|
||||
$itemTotal
|
||||
->expects('toArray')->andReturn(['itemTotal']);
|
||||
$shipping = \Mockery::mock(Money::class);
|
||||
$shipping = Mockery::mock(Money::class);
|
||||
$shipping
|
||||
->expects('toArray')->andReturn(['shipping']);
|
||||
$taxTotal = \Mockery::mock(Money::class);
|
||||
$taxTotal = Mockery::mock(Money::class);
|
||||
$taxTotal
|
||||
->expects('toArray')->andReturn(['taxTotal']);
|
||||
$handling = \Mockery::mock(Money::class);
|
||||
$handling = Mockery::mock(Money::class);
|
||||
$handling
|
||||
->expects('toArray')->andReturn(['handling']);
|
||||
$insurance = \Mockery::mock(Money::class);
|
||||
$insurance = Mockery::mock(Money::class);
|
||||
$insurance
|
||||
->expects('toArray')->andReturn(['insurance']);
|
||||
$shippingDiscount = \Mockery::mock(Money::class);
|
||||
$shippingDiscount = Mockery::mock(Money::class);
|
||||
$shippingDiscount
|
||||
->expects('toArray')->andReturn(['shippingDiscount']);
|
||||
$discount = \Mockery::mock(Money::class);
|
||||
$discount = Mockery::mock(Money::class);
|
||||
$discount
|
||||
->expects('toArray')->andReturn(['discount']);
|
||||
$testee = new AmountBreakdown(
|
||||
|
@ -67,25 +68,25 @@ class AmountBreakdownTest extends TestCase
|
|||
*/
|
||||
public function testDropArrayKeyIfNoValueGiven($keyMissing, $methodName) {
|
||||
|
||||
$itemTotal = \Mockery::mock(Money::class);
|
||||
$itemTotal = Mockery::mock(Money::class);
|
||||
$itemTotal
|
||||
->shouldReceive('toArray')->zeroOrMoreTimes()->andReturn(['itemTotal']);
|
||||
$shipping = \Mockery::mock(Money::class);
|
||||
$shipping = Mockery::mock(Money::class);
|
||||
$shipping
|
||||
->shouldReceive('toArray')->zeroOrMoreTimes()->andReturn(['shipping']);
|
||||
$taxTotal = \Mockery::mock(Money::class);
|
||||
$taxTotal = Mockery::mock(Money::class);
|
||||
$taxTotal
|
||||
->shouldReceive('toArray')->zeroOrMoreTimes()->andReturn(['taxTotal']);
|
||||
$handling = \Mockery::mock(Money::class);
|
||||
$handling = Mockery::mock(Money::class);
|
||||
$handling
|
||||
->shouldReceive('toArray')->zeroOrMoreTimes()->andReturn(['handling']);
|
||||
$insurance = \Mockery::mock(Money::class);
|
||||
$insurance = Mockery::mock(Money::class);
|
||||
$insurance
|
||||
->shouldReceive('toArray')->zeroOrMoreTimes()->andReturn(['insurance']);
|
||||
$shippingDiscount = \Mockery::mock(Money::class);
|
||||
$shippingDiscount = Mockery::mock(Money::class);
|
||||
$shippingDiscount
|
||||
->shouldReceive('toArray')->zeroOrMoreTimes()->andReturn(['shippingDiscount']);
|
||||
$discount = \Mockery::mock(Money::class);
|
||||
$discount = Mockery::mock(Money::class);
|
||||
$discount
|
||||
->shouldReceive('toArray')->zeroOrMoreTimes()->andReturn(['discount']);
|
||||
|
||||
|
|
|
@ -5,12 +5,13 @@ namespace Inpsyde\PayPalCommerce\ApiClient\Entity;
|
|||
|
||||
|
||||
use Inpsyde\PayPalCommerce\ApiClient\TestCase;
|
||||
use Mockery;
|
||||
|
||||
class AmountTest extends TestCase
|
||||
{
|
||||
|
||||
public function test() {
|
||||
$money = \Mockery::mock(Money::class);
|
||||
$money = Mockery::mock(Money::class);
|
||||
$money->shouldReceive('currencyCode')->andReturn('currencyCode');
|
||||
$money->shouldReceive('value')->andReturn(1.10);
|
||||
$testee = new Amount($money);
|
||||
|
@ -19,7 +20,7 @@ class AmountTest extends TestCase
|
|||
$this->assertEquals(1.10, $testee->value());
|
||||
}
|
||||
public function testBreakdownIsNull() {
|
||||
$money = \Mockery::mock(Money::class);
|
||||
$money = Mockery::mock(Money::class);
|
||||
$money->shouldReceive('currencyCode')->andReturn('currencyCode');
|
||||
$money->shouldReceive('value')->andReturn(1.10);
|
||||
$testee = new Amount($money);
|
||||
|
@ -33,10 +34,10 @@ class AmountTest extends TestCase
|
|||
$this->assertEquals($expectedArray, $testee->toArray());
|
||||
}
|
||||
public function testBreakdown() {
|
||||
$money = \Mockery::mock(Money::class);
|
||||
$money = Mockery::mock(Money::class);
|
||||
$money->shouldReceive('currencyCode')->andReturn('currencyCode');
|
||||
$money->shouldReceive('value')->andReturn(1.10);
|
||||
$breakdown = \Mockery::mock(AmountBreakdown::class);
|
||||
$breakdown = Mockery::mock(AmountBreakdown::class);
|
||||
$breakdown->shouldReceive('toArray')->andReturn([1]);
|
||||
$testee = new Amount($money, $breakdown);
|
||||
|
||||
|
|
|
@ -4,17 +4,18 @@ declare(strict_types=1);
|
|||
namespace Inpsyde\PayPalCommerce\ApiClient\Entity;
|
||||
|
||||
use Inpsyde\PayPalCommerce\ApiClient\TestCase;
|
||||
use Mockery;
|
||||
|
||||
class ErrorResponseCollectionTest extends TestCase
|
||||
{
|
||||
|
||||
public function testHasErrorCode() {
|
||||
$error1 = \Mockery::mock(ErrorResponse::class);
|
||||
$error1 = Mockery::mock(ErrorResponse::class);
|
||||
$error1
|
||||
->expects('code')
|
||||
->times(3)
|
||||
->andReturn('code-1');
|
||||
$error2 = \Mockery::mock(ErrorResponse::class);
|
||||
$error2 = Mockery::mock(ErrorResponse::class);
|
||||
$error2
|
||||
->expects('code')
|
||||
->times(3)
|
||||
|
@ -25,11 +26,11 @@ class ErrorResponseCollectionTest extends TestCase
|
|||
$this->assertFalse($testee->hasErrorCode('code-3'), 'code-3 should not return true');
|
||||
}
|
||||
public function testCodes() {
|
||||
$error1 = \Mockery::mock(ErrorResponse::class);
|
||||
$error1 = Mockery::mock(ErrorResponse::class);
|
||||
$error1
|
||||
->expects('code')
|
||||
->andReturn('code-1');
|
||||
$error2 = \Mockery::mock(ErrorResponse::class);
|
||||
$error2 = Mockery::mock(ErrorResponse::class);
|
||||
$error2
|
||||
->expects('code')
|
||||
->andReturn('code-2');
|
||||
|
@ -38,8 +39,8 @@ class ErrorResponseCollectionTest extends TestCase
|
|||
$this->assertEquals($expected, $testee->codes());
|
||||
}
|
||||
public function testErrors() {
|
||||
$error1 = \Mockery::mock(ErrorResponse::class);
|
||||
$error2 = \Mockery::mock(ErrorResponse::class);
|
||||
$error1 = Mockery::mock(ErrorResponse::class);
|
||||
$error2 = Mockery::mock(ErrorResponse::class);
|
||||
$testee = new ErrorResponseCollection($error1, $error2);
|
||||
|
||||
$errors = $testee->errors();
|
||||
|
|
|
@ -4,6 +4,7 @@ declare(strict_types=1);
|
|||
namespace Inpsyde\PayPalCommerce\ApiClient\Entity;
|
||||
|
||||
use Inpsyde\PayPalCommerce\ApiClient\TestCase;
|
||||
use Mockery;
|
||||
|
||||
class ErrorResponseTest extends TestCase
|
||||
{
|
||||
|
|
|
@ -4,13 +4,14 @@ declare(strict_types=1);
|
|||
namespace Inpsyde\PayPalCommerce\ApiClient\Entity;
|
||||
|
||||
use Inpsyde\PayPalCommerce\ApiClient\TestCase;
|
||||
use Mockery;
|
||||
|
||||
class ItemTest extends TestCase
|
||||
{
|
||||
|
||||
public function test() {
|
||||
$unitAmount = \Mockery::mock(Money::class);
|
||||
$tax = \Mockery::mock(Money::class);
|
||||
$unitAmount = Mockery::mock(Money::class);
|
||||
$tax = Mockery::mock(Money::class);
|
||||
$testee = new Item(
|
||||
'name',
|
||||
$unitAmount,
|
||||
|
@ -31,8 +32,8 @@ class ItemTest extends TestCase
|
|||
}
|
||||
|
||||
public function testDigitalGoodsCategory() {
|
||||
$unitAmount = \Mockery::mock(Money::class);
|
||||
$tax = \Mockery::mock(Money::class);
|
||||
$unitAmount = Mockery::mock(Money::class);
|
||||
$tax = Mockery::mock(Money::class);
|
||||
$testee = new Item(
|
||||
'name',
|
||||
$unitAmount,
|
||||
|
@ -48,11 +49,11 @@ class ItemTest extends TestCase
|
|||
|
||||
public function testToArray() {
|
||||
|
||||
$unitAmount = \Mockery::mock(Money::class);
|
||||
$unitAmount = Mockery::mock(Money::class);
|
||||
$unitAmount
|
||||
->expects('toArray')
|
||||
->andReturn([1]);
|
||||
$tax = \Mockery::mock(Money::class);
|
||||
$tax = Mockery::mock(Money::class);
|
||||
$tax
|
||||
->expects('toArray')
|
||||
->andReturn([2]);
|
||||
|
|
|
@ -6,6 +6,8 @@ namespace Inpsyde\PayPalCommerce\ApiClient;
|
|||
|
||||
use function Brain\Monkey\setUp;
|
||||
use function Brain\Monkey\tearDown;
|
||||
use function Brain\Monkey\Functions\expect;
|
||||
use Mockery;
|
||||
class TestCase extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
public function setUp(): void
|
||||
|
@ -16,7 +18,7 @@ class TestCase extends \PHPUnit\Framework\TestCase
|
|||
public function tearDown(): void
|
||||
{
|
||||
tearDown();
|
||||
\Mockery::close();
|
||||
Mockery::close();
|
||||
parent::tearDown();
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue