Skip to content

Commit faaa4ed

Browse files
committed
Rewrite tests to Peridot
A simple BDD testing framework
1 parent 1d19169 commit faaa4ed

8 files changed

+51
-121
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
.PHONY: tests
22

33
tests: vendor
4-
php -d zend.assertions=1 -d assert.exception=1 test.php
4+
php -d zend.assertions=1 -d assert.exception=1 vendor/bin/peridot ./specs
55

66
vendor: composer.json composer.lock
77
composer install

composer.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@
66
"php": ">=7.1",
77
"psr/container": "^1.0"
88
},
9+
"require-dev": {
10+
"peridot-php/peridot": "^1.19"
11+
},
912
"license": "MIT",
1013
"authors": [
1114
{

specs/null-container.spec.php

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
<?php
2+
3+
use Psr\Container\ContainerInterface;
4+
use Psr\Container\NotFoundExceptionInterface;
5+
use Technically\NullContainer\Exceptions\ServiceNotFound;
6+
use Technically\NullContainer\NullContainer;
7+
8+
describe('NullContainer', function() {
9+
10+
it('should instantiate a new instance', function() {
11+
$container = new NullContainer();
12+
assert($container instanceof NullContainer);
13+
});
14+
15+
it('should implement PSR container interface', function() {
16+
$container = new NullContainer();
17+
assert($container instanceof ContainerInterface);
18+
});
19+
20+
describe('->has()', function() {
21+
it('should always return false', function () {
22+
$container = new NullContainer();
23+
24+
assert($container->has('a') === false);
25+
assert($container->has('b') === false);
26+
assert($container->has('c') === false);
27+
assert($container->has(NullContainer::class) === false);
28+
assert($container->has(ContainerInterface::class) === false);
29+
});
30+
});
31+
32+
describe('->get()', function() {
33+
it('should always throw ServiceNotFound exception', function () {
34+
$container = new NullContainer();
35+
36+
try {
37+
$container->get('a');
38+
} catch (ServiceNotFound $exception) {
39+
// passthru
40+
}
41+
42+
assert(isset($exception));
43+
assert($exception instanceof ServiceNotFound);
44+
assert($exception instanceof NotFoundExceptionInterface);
45+
});
46+
});
47+
});

test.php

Lines changed: 0 additions & 76 deletions
This file was deleted.

tests/it_should_always_report_service_not_defined.php

Lines changed: 0 additions & 12 deletions
This file was deleted.

tests/it_should_always_throw_service_not_found.php

Lines changed: 0 additions & 17 deletions
This file was deleted.

tests/it_should_implement_psr_container_interface.php

Lines changed: 0 additions & 8 deletions
This file was deleted.

tests/it_should_instantiate.php

Lines changed: 0 additions & 7 deletions
This file was deleted.

0 commit comments

Comments
 (0)