Fixing phpcs errors.
This commit is contained in:
parent
f789cc26b0
commit
9d8b93c074
|
@ -53,12 +53,12 @@ class TrackingController implements RegisterHooksInterface {
|
|||
|
||||
add_filter(
|
||||
'wc_order_source_attribution_allow_tracking',
|
||||
[ $this, 'is_wccom_tracking_allowed' ]
|
||||
array( $this, 'is_wccom_tracking_allowed' )
|
||||
);
|
||||
|
||||
add_action(
|
||||
'wp_enqueue_scripts',
|
||||
[ $this, 'enqueue_scripts' ]
|
||||
array( $this, 'enqueue_scripts' )
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,7 @@
|
|||
<?php
|
||||
/**
|
||||
* SourceAttribution test class.
|
||||
*/
|
||||
|
||||
namespace Automattic\WooCommerce\Tests\Internal\Admin\Orders\MetaBoxes;
|
||||
|
||||
|
@ -6,10 +9,18 @@ use Automattic\WooCommerce\Internal\Admin\Orders\MetaBoxes\SourceAttribution;
|
|||
use WC_Helper_Order;
|
||||
use WP_UnitTestCase;
|
||||
|
||||
/**
|
||||
* Tests for the SourceAttribution class.
|
||||
*/
|
||||
class SourceAttributionTest extends WP_UnitTestCase {
|
||||
|
||||
private $sut;
|
||||
|
||||
/**
|
||||
* Set up the test fixture.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setUp(): void {
|
||||
parent::setUp();
|
||||
$this->sut = new SourceAttribution();
|
||||
|
@ -74,21 +85,21 @@ class SourceAttributionTest extends WP_UnitTestCase {
|
|||
public function test_additional_order_meta_affects_arguments() {
|
||||
$order = WC_Helper_Order::create_order();
|
||||
|
||||
$meta = [
|
||||
'_wc_order_source_attribution_origin' => 'Referral: WooCommerce.com',
|
||||
'_wc_order_source_attribution_device_type' => 'Desktop',
|
||||
'_wc_order_source_attribution_user_agent' => 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/119.0.0.0 Safari/537.36',
|
||||
'_wc_order_source_attribution_session_count' => 1,
|
||||
'_wc_order_source_attribution_session_pages' => 4,
|
||||
$meta = array(
|
||||
'_wc_order_source_attribution_origin' => 'Referral: WooCommerce.com',
|
||||
'_wc_order_source_attribution_device_type' => 'Desktop',
|
||||
'_wc_order_source_attribution_user_agent' => 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/119.0.0.0 Safari/537.36',
|
||||
'_wc_order_source_attribution_session_count' => 1,
|
||||
'_wc_order_source_attribution_session_pages' => 4,
|
||||
'_wc_order_source_attribution_session_start_time' => '2023-11-16 13:47:50',
|
||||
'_wc_order_source_attribution_session_entry' => 'https://wordpress.ddev.site/product/belt/',
|
||||
'_wc_order_source_attribution_utm_content' => '/',
|
||||
'_wc_order_source_attribution_utm_medium' => 'referral',
|
||||
'_wc_order_source_attribution_utm_source' => 'woocommerce.com',
|
||||
'_wc_order_source_attribution_referrer' => 'https://woocommerce.com/',
|
||||
'_wc_order_source_attribution_source_type' => 'referral',
|
||||
];
|
||||
foreach ($meta as $key => $value) {
|
||||
'_wc_order_source_attribution_session_entry' => 'https://wordpress.ddev.site/product/belt/',
|
||||
'_wc_order_source_attribution_utm_content' => '/',
|
||||
'_wc_order_source_attribution_utm_medium' => 'referral',
|
||||
'_wc_order_source_attribution_utm_source' => 'woocommerce.com',
|
||||
'_wc_order_source_attribution_referrer' => 'https://woocommerce.com/',
|
||||
'_wc_order_source_attribution_source_type' => 'referral',
|
||||
);
|
||||
foreach ( $meta as $key => $value ) {
|
||||
$order->add_meta_data( $key, $value );
|
||||
}
|
||||
|
||||
|
|
|
@ -163,7 +163,7 @@ class AbstractInterfaceServiceProviderTest extends \WC_Unit_Test_Case {
|
|||
* Tests adding a class under alias returns the proper object.
|
||||
*
|
||||
* @return void
|
||||
* @throws ContainerException
|
||||
* @throws ContainerException Dependency injection error.
|
||||
*/
|
||||
public function test_add_with_implements_tags_with_concrete() {
|
||||
$this->sut->add_with_implements_tags( ClassWithNoInterface::class, ClassWithMultipleInterfaces::class );
|
||||
|
@ -201,7 +201,7 @@ class AbstractInterfaceServiceProviderTest extends \WC_Unit_Test_Case {
|
|||
* Tests sharing a class with multiple interfaces returns the same instance.
|
||||
*
|
||||
* @return void
|
||||
* @throws ContainerException
|
||||
* @throws ContainerException Dependency injection error.
|
||||
*/
|
||||
public function test_share_with_implements_tags_returns_the_same_instance() {
|
||||
$definition = $this->sut->share_with_implements_tags( ClassWithMultipleInterfaces::class, null );
|
||||
|
|
|
@ -1,4 +1,7 @@
|
|||
<?php
|
||||
/**
|
||||
* Class TrackingControllerTest
|
||||
*/
|
||||
|
||||
namespace Automattic\WooCommerce\Tests\Internal\WCCom;
|
||||
|
||||
|
@ -6,6 +9,11 @@ use Automattic\WooCommerce\Internal\Features\FeaturesController;
|
|||
use Automattic\WooCommerce\Internal\WCCom\TrackingController;
|
||||
use WP_UnitTestCase;
|
||||
|
||||
/**
|
||||
* Class TrackingControllerTest
|
||||
*
|
||||
* Contains tests for the TrackingController class.
|
||||
*/
|
||||
class TrackingControllerTest extends WP_UnitTestCase {
|
||||
|
||||
/**
|
||||
|
@ -15,6 +23,11 @@ class TrackingControllerTest extends WP_UnitTestCase {
|
|||
*/
|
||||
private $sut;
|
||||
|
||||
/**
|
||||
* Set up the test fixture.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setUp(): void {
|
||||
parent::setUp();
|
||||
$this->sut = new TrackingController();
|
||||
|
@ -42,13 +55,13 @@ class TrackingControllerTest extends WP_UnitTestCase {
|
|||
|
||||
$filter = has_filter(
|
||||
'wc_order_source_attribution_allow_tracking',
|
||||
[ $this->sut, 'is_wccom_tracking_allowed' ]
|
||||
array( $this->sut, 'is_wccom_tracking_allowed' )
|
||||
);
|
||||
$this->assertEquals( 10, $filter );
|
||||
|
||||
$action = has_action(
|
||||
'wp_enqueue_scripts',
|
||||
[ $this->sut, 'enqueue_scripts' ]
|
||||
array( $this->sut, 'enqueue_scripts' )
|
||||
);
|
||||
$this->assertEquals( 10, $action );
|
||||
}
|
||||
|
@ -73,13 +86,13 @@ class TrackingControllerTest extends WP_UnitTestCase {
|
|||
|
||||
$filter = has_filter(
|
||||
'wc_order_source_attribution_allow_tracking',
|
||||
[ $this->sut, 'is_wccom_tracking_allowed' ]
|
||||
array( $this->sut, 'is_wccom_tracking_allowed' )
|
||||
);
|
||||
$this->assertFalse( $filter );
|
||||
|
||||
$action = has_action(
|
||||
'wp_enqueue_scripts',
|
||||
[ $this->sut, 'enqueue_scripts' ]
|
||||
array( $this->sut, 'enqueue_scripts' )
|
||||
);
|
||||
$this->assertFalse( $action );
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue