Skip to content

Commit

Permalink
refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
osorioramirez committed May 1, 2016
1 parent c5a810f commit b727958
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
3 changes: 3 additions & 0 deletions Promise/FulfilledPromise.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ class FulfilledPromise extends AbstractPromise
*/
public function __construct($value = null)
{
if ($value instanceof PromiseInterface) {
throw new \InvalidArgumentException(\sprintf('You cannot create %s with a promise.', self::class));
}
$this->value = $value;
}

Expand Down
14 changes: 13 additions & 1 deletion Tests/Units/Promise/FulfilledPromiseTests.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace Cubiche\Core\Async\Tests\Units\Promise;

/**
Expand All @@ -35,4 +34,17 @@ protected function promiseDataProvider()
array($this->newDefaultTestedInstance()),
);
}

/**
* Test __construct.
*/
public function testConstruct()
{
$this
->exception(function () {
$this->newTestedInstance($this->newDefaultTestedInstance());
})
->isInstanceOf(\InvalidArgumentException::class)
;
}
}

0 comments on commit b727958

Please sign in to comment.