woocommerce/plugins/woocommerce-admin/tests/remote-inbox-notifications/wcadmin-active-for-rule-pro...

58 lines
1.3 KiB
PHP
Raw Normal View History

Add stored state between remote inbox notification runs (https://github.com/woocommerce/woocommerce-admin/pull/4260) * Fix comment and convert if..elseif to switch * Take out intermediate function * make ProductsProvider a non-static class * Adds RINDS data rule, and set up for woocommerce/woocommerce-admin#4223 # Conflicts: # src/RemoteInboxNotifications/EvaluateAndGetStatus.php * Fix rebase issues # Conflicts: # src/RemoteInboxNotifications/DataRuleProcessor.php * Split product data setup out, use product query # Conflicts: # src/RemoteInboxNotifications/RemoteInboxNotificationsEngine.php * Remove RINDS references * Remove unused products provider * Add validation to the data rule processor * Fix some issues that were failing tests * Remove unused var * Make data setup for products return the data object * Rework product query * Rename $data to $stored_state * Fix condition in query * Add time after wcadmin activation rule (https://github.com/woocommerce/woocommerce-admin/pull/4337) * Add wcadmin active for rule # Conflicts: # src/RemoteInboxNotifications/GetRuleProcessor.php * Use DAY_IN_SECONDS constant * Fix logic error * Fix test naming Co-authored-by: Rebecca Scott <me@becdetat.com> * Add order count rule (https://github.com/woocommerce/woocommerce-admin/pull/4335) * Order count rule # Conflicts: # src/RemoteInboxNotifications/GetRuleProcessor.php * Use default provider Co-authored-by: Rebecca Scott <me@becdetat.com> * Use correct 'return' value * Move back to using a SQL query to get the product count as the WC_Product_Query has issues during the product publish lifecycle. The product is initially published with a taxonomy term of uncategorized which isn't accepted by the query's filter. * Change back to using WC_Product_Query, and do prelim init via admin_init action * If there are no specs when running the engine, run the poller first then retry * Fix some failing tests * Don't perform init if we're feature toggled off * Move feature check inside RIN engine class because the feature filter isn't ready during FeaturePlugin init Co-authored-by: Rebecca Scott <me@becdetat.com>
2020-06-15 23:42:35 +00:00
<?php
/**
* WCAdmin active for rule processor tests.
*
* @package WooCommerce\Tests\RemoteInboxNotification
*/
use Automattic\WooCommerce\Admin\RemoteInboxNotifications\WCAdminActiveForRuleProcessor;
/**
* class WC_Tests_RemoteInboxNotifications_WCAdminActiveForRuleProcessor
*/
class WC_Tests_RemoteInboxNotifications_WCAdminActiveForRuleProcessor extends WC_Unit_Test_Case {
/**
* Greater than 7 days evaluates to true
*
* @group fast
*/
public function test_greater_than_7_days_evaluates_to_true() {
$processor = new WCAdminActiveForRuleProcessor(
new MockWCAdminActiveForProvider()
);
$rule = json_decode(
'{
"type": "wcadmin_active_for",
"operation": ">",
"days": 7
}'
);
$result = $processor->process( $rule, new stdClass() );
$this->assertEquals( true, $result );
}
/**
* Greater than 12 days evaluates to false
*
* @group fast
*/
public function test_greater_than_12_days_evaluates_to_false() {
$processor = new WCAdminActiveForRuleProcessor(
new MockWCAdminActiveForProvider()
);
$rule = json_decode(
'{
"type": "wcadmin_active_for",
"operation": ">",
"days": 12
}'
);
$result = $processor->process( $rule, new stdClass() );
$this->assertEquals( false, $result );
}
}