Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add range operator in Remote Inbox Notification (#45201)
* Add range rule in Remote Inbox Notification * Add changefile(s) from automation for the following project(s): woocommerce * Add range * Add changefile(s) from automation for the following project(s): packages/php/remote-specs-validation, woocommerce * Update README.md * Fix lint errors * Make sure right-hand is an array with two elemetns -- range * Update README * Lint fixes --------- Co-authored-by: github-actions <github-actions@github.com>
- Loading branch information
Showing
11 changed files
with
142 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -59,7 +59,8 @@ | |
"contains", | ||
"!contains", | ||
"in", | ||
"!in" | ||
"!in", | ||
"range" | ||
] | ||
}, | ||
"rules": { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -728,7 +728,8 @@ | |
"contains", | ||
"!contains", | ||
"in", | ||
"!in" | ||
"!in", | ||
"range" | ||
] | ||
}, | ||
"rules": { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -147,7 +147,8 @@ | |
"contains", | ||
"!contains", | ||
"in", | ||
"!in" | ||
"!in", | ||
"range" | ||
] | ||
}, | ||
"rules": { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -711,7 +711,8 @@ | |
"contains", | ||
"!contains", | ||
"in", | ||
"!in" | ||
"!in", | ||
"range" | ||
] | ||
}, | ||
"rules": { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -708,7 +708,8 @@ | |
"contains", | ||
"!contains", | ||
"in", | ||
"!in" | ||
"!in", | ||
"range" | ||
] | ||
}, | ||
"rules": { | ||
|
4 changes: 4 additions & 0 deletions
4
packages/php/remote-specs-validation/changelog/45201-add-44787-add-range-rule
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
Significance: minor | ||
Type: add | ||
|
||
Support range operator in Remote Inbox Notification |
2 changes: 1 addition & 1 deletion
2
packages/php/remote-specs-validation/schemas/shared/operations.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
{ | ||
"type": "string", | ||
"enum": ["=", "<", "<=", ">", ">=", "!=", "contains", "!contains", "in", "!in"] | ||
"enum": ["=", "<", "<=", ">", ">=", "!=", "contains", "!contains", "in", "!in", "range"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
Significance: minor | ||
Type: add | ||
|
||
Support range operator in Remote Inbox Notification |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
85 changes: 85 additions & 0 deletions
85
...s/legacy/unit-tests/woocommerce-admin/remote-inbox-notifications/comparison-operation.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
<?php | ||
/** | ||
* ComparisonOperation Tests | ||
* | ||
* @package WooCommerce\Admin\Tests\RemoteInboxNotification | ||
*/ | ||
|
||
use Automattic\WooCommerce\Admin\RemoteInboxNotifications\ComparisonOperation; | ||
|
||
/** | ||
* class WC_Admin_Tests_RemoteInboxNotifications_Comparison_Operation | ||
*/ | ||
class WC_Admin_Tests_RemoteInboxNotifications_Comparison_Operation extends WC_Unit_Test_Case { | ||
/** | ||
* @var ComparisonOperation $operation | ||
*/ | ||
private $operation; | ||
|
||
/** | ||
* setUp | ||
* @return void | ||
*/ | ||
public function setUp(): void { | ||
parent::setUp(); | ||
$this->operation = new ComparisonOperation(); | ||
} | ||
|
||
/** | ||
* Test range | ||
* | ||
* @group fast | ||
* @return void | ||
*/ | ||
public function test_range() { | ||
$this->assertTrue( $this->operation->compare( 1, array( 1, 10 ), 'range' ) ); | ||
$this->assertFalse( $this->operation->compare( 11, array( 1, 10 ), 'range' ) ); | ||
$this->assertFalse( $this->operation->compare( 11, array( 1, 10, 2 ), 'range' ) ); | ||
$this->assertFalse( $this->operation->compare( 11, 'string', 'range' ) ); | ||
|
||
} | ||
|
||
/** | ||
* Test contains | ||
* | ||
* @group fast | ||
* @return void | ||
*/ | ||
public function test_contains() { | ||
$this->assertTrue( $this->operation->compare( array( 'test', 'test1' ), 'test', 'contains' ) ); | ||
$this->assertFalse( $this->operation->compare( array( 'a', 'b' ), 'test', 'contains' ) ); | ||
} | ||
|
||
/** | ||
* Test !contains | ||
* | ||
* @group fast | ||
* @return void | ||
*/ | ||
public function test_not_contains() { | ||
$this->assertTrue( $this->operation->compare( array( 'test1', 'test2' ), 'test', '!contains' ) ); | ||
$this->assertFalse( $this->operation->compare( array( 'test' ), 'test', '!contains' ) ); | ||
} | ||
|
||
/** | ||
* Test in | ||
* | ||
* @group fast | ||
* @return void | ||
*/ | ||
public function test_in() { | ||
$this->assertTrue( $this->operation->compare( 'test', array( 'test', 'test2' ), 'in' ) ); | ||
$this->assertFalse( $this->operation->compare( 'test', array( 'test1', 'test2' ), 'in' ) ); | ||
} | ||
|
||
/** | ||
* Test !in | ||
* | ||
* @group fast | ||
* @return void | ||
*/ | ||
public function test_not_in() { | ||
$this->assertTrue( $this->operation->compare( 'test', array( 'test1', 'test2' ), '!in' ) ); | ||
$this->assertFalse( $this->operation->compare( 'test', array( 'test', 'test2' ), '!in' ) ); | ||
} | ||
} |