mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-05 08:59:14 +08:00
Merge pull request #657 from woocommerce/PCP-687-do-not-call-partner-referrals-si
Cache partner referrals signup links
This commit is contained in:
commit
259f824dac
9 changed files with 165 additions and 22 deletions
|
@ -2,3 +2,6 @@
|
||||||
if (!defined('EP_PAGES')) {
|
if (!defined('EP_PAGES')) {
|
||||||
define('EP_PAGES', 4096);
|
define('EP_PAGES', 4096);
|
||||||
}
|
}
|
||||||
|
if (!defined('MONTH_IN_SECONDS')) {
|
||||||
|
define('MONTH_IN_SECONDS', 30 * DAY_IN_SECONDS);
|
||||||
|
}
|
||||||
|
|
|
@ -67,10 +67,11 @@ class Cache {
|
||||||
*
|
*
|
||||||
* @param string $key The key under which the value should be cached.
|
* @param string $key The key under which the value should be cached.
|
||||||
* @param mixed $value The value to cache.
|
* @param mixed $value The value to cache.
|
||||||
|
* @param int $expiration Time until expiration in seconds.
|
||||||
*
|
*
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function set( string $key, $value ): bool {
|
public function set( string $key, $value, int $expiration = 0 ): bool {
|
||||||
return (bool) set_transient( $this->prefix . $key, $value );
|
return (bool) set_transient( $this->prefix . $key, $value, $expiration );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -87,7 +87,19 @@ const ppcp_onboarding = {
|
||||||
}).then((res)=>{
|
}).then((res)=>{
|
||||||
return res.json();
|
return res.json();
|
||||||
}).then((data)=>{
|
}).then((data)=>{
|
||||||
location.reload();
|
if (!data.success) {
|
||||||
|
alert('Could not update signup buttons: ' + JSON.stringify(data));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
buttons.forEach((element) => {
|
||||||
|
for (let [key, value] of Object.entries(data.data.signup_links)) {
|
||||||
|
key = 'connect-to' + key.replace(/-/g, '');
|
||||||
|
if(key === element.id) {
|
||||||
|
element.setAttribute('href', value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
|
|
@ -191,6 +191,9 @@ return array(
|
||||||
return new PayUponInvoiceEndpoint(
|
return new PayUponInvoiceEndpoint(
|
||||||
$container->get( 'wcgateway.settings' ),
|
$container->get( 'wcgateway.settings' ),
|
||||||
$container->get( 'button.request-data' ),
|
$container->get( 'button.request-data' ),
|
||||||
|
$container->get( 'onboarding.signup-link-cache' ),
|
||||||
|
$container->get( 'onboarding.render' ),
|
||||||
|
$container->get( 'onboarding.signup-link-ids' ),
|
||||||
$container->get( 'woocommerce.logger.woocommerce' )
|
$container->get( 'woocommerce.logger.woocommerce' )
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
@ -210,17 +213,29 @@ return array(
|
||||||
$container->get( 'woocommerce.logger.woocommerce' )
|
$container->get( 'woocommerce.logger.woocommerce' )
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
'onboarding.signup-link-cache' => static function( ContainerInterface $container ): Cache {
|
||||||
|
return new Cache( 'ppcp-paypal-signup-link' );
|
||||||
|
},
|
||||||
|
'onboarding.signup-link-ids' => static function ( ContainerInterface $container ): array {
|
||||||
|
return array(
|
||||||
|
'production-ppcp',
|
||||||
|
'production-express_checkout',
|
||||||
|
'sandbox-ppcp',
|
||||||
|
'sandbox-express_checkout',
|
||||||
|
);
|
||||||
|
},
|
||||||
'onboarding.render' => static function ( ContainerInterface $container ) : OnboardingRenderer {
|
'onboarding.render' => static function ( ContainerInterface $container ) : OnboardingRenderer {
|
||||||
|
|
||||||
$partner_referrals = $container->get( 'api.endpoint.partner-referrals-production' );
|
$partner_referrals = $container->get( 'api.endpoint.partner-referrals-production' );
|
||||||
$partner_referrals_sandbox = $container->get( 'api.endpoint.partner-referrals-sandbox' );
|
$partner_referrals_sandbox = $container->get( 'api.endpoint.partner-referrals-sandbox' );
|
||||||
$partner_referrals_data = $container->get( 'api.repository.partner-referrals-data' );
|
$partner_referrals_data = $container->get( 'api.repository.partner-referrals-data' );
|
||||||
$settings = $container->get( 'wcgateway.settings' );
|
$settings = $container->get( 'wcgateway.settings' );
|
||||||
|
$signup_link_cache = $container->get( 'onboarding.signup-link-cache' );
|
||||||
return new OnboardingRenderer(
|
return new OnboardingRenderer(
|
||||||
$settings,
|
$settings,
|
||||||
$partner_referrals,
|
$partner_referrals,
|
||||||
$partner_referrals_sandbox,
|
$partner_referrals_sandbox,
|
||||||
$partner_referrals_data
|
$partner_referrals_data,
|
||||||
|
$signup_link_cache
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
'onboarding.render-options' => static function ( ContainerInterface $container ) : OnboardingOptionsRenderer {
|
'onboarding.render-options' => static function ( ContainerInterface $container ) : OnboardingOptionsRenderer {
|
||||||
|
|
|
@ -11,8 +11,10 @@ namespace WooCommerce\PayPalCommerce\Onboarding\Endpoint;
|
||||||
|
|
||||||
use Exception;
|
use Exception;
|
||||||
use Psr\Log\LoggerInterface;
|
use Psr\Log\LoggerInterface;
|
||||||
|
use WooCommerce\PayPalCommerce\ApiClient\Helper\Cache;
|
||||||
use WooCommerce\PayPalCommerce\Button\Endpoint\EndpointInterface;
|
use WooCommerce\PayPalCommerce\Button\Endpoint\EndpointInterface;
|
||||||
use WooCommerce\PayPalCommerce\Button\Endpoint\RequestData;
|
use WooCommerce\PayPalCommerce\Button\Endpoint\RequestData;
|
||||||
|
use WooCommerce\PayPalCommerce\Onboarding\Render\OnboardingRenderer;
|
||||||
use WooCommerce\PayPalCommerce\WcGateway\Settings\Settings;
|
use WooCommerce\PayPalCommerce\WcGateway\Settings\Settings;
|
||||||
use WooCommerce\PayPalCommerce\WcGateway\Exception\NotFoundException;
|
use WooCommerce\PayPalCommerce\WcGateway\Exception\NotFoundException;
|
||||||
|
|
||||||
|
@ -35,6 +37,27 @@ class PayUponInvoiceEndpoint implements EndpointInterface {
|
||||||
*/
|
*/
|
||||||
protected $request_data;
|
protected $request_data;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The signup link cache.
|
||||||
|
*
|
||||||
|
* @var Cache
|
||||||
|
*/
|
||||||
|
protected $signup_link_cache;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The onboarding renderer.
|
||||||
|
*
|
||||||
|
* @var OnboardingRenderer
|
||||||
|
*/
|
||||||
|
protected $onboarding_renderer;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Signup link ids.
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
protected $signup_link_ids;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The logger.
|
* The logger.
|
||||||
*
|
*
|
||||||
|
@ -45,14 +68,27 @@ class PayUponInvoiceEndpoint implements EndpointInterface {
|
||||||
/**
|
/**
|
||||||
* PayUponInvoiceEndpoint constructor.
|
* PayUponInvoiceEndpoint constructor.
|
||||||
*
|
*
|
||||||
* @param Settings $settings The settings.
|
* @param Settings $settings The settings.
|
||||||
* @param RequestData $request_data The request data.
|
* @param RequestData $request_data The request data.
|
||||||
* @param LoggerInterface $logger The logger.
|
* @param Cache $signup_link_cache The signup link cache.
|
||||||
|
* @param OnboardingRenderer $onboarding_renderer The onboarding renderer.
|
||||||
|
* @param array $signup_link_ids Signup link ids.
|
||||||
|
* @param LoggerInterface $logger The logger.
|
||||||
*/
|
*/
|
||||||
public function __construct( Settings $settings, RequestData $request_data, LoggerInterface $logger ) {
|
public function __construct(
|
||||||
$this->settings = $settings;
|
Settings $settings,
|
||||||
$this->request_data = $request_data;
|
RequestData $request_data,
|
||||||
$this->logger = $logger;
|
Cache $signup_link_cache,
|
||||||
|
OnboardingRenderer $onboarding_renderer,
|
||||||
|
array $signup_link_ids,
|
||||||
|
LoggerInterface $logger
|
||||||
|
) {
|
||||||
|
$this->settings = $settings;
|
||||||
|
$this->request_data = $request_data;
|
||||||
|
$this->signup_link_cache = $signup_link_cache;
|
||||||
|
$this->onboarding_renderer = $onboarding_renderer;
|
||||||
|
$this->logger = $logger;
|
||||||
|
$this->signup_link_ids = $signup_link_ids;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -71,18 +107,33 @@ class PayUponInvoiceEndpoint implements EndpointInterface {
|
||||||
* @throws NotFoundException When order not found or handling failed.
|
* @throws NotFoundException When order not found or handling failed.
|
||||||
*/
|
*/
|
||||||
public function handle_request(): bool {
|
public function handle_request(): bool {
|
||||||
|
$signup_links = array();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$data = $this->request_data->read_request( $this->nonce() );
|
$data = $this->request_data->read_request( $this->nonce() );
|
||||||
$this->settings->set( 'ppcp-onboarding-pui', $data['checked'] );
|
$this->settings->set( 'ppcp-onboarding-pui', $data['checked'] );
|
||||||
$this->settings->persist();
|
$this->settings->persist();
|
||||||
|
|
||||||
|
foreach ( $this->signup_link_ids as $key ) {
|
||||||
|
if ( $this->signup_link_cache->has( $key ) ) {
|
||||||
|
$this->signup_link_cache->delete( $key );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach ( $this->signup_link_ids as $key ) {
|
||||||
|
$parts = explode( '-', $key );
|
||||||
|
$is_production = 'production' === $parts[0];
|
||||||
|
$products = 'ppcp' === $parts[1] ? array( 'PPCP' ) : array( 'EXPRESS_CHECKOUT' );
|
||||||
|
$signup_links[ $key ] = $this->onboarding_renderer->get_signup_link( $is_production, $products );
|
||||||
|
}
|
||||||
} catch ( Exception $exception ) {
|
} catch ( Exception $exception ) {
|
||||||
$this->logger->error( $exception->getMessage() );
|
$this->logger->error( $exception->getMessage() );
|
||||||
}
|
}
|
||||||
|
|
||||||
wp_send_json_success(
|
wp_send_json_success(
|
||||||
array(
|
array(
|
||||||
$this->settings->get( 'ppcp-onboarding-pui' ),
|
'onboarding_pui' => $this->settings->get( 'ppcp-onboarding-pui' ),
|
||||||
|
'signup_links' => $signup_links,
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
@ -11,6 +11,7 @@ namespace WooCommerce\PayPalCommerce\Onboarding\Render;
|
||||||
|
|
||||||
use WooCommerce\PayPalCommerce\ApiClient\Endpoint\PartnerReferrals;
|
use WooCommerce\PayPalCommerce\ApiClient\Endpoint\PartnerReferrals;
|
||||||
use WooCommerce\PayPalCommerce\ApiClient\Exception\RuntimeException;
|
use WooCommerce\PayPalCommerce\ApiClient\Exception\RuntimeException;
|
||||||
|
use WooCommerce\PayPalCommerce\ApiClient\Helper\Cache;
|
||||||
use WooCommerce\PayPalCommerce\ApiClient\Repository\PartnerReferralsData;
|
use WooCommerce\PayPalCommerce\ApiClient\Repository\PartnerReferralsData;
|
||||||
use WooCommerce\PayPalCommerce\WcGateway\Settings\Settings;
|
use WooCommerce\PayPalCommerce\WcGateway\Settings\Settings;
|
||||||
|
|
||||||
|
@ -47,6 +48,13 @@ class OnboardingRenderer {
|
||||||
*/
|
*/
|
||||||
private $partner_referrals_data;
|
private $partner_referrals_data;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The cache
|
||||||
|
*
|
||||||
|
* @var Cache
|
||||||
|
*/
|
||||||
|
protected $cache;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* OnboardingRenderer constructor.
|
* OnboardingRenderer constructor.
|
||||||
*
|
*
|
||||||
|
@ -54,17 +62,20 @@ class OnboardingRenderer {
|
||||||
* @param PartnerReferrals $production_partner_referrals The PartnerReferrals for production.
|
* @param PartnerReferrals $production_partner_referrals The PartnerReferrals for production.
|
||||||
* @param PartnerReferrals $sandbox_partner_referrals The PartnerReferrals for sandbox.
|
* @param PartnerReferrals $sandbox_partner_referrals The PartnerReferrals for sandbox.
|
||||||
* @param PartnerReferralsData $partner_referrals_data The default partner referrals data.
|
* @param PartnerReferralsData $partner_referrals_data The default partner referrals data.
|
||||||
|
* @param Cache $cache The cache.
|
||||||
*/
|
*/
|
||||||
public function __construct(
|
public function __construct(
|
||||||
Settings $settings,
|
Settings $settings,
|
||||||
PartnerReferrals $production_partner_referrals,
|
PartnerReferrals $production_partner_referrals,
|
||||||
PartnerReferrals $sandbox_partner_referrals,
|
PartnerReferrals $sandbox_partner_referrals,
|
||||||
PartnerReferralsData $partner_referrals_data
|
PartnerReferralsData $partner_referrals_data,
|
||||||
|
Cache $cache
|
||||||
) {
|
) {
|
||||||
$this->settings = $settings;
|
$this->settings = $settings;
|
||||||
$this->production_partner_referrals = $production_partner_referrals;
|
$this->production_partner_referrals = $production_partner_referrals;
|
||||||
$this->sandbox_partner_referrals = $sandbox_partner_referrals;
|
$this->sandbox_partner_referrals = $sandbox_partner_referrals;
|
||||||
$this->partner_referrals_data = $partner_referrals_data;
|
$this->partner_referrals_data = $partner_referrals_data;
|
||||||
|
$this->cache = $cache;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -83,9 +94,17 @@ class OnboardingRenderer {
|
||||||
->with_products( $products )
|
->with_products( $products )
|
||||||
->data();
|
->data();
|
||||||
|
|
||||||
|
$environment = $is_production ? 'production' : 'sandbox';
|
||||||
|
$product = 'PPCP' === $data['products'][0] ? 'ppcp' : 'express_checkout';
|
||||||
|
if ( $this->cache->has( $environment . '-' . $product ) ) {
|
||||||
|
return $this->cache->get( $environment . '-' . $product );
|
||||||
|
}
|
||||||
|
|
||||||
$url = $is_production ? $this->production_partner_referrals->signup_link( $data ) : $this->sandbox_partner_referrals->signup_link( $data );
|
$url = $is_production ? $this->production_partner_referrals->signup_link( $data ) : $this->sandbox_partner_referrals->signup_link( $data );
|
||||||
$url = add_query_arg( $args, $url );
|
$url = add_query_arg( $args, $url );
|
||||||
|
|
||||||
|
$this->cache->set( $environment . '-' . $product, $url, 3 * MONTH_IN_SECONDS );
|
||||||
|
|
||||||
return $url;
|
return $url;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -219,7 +219,19 @@ return array(
|
||||||
$cache = new Cache( 'ppcp-paypal-bearer' );
|
$cache = new Cache( 'ppcp-paypal-bearer' );
|
||||||
$bearer = $container->get( 'api.bearer' );
|
$bearer = $container->get( 'api.bearer' );
|
||||||
$page_id = $container->get( 'wcgateway.current-ppcp-settings-page-id' );
|
$page_id = $container->get( 'wcgateway.current-ppcp-settings-page-id' );
|
||||||
return new SettingsListener( $settings, $fields, $webhook_registrar, $cache, $state, $bearer, $page_id );
|
$signup_link_cache = $container->get( 'onboarding.signup-link-cache' );
|
||||||
|
$signup_link_ids = $container->get( 'onboarding.signup-link-ids' );
|
||||||
|
return new SettingsListener(
|
||||||
|
$settings,
|
||||||
|
$fields,
|
||||||
|
$webhook_registrar,
|
||||||
|
$cache,
|
||||||
|
$state,
|
||||||
|
$bearer,
|
||||||
|
$page_id,
|
||||||
|
$signup_link_cache,
|
||||||
|
$signup_link_ids
|
||||||
|
);
|
||||||
},
|
},
|
||||||
'wcgateway.order-processor' => static function ( ContainerInterface $container ): OrderProcessor {
|
'wcgateway.order-processor' => static function ( ContainerInterface $container ): OrderProcessor {
|
||||||
|
|
||||||
|
@ -2217,7 +2229,7 @@ return array(
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
|
||||||
'wcgateway.helper.vaulting-scope' => static function ( ContainerInterface $container ): bool {
|
'wcgateway.helper.vaulting-scope' => static function ( ContainerInterface $container ): bool {
|
||||||
try {
|
try {
|
||||||
$token = $container->get( 'api.bearer' )->bearer();
|
$token = $container->get( 'api.bearer' )->bearer();
|
||||||
return $token->vaulting_available();
|
return $token->vaulting_available();
|
||||||
|
@ -2226,7 +2238,7 @@ return array(
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
'button.helper.vaulting-label' => static function ( ContainerInterface $container ): string {
|
'button.helper.vaulting-label' => static function ( ContainerInterface $container ): string {
|
||||||
$vaulting_label = __( 'Enable saved cards and subscription features on your store.', 'woocommerce-paypal-payments' );
|
$vaulting_label = __( 'Enable saved cards and subscription features on your store.', 'woocommerce-paypal-payments' );
|
||||||
|
|
||||||
if ( ! $container->get( 'wcgateway.helper.vaulting-scope' ) ) {
|
if ( ! $container->get( 'wcgateway.helper.vaulting-scope' ) ) {
|
||||||
|
@ -2248,7 +2260,7 @@ return array(
|
||||||
return $vaulting_label;
|
return $vaulting_label;
|
||||||
},
|
},
|
||||||
|
|
||||||
'wcgateway.settings.fields.pay-later-label' => static function ( ContainerInterface $container ): string {
|
'wcgateway.settings.fields.pay-later-label' => static function ( ContainerInterface $container ): string {
|
||||||
$pay_later_label = '<span class="ppcp-pay-later-enabled-label">%s</span>';
|
$pay_later_label = '<span class="ppcp-pay-later-enabled-label">%s</span>';
|
||||||
$pay_later_label .= '<span class="ppcp-pay-later-disabled-label">';
|
$pay_later_label .= '<span class="ppcp-pay-later-disabled-label">';
|
||||||
$pay_later_label .= __( "You have PayPal vaulting enabled, that's why Pay Later Messaging options are unavailable now. You cannot use both features at the same time.", 'woocommerce-paypal-payments' );
|
$pay_later_label .= __( "You have PayPal vaulting enabled, that's why Pay Later Messaging options are unavailable now. You cannot use both features at the same time.", 'woocommerce-paypal-payments' );
|
||||||
|
|
|
@ -81,6 +81,20 @@ class SettingsListener {
|
||||||
*/
|
*/
|
||||||
protected $page_id;
|
protected $page_id;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The signup link cache.
|
||||||
|
*
|
||||||
|
* @var Cache
|
||||||
|
*/
|
||||||
|
protected $signup_link_cache;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Signup link ids
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
protected $signup_link_ids;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* SettingsListener constructor.
|
* SettingsListener constructor.
|
||||||
*
|
*
|
||||||
|
@ -91,6 +105,8 @@ class SettingsListener {
|
||||||
* @param State $state The state.
|
* @param State $state The state.
|
||||||
* @param Bearer $bearer The bearer.
|
* @param Bearer $bearer The bearer.
|
||||||
* @param string $page_id ID of the current PPCP gateway settings page, or empty if it is not such page.
|
* @param string $page_id ID of the current PPCP gateway settings page, or empty if it is not such page.
|
||||||
|
* @param Cache $signup_link_cache The signup link cache.
|
||||||
|
* @param array $signup_link_ids Signup link ids.
|
||||||
*/
|
*/
|
||||||
public function __construct(
|
public function __construct(
|
||||||
Settings $settings,
|
Settings $settings,
|
||||||
|
@ -99,7 +115,9 @@ class SettingsListener {
|
||||||
Cache $cache,
|
Cache $cache,
|
||||||
State $state,
|
State $state,
|
||||||
Bearer $bearer,
|
Bearer $bearer,
|
||||||
string $page_id
|
string $page_id,
|
||||||
|
Cache $signup_link_cache,
|
||||||
|
array $signup_link_ids
|
||||||
) {
|
) {
|
||||||
|
|
||||||
$this->settings = $settings;
|
$this->settings = $settings;
|
||||||
|
@ -109,6 +127,8 @@ class SettingsListener {
|
||||||
$this->state = $state;
|
$this->state = $state;
|
||||||
$this->bearer = $bearer;
|
$this->bearer = $bearer;
|
||||||
$this->page_id = $page_id;
|
$this->page_id = $page_id;
|
||||||
|
$this->signup_link_cache = $signup_link_cache;
|
||||||
|
$this->signup_link_ids = $signup_link_ids;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -260,6 +280,12 @@ class SettingsListener {
|
||||||
true
|
true
|
||||||
) ) {
|
) ) {
|
||||||
$this->webhook_registrar->unregister();
|
$this->webhook_registrar->unregister();
|
||||||
|
|
||||||
|
foreach ( $this->signup_link_ids as $key ) {
|
||||||
|
if ( $this->signup_link_cache->has( $key ) ) {
|
||||||
|
$this->signup_link_cache->delete( $key );
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -32,12 +32,12 @@ class SettingsListenerTest extends ModularTestCase
|
||||||
$webhook_registrar = Mockery::mock(WebhookRegistrar::class);
|
$webhook_registrar = Mockery::mock(WebhookRegistrar::class);
|
||||||
$webhook_registrar->shouldReceive('unregister')->andReturnTrue();
|
$webhook_registrar->shouldReceive('unregister')->andReturnTrue();
|
||||||
$webhook_registrar->shouldReceive('register')->andReturnTrue();
|
$webhook_registrar->shouldReceive('register')->andReturnTrue();
|
||||||
|
|
||||||
$cache = Mockery::mock(Cache::class);
|
$cache = Mockery::mock(Cache::class);
|
||||||
|
|
||||||
$state = Mockery::mock(State::class);
|
$state = Mockery::mock(State::class);
|
||||||
$state->shouldReceive('current_state')->andReturn(State::STATE_ONBOARDED);
|
$state->shouldReceive('current_state')->andReturn(State::STATE_ONBOARDED);
|
||||||
$bearer = Mockery::mock(Bearer::class);
|
$bearer = Mockery::mock(Bearer::class);
|
||||||
|
$signup_link_cache = Mockery::mock(Cache::class);
|
||||||
|
$signup_link_ids = array();
|
||||||
|
|
||||||
$testee = new SettingsListener(
|
$testee = new SettingsListener(
|
||||||
$settings,
|
$settings,
|
||||||
|
@ -46,7 +46,9 @@ class SettingsListenerTest extends ModularTestCase
|
||||||
$cache,
|
$cache,
|
||||||
$state,
|
$state,
|
||||||
$bearer,
|
$bearer,
|
||||||
PayPalGateway::ID
|
PayPalGateway::ID,
|
||||||
|
$signup_link_cache,
|
||||||
|
$signup_link_ids
|
||||||
);
|
);
|
||||||
|
|
||||||
$_GET['section'] = PayPalGateway::ID;
|
$_GET['section'] = PayPalGateway::ID;
|
||||||
|
@ -74,6 +76,8 @@ class SettingsListenerTest extends ModularTestCase
|
||||||
$settings->shouldReceive('persist');
|
$settings->shouldReceive('persist');
|
||||||
$cache->shouldReceive('has')
|
$cache->shouldReceive('has')
|
||||||
->andReturn(false);
|
->andReturn(false);
|
||||||
|
$signup_link_cache->shouldReceive('has')
|
||||||
|
->andReturn(false);
|
||||||
|
|
||||||
$testee->listen();
|
$testee->listen();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue