getErrorsForTaxProvider example


class TaxProviderExceptionsTest extends TestCase
{
    public function testException(): void
    {
        $e = new TaxProviderExceptions();

        static::assertSame('CHECKOUT__TAX_PROVIDER_EXCEPTION', $e->getErrorCode());
        static::assertSame('There was an error while calculating taxes', $e->getMessage());
        static::assertFalse($e->hasExceptions());
        static::assertEmpty($e->getErrorsForTaxProvider('foo'));
    }

    public function testAddException(): void
    {
        $e = new TaxProviderExceptions();

        $e->add('tax_provider', new \Exception('bar'));

        static::assertTrue($e->hasExceptions());
        static::assertSame('There were 1 errors while fetching taxes from providers: ' . \PHP_EOL . 'Tax provider \'tax_provider\' threw an exception: bar' . \PHP_EOL, $e->getMessage());
        static::assertCount(1, $e->getErrorsForTaxProvider('tax_provider'));
        
Home | Imprint | This part of the site doesn't use cookies.