Fix WooCommerce test stubs to follow Code Sniffer rules
[MAILPOET-2382]
This commit is contained in:
committed by
Jack Kitterhing
parent
8fd5f987a9
commit
f0fa9bee2e
@ -7,7 +7,6 @@ use Codeception\Stub\Expected;
|
|||||||
use Codeception\Util\Fixtures;
|
use Codeception\Util\Fixtures;
|
||||||
use MailPoet\AutomaticEmails\WooCommerce\Events\FirstPurchase;
|
use MailPoet\AutomaticEmails\WooCommerce\Events\FirstPurchase;
|
||||||
use MailPoet\AutomaticEmails\WooCommerce\Helper as WCPremiumHelper;
|
use MailPoet\AutomaticEmails\WooCommerce\Helper as WCPremiumHelper;
|
||||||
use MailPoet\AutomaticEmails\WooCommerce\OrderDetails;
|
|
||||||
use MailPoet\AutomaticEmails\WooCommerce\WooCommerce;
|
use MailPoet\AutomaticEmails\WooCommerce\WooCommerce;
|
||||||
use MailPoet\Models\Newsletter;
|
use MailPoet\Models\Newsletter;
|
||||||
use MailPoet\Models\NewsletterOption;
|
use MailPoet\Models\NewsletterOption;
|
||||||
@ -17,10 +16,11 @@ use MailPoet\Models\ScheduledTaskSubscriber;
|
|||||||
use MailPoet\Models\SendingQueue;
|
use MailPoet\Models\SendingQueue;
|
||||||
use MailPoet\Models\Subscriber;
|
use MailPoet\Models\Subscriber;
|
||||||
use MailPoet\Tasks\Sending;
|
use MailPoet\Tasks\Sending;
|
||||||
|
use MailPoet\Test\AutomaticEmails\WooCommerce\WooCommerceStubs\OrderDetails;
|
||||||
use MailPoet\WooCommerce\Helper as WCHelper;
|
use MailPoet\WooCommerce\Helper as WCHelper;
|
||||||
use MailPoet\WP\Functions as WPFunctions;
|
use MailPoet\WP\Functions as WPFunctions;
|
||||||
|
|
||||||
require_once(__DIR__ . '/../WooCommerceStub.php');
|
require_once __DIR__ . '/../WooCommerceStubs/OrderDetails.php';
|
||||||
|
|
||||||
class FirstPurchaseTest extends \MailPoetTest {
|
class FirstPurchaseTest extends \MailPoetTest {
|
||||||
function _before() {
|
function _before() {
|
||||||
@ -134,7 +134,7 @@ class FirstPurchaseTest extends \MailPoetTest {
|
|||||||
|
|
||||||
function testItDoesNotScheduleEmailWhenCustomerEmailIsEmpty() {
|
function testItDoesNotScheduleEmailWhenCustomerEmailIsEmpty() {
|
||||||
$order_details = Stub::make(
|
$order_details = Stub::make(
|
||||||
new \WooCommerceStub\OrderDetails(),
|
new OrderDetails(),
|
||||||
[
|
[
|
||||||
'get_billing_email' => Expected::once(),
|
'get_billing_email' => Expected::once(),
|
||||||
],
|
],
|
||||||
@ -149,7 +149,7 @@ class FirstPurchaseTest extends \MailPoetTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function testItDoesNotScheduleEmailWhenItIsNotCustomersFirstPurchase() {
|
function testItDoesNotScheduleEmailWhenItIsNotCustomersFirstPurchase() {
|
||||||
$order_details = Stub::make(new \WooCommerceStub\OrderDetails(), ['get_billing_email' => 'test@example.com']);
|
$order_details = Stub::make(new OrderDetails(), ['get_billing_email' => 'test@example.com']);
|
||||||
$helper = Stub::make(WCHelper::class, [
|
$helper = Stub::make(WCHelper::class, [
|
||||||
'wcGetOrder' => $order_details,
|
'wcGetOrder' => $order_details,
|
||||||
]);
|
]);
|
||||||
@ -164,7 +164,7 @@ class FirstPurchaseTest extends \MailPoetTest {
|
|||||||
function testItDoesNotScheduleEmailWhenCustomerIsNotAWCSegmentSubscriber() {
|
function testItDoesNotScheduleEmailWhenCustomerIsNotAWCSegmentSubscriber() {
|
||||||
$date_created = new \DateTime('2018-12-12');
|
$date_created = new \DateTime('2018-12-12');
|
||||||
$order_details = Stub::make(
|
$order_details = Stub::make(
|
||||||
new \WooCommerceStub\OrderDetails(),
|
new OrderDetails(),
|
||||||
[
|
[
|
||||||
'get_billing_email' => 'test@example.com',
|
'get_billing_email' => 'test@example.com',
|
||||||
'get_date_created' => Expected::once(function() use ($date_created) {
|
'get_date_created' => Expected::once(function() use ($date_created) {
|
||||||
@ -235,7 +235,7 @@ class FirstPurchaseTest extends \MailPoetTest {
|
|||||||
$helper = Stub::make(WCHelper::class, [
|
$helper = Stub::make(WCHelper::class, [
|
||||||
'wcGetOrder' => function($order_id) use ($customer_email, $date_created) {
|
'wcGetOrder' => function($order_id) use ($customer_email, $date_created) {
|
||||||
$order_details = Stub::construct(
|
$order_details = Stub::construct(
|
||||||
new \WooCommerceStub\OrderDetails(),
|
new OrderDetails(),
|
||||||
[$order_id],
|
[$order_id],
|
||||||
[
|
[
|
||||||
'get_billing_email' => $customer_email,
|
'get_billing_email' => $customer_email,
|
||||||
|
@ -16,10 +16,12 @@ use MailPoet\Models\ScheduledTaskSubscriber;
|
|||||||
use MailPoet\Models\SendingQueue;
|
use MailPoet\Models\SendingQueue;
|
||||||
use MailPoet\Models\Subscriber;
|
use MailPoet\Models\Subscriber;
|
||||||
use MailPoet\Tasks\Sending;
|
use MailPoet\Tasks\Sending;
|
||||||
|
use MailPoet\Test\AutomaticEmails\WooCommerce\WooCommerceStubs\ItemDetails;
|
||||||
|
use MailPoet\Test\AutomaticEmails\WooCommerce\WooCommerceStubs\OrderDetails;
|
||||||
use MailPoet\WooCommerce\Helper as WCHelper;
|
use MailPoet\WooCommerce\Helper as WCHelper;
|
||||||
use MailPoet\WP\Functions as WPFunctions;
|
use MailPoet\WP\Functions as WPFunctions;
|
||||||
|
|
||||||
require_once(__DIR__ . '/../WooCommerceStub.php');
|
require_once __DIR__ . '/../WooCommerceStubs/ItemDetails.php';
|
||||||
|
|
||||||
class PurchasedProductTest extends \MailPoetTest {
|
class PurchasedProductTest extends \MailPoetTest {
|
||||||
function _before() {
|
function _before() {
|
||||||
@ -44,7 +46,7 @@ class PurchasedProductTest extends \MailPoetTest {
|
|||||||
|
|
||||||
function testItDoesNotScheduleEmailWhenCustomerEmailIsEmpty() {
|
function testItDoesNotScheduleEmailWhenCustomerEmailIsEmpty() {
|
||||||
$order_details = Stub::make(
|
$order_details = Stub::make(
|
||||||
new \WooCommerceStub\OrderDetails(),
|
new OrderDetails(),
|
||||||
[
|
[
|
||||||
'get_billing_email' => Expected::once(),
|
'get_billing_email' => Expected::once(),
|
||||||
],
|
],
|
||||||
@ -61,13 +63,13 @@ class PurchasedProductTest extends \MailPoetTest {
|
|||||||
|
|
||||||
function testItDoesNotScheduleEmailWhenCustomerIsNotAWCSegmentSubscriber() {
|
function testItDoesNotScheduleEmailWhenCustomerIsNotAWCSegmentSubscriber() {
|
||||||
$order_details = Stub::make(
|
$order_details = Stub::make(
|
||||||
new \WooCommerceStub\OrderDetails(),
|
new OrderDetails(),
|
||||||
[
|
[
|
||||||
'get_billing_email' => 'test@example.com',
|
'get_billing_email' => 'test@example.com',
|
||||||
'get_items' => function() {
|
'get_items' => function() {
|
||||||
return [
|
return [
|
||||||
Stub::make(
|
Stub::make(
|
||||||
new \WooCommerceStub\ItemDetails(),
|
new ItemDetails(),
|
||||||
[
|
[
|
||||||
'get_product_id' => 12,
|
'get_product_id' => 12,
|
||||||
]
|
]
|
||||||
@ -124,19 +126,19 @@ class PurchasedProductTest extends \MailPoetTest {
|
|||||||
$subscriber->save();
|
$subscriber->save();
|
||||||
|
|
||||||
$order_details = Stub::make(
|
$order_details = Stub::make(
|
||||||
new \WooCommerceStub\OrderDetails(),
|
new OrderDetails(),
|
||||||
[
|
[
|
||||||
'get_billing_email' => 'test@example.com',
|
'get_billing_email' => 'test@example.com',
|
||||||
'get_items' => function() use ($incorrect_product_ids) {
|
'get_items' => function() use ($incorrect_product_ids) {
|
||||||
return [
|
return [
|
||||||
Stub::make(
|
Stub::make(
|
||||||
new \WooCommerceStub\ItemDetails(),
|
new ItemDetails(),
|
||||||
[
|
[
|
||||||
'get_product_id' => $incorrect_product_ids[0],
|
'get_product_id' => $incorrect_product_ids[0],
|
||||||
]
|
]
|
||||||
),
|
),
|
||||||
Stub::make(
|
Stub::make(
|
||||||
new \WooCommerceStub\ItemDetails(),
|
new ItemDetails(),
|
||||||
[
|
[
|
||||||
'get_product_id' => $incorrect_product_ids[1],
|
'get_product_id' => $incorrect_product_ids[1],
|
||||||
]
|
]
|
||||||
@ -202,19 +204,19 @@ class PurchasedProductTest extends \MailPoetTest {
|
|||||||
$subscriber->save();
|
$subscriber->save();
|
||||||
|
|
||||||
$order_details = Stub::make(
|
$order_details = Stub::make(
|
||||||
new \WooCommerceStub\OrderDetails(),
|
new OrderDetails(),
|
||||||
[
|
[
|
||||||
'get_billing_email' => 'test@example.com',
|
'get_billing_email' => 'test@example.com',
|
||||||
'get_items' => function() use ($incorrect_product_id, $product_id) {
|
'get_items' => function() use ($incorrect_product_id, $product_id) {
|
||||||
return [
|
return [
|
||||||
Stub::make(
|
Stub::make(
|
||||||
new \WooCommerceStub\ItemDetails(),
|
new ItemDetails(),
|
||||||
[
|
[
|
||||||
'get_product_id' => $incorrect_product_id,
|
'get_product_id' => $incorrect_product_id,
|
||||||
]
|
]
|
||||||
),
|
),
|
||||||
Stub::make(
|
Stub::make(
|
||||||
new \WooCommerceStub\ItemDetails(),
|
new ItemDetails(),
|
||||||
[
|
[
|
||||||
'get_product_id' => $product_id,
|
'get_product_id' => $product_id,
|
||||||
]
|
]
|
||||||
|
@ -1,38 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace WooCommerceStub;
|
|
||||||
|
|
||||||
class OrderDetails {
|
|
||||||
public $total;
|
|
||||||
public $order_id;
|
|
||||||
|
|
||||||
function __construct($order_id = null) {
|
|
||||||
$this->order_id = $order_id;
|
|
||||||
}
|
|
||||||
|
|
||||||
function get_customer_id() {
|
|
||||||
}
|
|
||||||
|
|
||||||
function get_billing_email() {
|
|
||||||
}
|
|
||||||
|
|
||||||
function get_date_created() {
|
|
||||||
}
|
|
||||||
|
|
||||||
function get_id() {
|
|
||||||
return $this->order_id;
|
|
||||||
}
|
|
||||||
|
|
||||||
function get_total() {
|
|
||||||
return $this->total;
|
|
||||||
}
|
|
||||||
|
|
||||||
function get_items() {
|
|
||||||
return new ItemDetails();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class ItemDetails {
|
|
||||||
function get_product_id() {
|
|
||||||
}
|
|
||||||
}
|
|
@ -0,0 +1,9 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace MailPoet\Test\AutomaticEmails\WooCommerce\WooCommerceStubs;
|
||||||
|
|
||||||
|
// phpcs:disable PSR1.Methods.CamelCapsMethodName
|
||||||
|
class ItemDetails {
|
||||||
|
function get_product_id() {
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,37 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace MailPoet\Test\AutomaticEmails\WooCommerce\WooCommerceStubs;
|
||||||
|
|
||||||
|
require_once __DIR__ . '/ItemDetails.php';
|
||||||
|
|
||||||
|
// phpcs:disable PSR1.Methods.CamelCapsMethodName
|
||||||
|
class OrderDetails
|
||||||
|
{
|
||||||
|
public $total;
|
||||||
|
public $order_id;
|
||||||
|
|
||||||
|
function __construct($order_id = null) {
|
||||||
|
$this->order_id = $order_id;
|
||||||
|
}
|
||||||
|
|
||||||
|
function get_customer_id() {
|
||||||
|
}
|
||||||
|
|
||||||
|
function get_billing_email() {
|
||||||
|
}
|
||||||
|
|
||||||
|
function get_date_created() {
|
||||||
|
}
|
||||||
|
|
||||||
|
function get_id() {
|
||||||
|
return $this->order_id;
|
||||||
|
}
|
||||||
|
|
||||||
|
function get_total() {
|
||||||
|
return $this->total;
|
||||||
|
}
|
||||||
|
|
||||||
|
function get_items() {
|
||||||
|
return new ItemDetails();
|
||||||
|
}
|
||||||
|
}
|
Reference in New Issue
Block a user