Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' of https://github.com/elliotchance/concise into…
… feature/72-expose-method-for-mocks
- Loading branch information
Showing
10 changed files
with
213 additions
and
1 deletion.
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
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,23 @@ | ||
<?php | ||
|
||
namespace Concise\Matcher; | ||
|
||
class ContainsString extends AbstractMatcher | ||
{ | ||
public function supportedSyntaxes() | ||
{ | ||
return array( | ||
'?:string contains string ?:string' => 'A string contains a substring', | ||
); | ||
} | ||
|
||
public function match($syntax, array $data = array()) | ||
{ | ||
return strpos($data[0], $data[1]) !== false; | ||
} | ||
|
||
public function getTags() | ||
{ | ||
return array(Tag::STRINGS); | ||
} | ||
} |
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,23 @@ | ||
<?php | ||
|
||
namespace Concise\Matcher; | ||
|
||
class ContainsStringIgnoringCase extends ContainsString | ||
{ | ||
public function supportedSyntaxes() | ||
{ | ||
return array( | ||
'?:string contains string ?:string ignoring case' => 'A string contains a substring (ignoring case-sensitivity)', | ||
); | ||
} | ||
|
||
public function match($syntax, array $data = array()) | ||
{ | ||
return parent::match(null, array(strtolower($data[0]), strtolower($data[1]))); | ||
} | ||
|
||
public function getTags() | ||
{ | ||
return array(Tag::STRINGS); | ||
} | ||
} |
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,23 @@ | ||
<?php | ||
|
||
namespace Concise\Matcher; | ||
|
||
class DoesNotContainString extends ContainsString | ||
{ | ||
public function supportedSyntaxes() | ||
{ | ||
return array( | ||
'?:string does not contain string ?:string' => 'A string does not contain a substring.', | ||
); | ||
} | ||
|
||
public function match($syntax, array $data = array()) | ||
{ | ||
return !parent::match(null, $data); | ||
} | ||
|
||
public function getTags() | ||
{ | ||
return array(Tag::STRINGS); | ||
} | ||
} |
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,23 @@ | ||
<?php | ||
|
||
namespace Concise\Matcher; | ||
|
||
class DoesNotContainStringIgnoringCase extends ContainsStringIgnoringCase | ||
{ | ||
public function supportedSyntaxes() | ||
{ | ||
return array( | ||
'?:string does not contain string ?:string ignoring case' => 'A string does not contain a substring (ignoring case-sensitivity)', | ||
); | ||
} | ||
|
||
public function match($syntax, array $data = array()) | ||
{ | ||
return !parent::match(null, $data); | ||
} | ||
|
||
public function getTags() | ||
{ | ||
return array(Tag::STRINGS); | ||
} | ||
} |
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,29 @@ | ||
<?php | ||
|
||
namespace Concise\Matcher; | ||
|
||
use \Concise\TestCase; | ||
|
||
class ContainsStringIgnoringCaseTest extends AbstractMatcherTestCase | ||
{ | ||
public function setUp() | ||
{ | ||
parent::setUp(); | ||
$this->matcher = new ContainsStringIgnoringCase(); | ||
} | ||
|
||
public function testSuccessIfStringContainsASubstring() | ||
{ | ||
$this->assert('foobar', contains_string, 'oob', ignoring_case); | ||
} | ||
|
||
public function testFailsIfSubstringDoesNotExistInString() | ||
{ | ||
$this->assertFailure('foobar', contains_string, 'baz', ignoring_case); | ||
} | ||
|
||
public function testIsNotSensitiveToCase() | ||
{ | ||
$this->assert('foobar', contains_string, 'Foo', ignoring_case); | ||
} | ||
} |
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,29 @@ | ||
<?php | ||
|
||
namespace Concise\Matcher; | ||
|
||
use \Concise\TestCase; | ||
|
||
class ContainsStringTest extends AbstractMatcherTestCase | ||
{ | ||
public function setUp() | ||
{ | ||
parent::setUp(); | ||
$this->matcher = new ContainsString(); | ||
} | ||
|
||
public function testSuccessIfStringContainsASubstring() | ||
{ | ||
$this->assert('foobar', contains_string, 'oob'); | ||
} | ||
|
||
public function testFailsIfSubstringDoesNotExistInString() | ||
{ | ||
$this->assertFailure('foobar', contains_string, 'baz'); | ||
} | ||
|
||
public function testIsSensitiveToCase() | ||
{ | ||
$this->assertFailure('foobar', contains_string, 'Foo'); | ||
} | ||
} |
29 changes: 29 additions & 0 deletions
29
tests/Concise/Matcher/DoesNotContainStringIgnoringCaseTest.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,29 @@ | ||
<?php | ||
|
||
namespace Concise\Matcher; | ||
|
||
use \Concise\TestCase; | ||
|
||
class DoesNotContainStringIgnoringCaseTest extends AbstractMatcherTestCase | ||
{ | ||
public function setUp() | ||
{ | ||
parent::setUp(); | ||
$this->matcher = new DoesNotContainStringIgnoringCase(); | ||
} | ||
|
||
public function testSuccessIfStringContainsASubstring() | ||
{ | ||
$this->assertFailure('foobar', does_not_contain_string, 'oob', ignoring_case); | ||
} | ||
|
||
public function testFailsIfSubstringDoesNotExistInString() | ||
{ | ||
$this->assert('foobar', does_not_contain_string, 'baz', ignoring_case); | ||
} | ||
|
||
public function testIsNotSensitiveToCase() | ||
{ | ||
$this->assertFailure('foobar', does_not_contain_string, 'Foo', ignoring_case); | ||
} | ||
} |
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,29 @@ | ||
<?php | ||
|
||
namespace Concise\Matcher; | ||
|
||
use \Concise\TestCase; | ||
|
||
class DoesNotContainStringTest extends AbstractMatcherTestCase | ||
{ | ||
public function setUp() | ||
{ | ||
parent::setUp(); | ||
$this->matcher = new DoesNotContainString(); | ||
} | ||
|
||
public function testSuccessIfStringContainsASubstring() | ||
{ | ||
$this->assertFailure('foobar', does_not_contain_string, 'oob'); | ||
} | ||
|
||
public function testFailsIfSubstringDoesNotExistInString() | ||
{ | ||
$this->assert('foobar', does_not_contain_string, 'baz'); | ||
} | ||
|
||
public function testIsSensitiveToCase() | ||
{ | ||
$this->assert('foobar', does_not_contain_string, 'Foo'); | ||
} | ||
} |
Submodule wiki
updated
from f55d3a to d8c828