Add more specific exceptions
This commit is contained in:
@ -3,7 +3,7 @@
|
||||
declare(strict_types=1);
|
||||
|
||||
use Nsq\Consumer;
|
||||
use Nsq\Exception;
|
||||
use Nsq\Exception\MessageAlreadyFinished;
|
||||
use Nsq\Message;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
@ -20,7 +20,7 @@ final class MessageTest extends TestCase
|
||||
|
||||
self::assertTrue($message->isFinished());
|
||||
|
||||
$this->expectException(Exception::class);
|
||||
$this->expectException(MessageAlreadyFinished::class);
|
||||
$this->expectExceptionMessage('Can\'t finish message as it already finished.');
|
||||
|
||||
$message->finish();
|
||||
@ -37,7 +37,7 @@ final class MessageTest extends TestCase
|
||||
|
||||
self::assertTrue($message->isFinished());
|
||||
|
||||
$this->expectException(Exception::class);
|
||||
$this->expectException(MessageAlreadyFinished::class);
|
||||
$this->expectExceptionMessage('Can\'t requeue message as it already finished.');
|
||||
|
||||
$message->requeue(5);
|
||||
@ -52,7 +52,7 @@ final class MessageTest extends TestCase
|
||||
|
||||
$message->finish();
|
||||
|
||||
$this->expectException(Exception::class);
|
||||
$this->expectException(MessageAlreadyFinished::class);
|
||||
$this->expectExceptionMessage('Can\'t touch message as it already finished.');
|
||||
|
||||
$message->touch();
|
||||
|
@ -2,6 +2,7 @@
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
use Nsq\Exception\NsqError;
|
||||
use Nsq\Producer;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
@ -12,7 +13,7 @@ final class ProducerTest extends TestCase
|
||||
*/
|
||||
public function testPubFail(string $topic, string $body, string $exceptionMessage): void
|
||||
{
|
||||
$this->expectException(Exception::class);
|
||||
$this->expectException(NsqError::class);
|
||||
$this->expectExceptionMessage($exceptionMessage);
|
||||
|
||||
$producer = new Producer('tcp://localhost:4150');
|
||||
|
@ -34,7 +34,7 @@ final class SubscriberTest extends TestCase
|
||||
|
||||
public function testInvalidChangeInterval(): void
|
||||
{
|
||||
$this->expectException(\Nsq\Exception::class);
|
||||
$this->expectException(InvalidArgumentException::class);
|
||||
$this->expectExceptionMessage('Timeout must be float, "string" given.');
|
||||
|
||||
$generator = $this->subscriber->subscribe(__FUNCTION__, __FUNCTION__);
|
||||
|
Reference in New Issue
Block a user