-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #33 from shopware/brain-10/implement-logging
BRAIN-10 - Implement logging
- Loading branch information
Showing
13 changed files
with
161 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
src/Braintree/Exception/BraintreeTransactionNotFoundException.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<?php declare(strict_types=1); | ||
|
||
namespace Swag\Braintree\Braintree\Exception; | ||
|
||
use Shopware\App\SDK\Shop\ShopInterface; | ||
use Swag\Braintree\Framework\Exception\BraintreeHttpException; | ||
use Symfony\Component\HttpFoundation\Response; | ||
|
||
class BraintreeTransactionNotFoundException extends BraintreeHttpException | ||
{ | ||
public const ERROR_CODE = 'SWAG_BRAINTREE__TRANSACTION_NOT_FOUND'; | ||
|
||
/** | ||
* @param string[] $orderTransactionIds | ||
*/ | ||
public function __construct(array $orderTransactionIds, ShopInterface $shop, string $braintreeTransactionId = null, array $parameters = []) | ||
{ | ||
$parameters['shopId'] = $shop->getShopId(); | ||
$parameters['orderTransactionIds'] = $orderTransactionIds; | ||
if ($braintreeTransactionId) { | ||
$parameters['braintreeTransactionId'] = $braintreeTransactionId; | ||
} | ||
|
||
parent::__construct('Braintree transaction not found', $parameters); | ||
} | ||
|
||
public function getErrorCode(): string | ||
{ | ||
return self::ERROR_CODE; | ||
} | ||
|
||
public function getStatusCode(): int | ||
{ | ||
return Response::HTTP_BAD_REQUEST; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
tests/unit/Braintree/Exception/BraintreeTransactionNotFoundExceptionTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<?php declare(strict_types=1); | ||
|
||
namespace Swag\Braintree\Tests\Unit\Braintree\Exception; | ||
|
||
use PHPUnit\Framework\Attributes\CoversClass; | ||
use PHPUnit\Framework\TestCase; | ||
use Swag\Braintree\Braintree\Exception\BraintreeTransactionNotFoundException; | ||
use Swag\Braintree\Entity\ShopEntity; | ||
use Symfony\Component\HttpFoundation\Response; | ||
|
||
#[CoversClass(BraintreeTransactionNotFoundException::class)] | ||
class BraintreeTransactionNotFoundExceptionTest extends TestCase | ||
{ | ||
public function testConstruct(): void | ||
{ | ||
$orderTransactionIds = ['this-is-order-transaction-id']; | ||
$shop = new ShopEntity('this-is-shop-id', '', ''); | ||
$exception = new BraintreeTransactionNotFoundException($orderTransactionIds, $shop, 'this-is-braintree-transaction-id'); | ||
|
||
static::assertSame('SWAG_BRAINTREE__TRANSACTION_NOT_FOUND', $exception->getErrorCode()); | ||
static::assertSame('Braintree transaction not found', $exception->getMessage()); | ||
static::assertSame(Response::HTTP_BAD_REQUEST, $exception->getStatusCode()); | ||
|
||
$params = $exception->getParameters(); | ||
static::assertSame($shop->getShopId(), $params['shopId']); | ||
static::assertSame($orderTransactionIds, $params['orderTransactionIds']); | ||
static::assertSame('this-is-braintree-transaction-id', $params['braintreeTransactionId']); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.