Skip to content

Commit

Permalink
NEXT-39769 - Changed the exception message to be more contextual and …
Browse files Browse the repository at this point in the history
…added test for custom exception.
  • Loading branch information
nsaliu committed Nov 29, 2024
1 parent 69ac305 commit d8d1833
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/Exception/ShopURLIsNotReachableException.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ public function __construct(string $shopUrl, ?\Throwable $previous = null)
{
parent::__construct(
sprintf(
'Shop URL "%s" is not reachable from the internet and cannot be registered.',
'Shop URL "%s" is not reachable from the application server.',
$shopUrl
),
0,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public function testListenerMustBeExecutedWithoutErrorsIfTheCheckIsSetToTrueInCo
public function testListenerMustThrowExceptionBecauseTheShopURLIsNotReachable(): void
{
$this->expectException(ShopURLIsNotReachableException::class);
$this->expectExceptionMessage('Shop URL "https://shop-url.com" is not reachable from the internet and cannot be registered.');
$this->expectExceptionMessage('Shop URL "https://shop-url.com" is not reachable from the application server.');

$shop = $this->createMock(ShopInterface::class);
$shop
Expand Down
28 changes: 28 additions & 0 deletions tests/Exception/ShopURLIsNotReachableExceptionTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?php

declare(strict_types=1);

namespace Exception;

use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\TestCase;
use Shopware\AppBundle\Exception\ShopURLIsNotReachableException;

#[CoversClass(ShopURLIsNotReachableException::class)]
class ShopURLIsNotReachableExceptionTest extends TestCase
{
public function testExceptionMessage(): void
{
$shopUrl = 'http://example.com';

$exception = new ShopURLIsNotReachableException($shopUrl);

static::assertSame(
sprintf(
'Shop URL "%s" is not reachable from the application server.',
$shopUrl
),
$exception->getMessage()
);
}
}

0 comments on commit d8d1833

Please sign in to comment.