Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add a contain operator #24

Merged
merged 1 commit into from
Jan 6, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# `dev-master`

* [#24](https://github.com/atoum/ruler-extension/pull/24) Add a contain operator ([@agallou])

# 1.0.3 - 2015-06-24

* [#17](https://github.com/atoum/ruler-extension/pull/17) Move to Hoa\Ustring ([@Metalaka](https://github.com/Metalaka))
Expand Down
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,17 @@ Those variables are available in the filter:

Run all tests except those who have the `needsDatabase` tag:

```
./vendor/bin/atoum -d tests --filter 'not (tags contains "needsDatabase")'
```

You can also use the ruler's default `in` operator, but in that case that's less readable:

```
./vendor/bin/atoum -d tests --filter 'not ("needsDatabase" in tags)'
```


Run all tests with a method named `testMethod1`:

```
Expand Down
1 change: 1 addition & 0 deletions classes/ruler.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ public function __construct($rule)
{
$this->rule = HoaRuler::interpret($rule);
$this->ruler = new HoaRuler();
$this->ruler->getAsserter()->setOperator('contains', function (Array $a, $b) { return in_array($b, $a); });
}

/**
Expand Down
3 changes: 3 additions & 0 deletions tests/units/classes/ruler.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@ protected function testFilterDataProvider()
'not("unSuperTagAuNiveauDeLaMethode1" in tags)' => array(
'testMethod1' => true,
),
'not(tags contains "unSuperTagAuNiveauDeLaMethode1")' => array(
'testMethod1' => true,
),
'method = "testMethod1"' => array(
'testMethod1' => false,
),
Expand Down