Skip to content

Commit a41a838

Browse files
committed
Add assertNotInstanceOf and assertNotSame
1 parent 336cb00 commit a41a838

File tree

4 files changed

+62
-8
lines changed

4 files changed

+62
-8
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ $extension->addToRunner($runner);
8181
| `assertInfinite(mixed $variable[, string $message = ''])` ||
8282
| `assertFinite(mixed $variable[, string $message = ''])` ||
8383
| `assertInstanceOf($expected, $actual[, $message = ''])` ||
84-
| `assertNotInstanceOf` ||
84+
| `assertNotInstanceOf($expected, $actual[, $message = ''])` ||
8585
| `assertInternalType($expected, $actual[, $message = ''])` ||
8686
| `assertNotInternalType` ||
8787
| `assertJsonFileEqualsJsonFile` ||
@@ -101,7 +101,7 @@ $extension->addToRunner($runner);
101101
| `assertStringMatchesFormatFile` ||
102102
| `assertStringNotMatchesFormatFile` ||
103103
| `assertSame(mixed $expected, mixed $actual[, string $message = ''])` ||
104-
| `assertNotSame` | |
104+
| `assertNotSame(mixed $expected, mixed $actual[, string $message = ''])` | |
105105
| `assertStringEndsWith` ||
106106
| `assertStringEndsNotWith` ||
107107
| `assertStringEqualsFile` ||
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<?php
2+
3+
namespace mageekguy\atoum\phpunit\constraints;
4+
5+
use
6+
mageekguy\atoum\asserters,
7+
mageekguy\atoum\exceptions\logic,
8+
mageekguy\atoum\phpunit\constraint
9+
;
10+
11+
class isNotInstanceOf extends constraint
12+
{
13+
private $expected;
14+
15+
public function __construct($expected, $description = null)
16+
{
17+
$this->expected = $expected;
18+
$this->description = $description;
19+
}
20+
21+
protected function matches($actual)
22+
{
23+
$asserter = new asserters\object();
24+
25+
try
26+
{
27+
$asserter->setWith($actual)->isNotInstanceOf($this->expected);
28+
}
29+
catch (logic $exception)
30+
{
31+
throw new \PHPUnit_Framework_Exception($exception->getMessage());
32+
}
33+
}
34+
}

classes/constraints/notSame.php

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<?php
2+
3+
namespace mageekguy\atoum\phpunit\constraints;
4+
5+
use
6+
mageekguy\atoum\asserters,
7+
mageekguy\atoum\phpunit\constraint
8+
;
9+
10+
class notSame extends constraint
11+
{
12+
private $expected;
13+
14+
public function __construct($expected, $description = null)
15+
{
16+
$this->expected = $expected;
17+
$this->description = $description;
18+
}
19+
20+
protected function matches($actual)
21+
{
22+
$asserter = new asserters\variable();
23+
$asserter->setWith($actual)->isNotIdenticalTo($this->expected);
24+
}
25+
}

tests/units/classes/constraints/equalsTest.php

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,8 @@ public function testClass()
2323
/**
2424
* @dataProvider equalProvider
2525
*/
26-
public function testAssertEqualsSucceeds($expected, $actual, $delta = null, $canonicalize = null, $ignoreCase = null, $skip = null)
26+
public function testAssertEqualsSucceeds($expected, $actual, $delta = null, $canonicalize = null, $ignoreCase = null)
2727
{
28-
if ($skip !== null)
29-
{
30-
$this->markTestSkipped($skip);
31-
}
32-
3328
$constraint = new testedClass($expected, null, $delta, 10, $canonicalize, $ignoreCase);
3429

3530
$this->assertSame($constraint, $constraint->evaluate($actual));

0 commit comments

Comments
 (0)