Skip to content

Commit d91bbe9

Browse files
committed
...
1 parent 1b9efa6 commit d91bbe9

File tree

4 files changed

+30
-7
lines changed

4 files changed

+30
-7
lines changed

.travis.yml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
language: php
22
php:
3-
- 5.5
4-
- 5.6
3+
- 5.5
4+
- 5.6
55
before_script:
6-
- composer install --no-interaction --prefer-dist
6+
- composer install --no-interaction --prefer-dist
77
script:
8-
- vendor/bin/phpunit --coverage-clover=coverage.clover
9-
- wget https://scrutinizer-ci.com/ocular.phar
10-
- php ocular.phar code-coverage:upload --format=php-clover coverage.clover
11-
- rm coverage.clover
8+
- vendor/bin/phpunit --coverage-clover=coverage.clover
9+
- wget https://scrutinizer-ci.com/ocular.phar
10+
- php ocular.phar code-coverage:upload --format=php-clover coverage.clover
11+
- rm coverage.clover

composer.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,16 @@
99
"email": "[email protected]"
1010
}
1111
],
12+
"require": {
13+
"php": ">=5.4.0"
14+
},
1215
"autoload": {
1316
"psr-4": {
1417
"TypedPHP\\Optional\\": "source"
1518
}
1619
},
1720
"require-dev": {
21+
"php": ">=5.5.0",
1822
"phpunit/phpunit": "4.*",
1923
"mockery/mockery": "0.*"
2024
},

source/Optional.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
namespace TypedPHP\Optional;
44

5+
use BadMethodCallException;
6+
57
class Optional
68
{
79
/**
@@ -56,6 +58,8 @@ public function __call($method, $parameters)
5658

5759
return new None();
5860
}
61+
62+
throw new BadMethodCallException("{$method} not implemented");
5963
}
6064

6165
/**

tests/OptionalTest.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace TypedPHP\Optional\Tests;
44

5+
use BadMethodCallException;
56
use Mockery;
67
use TypedPHP\Optional\None;
78
use TypedPHP\Optional\Optional;
@@ -135,4 +136,18 @@ public function itHandlesOptionalsCreatedWithNulls()
135136

136137
$this->assertTrue($flag);
137138
}
139+
140+
/**
141+
* @test
142+
*
143+
* @return void
144+
*/
145+
public function itThrowsIfMethodNotImplemented()
146+
{
147+
$optional = new Optional("hello world");
148+
149+
$this->setExpectedException(BadMethodCallException::class);
150+
151+
$optional->foo();
152+
}
138153
}

0 commit comments

Comments
 (0)