Skip to content

Commit bac84d7

Browse files
authored
Merge pull request #1 from technically-php/support/spec-tests
Support - BDD tests
2 parents bdfa1ad + faaa4ed commit bac84d7

10 files changed

+54
-124
lines changed

.github/workflows/test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ jobs:
66
runs-on: ubuntu-latest
77
strategy:
88
matrix:
9-
php: [ '7.0', '7.1', '7.2', '7.3', '7.4', '8.0' ]
9+
php: [ '7.1', '7.2', '7.3', '7.4', '8.0' ]
1010

1111
steps:
1212
- uses: actions/checkout@master

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

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ but don't want to deal with nullable values.
1010
## Features
1111

1212
- PSR-11
13-
- PHP 7.0+
13+
- PHP 7.1+
1414
- PHP 8.0
1515
- Semver
1616
- Tests

composer.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,12 @@
33
"description": "Null (always empty) PSR-11 container implementation",
44
"type": "library",
55
"require": {
6-
"php": ">=7.0",
6+
"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)