Skip to content

Commit 9aae8f8

Browse files
authored
Merge pull request #39 from mcurran-inviqa/feature/phpspec3.2-tests
add tests for the 3 new matchers in 3.2 Fixes issue #38
2 parents 8fac895 + 1b61cf8 commit 9aae8f8

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

tests/ExpectTest.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,10 @@ function correctExpectations()
4343
[ function () { expect('foo bar')->toStartWith('foo'); } ],
4444
[ function () { expect('foo bar')->toEndWith('bar'); } ],
4545
[ function () { expect('foo bar')->toMatch('/bar/'); } ],
46-
[ function () { expect((new Foo()))->toThrow('InvalidArgumentException')->duringThrowException(); } ]
46+
[ function () { expect((new Foo()))->toThrow('InvalidArgumentException')->duringThrowException(); } ],
47+
[ function () { expect((new Foo()))->toTrigger(E_USER_DEPRECATED)->duringTriggerError(); } ],
48+
[ function () { expect(1.444447777)->toBeApproximately(1.444447777, 1.0e-9); } ],
49+
[ function () { expect((new Foo())->getIterator())->toIterateAs(new \ArrayIterator(['Foo', 'Bar'])); } ],
4750
];
4851
}
4952

@@ -67,7 +70,9 @@ function incorrectExpectations()
6770
[ function () { expect('foo bar')->toStartWith('baz'); } ],
6871
[ function () { expect('foo bar')->toEndWith('baz'); } ],
6972
[ function () { expect('foo bar')->toMatch('/baz/'); } ],
70-
[ function () { expect((new Foo()))->toThrow('AnotherException')->duringThrowException(); } ]
73+
[ function () { expect((new Foo()))->toThrow('AnotherException')->duringThrowException(); } ],
74+
[ function () { expect(1.444447777)->toBeApproximately(1.444447778, 1.0e-9); } ],
75+
[ function () { expect((new Foo())->getIterator())->toIterateAs(new \ArrayIterator(['Bar', 'Foo'])); } ]
7176
];
7277
}
7378
}

tests/Foo.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,12 @@ public function throwException()
2525
{
2626
throw new InvalidArgumentException;
2727
}
28+
public function triggerError()
29+
{
30+
trigger_error('The method triggerError is deprecated.', E_USER_DEPRECATED);
31+
}
32+
public function getIterator()
33+
{
34+
return new \ArrayIterator(['Foo', 'Bar']);
35+
}
2836
}

0 commit comments

Comments
 (0)