Skip to content

Commit

Permalink
Replace setExpectedException() with @ExpectedException
Browse files Browse the repository at this point in the history
  • Loading branch information
jsor committed Apr 13, 2019
1 parent 4250253 commit 5f67f82
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 15 deletions.
7 changes: 4 additions & 3 deletions tests/FunctionRejectTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,12 @@ public function shouldRejectAnException()
->then($this->expectCallableNever(), $mock);
}

/** @test */
/**
* @test
* @expectedException \InvalidArgumentException
*/
public function shouldThrowWhenCalledWithANonException()
{
$this->setExpectedException('\InvalidArgumentException');

reject(1);
}
}
21 changes: 12 additions & 9 deletions tests/PromiseTest/RejectTestTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,31 +31,34 @@ public function rejectShouldRejectWithAnException()
$adapter->reject($exception);
}

/** @test */
/**
* @test
* @expectedException \InvalidArgumentException
*/
public function rejectShouldThrowWhenCalledWithAnImmediateValue()
{
$this->setExpectedException('\InvalidArgumentException');

$adapter = $this->getPromiseTestAdapter();

$adapter->reject(1);
}

/** @test */
/**
* @test
* @expectedException \InvalidArgumentException
*/
public function rejectShouldThrowWhenCalledWithAFulfilledPromise()
{
$this->setExpectedException('\InvalidArgumentException');

$adapter = $this->getPromiseTestAdapter();

$adapter->reject(Promise\resolve(1));
}

/** @test */
/**
* @test
* @expectedException \InvalidArgumentException
*/
public function rejectShouldThrowWhenCalledWithARejectedPromise()
{
$this->setExpectedException('\InvalidArgumentException');

$adapter = $this->getPromiseTestAdapter();

$adapter->reject(Promise\reject(1));
Expand Down
7 changes: 4 additions & 3 deletions tests/RejectedPromiseTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,12 @@ public function getPromiseTestAdapter(callable $canceller = null)
]);
}

/** @test */
/**
* @test
* @expectedException \InvalidArgumentException
*/
public function shouldThrowExceptionIfConstructedWithANonException()
{
$this->setExpectedException('\InvalidArgumentException');

return new RejectedPromise('foo');
}
}

0 comments on commit 5f67f82

Please sign in to comment.