Skip to content

Commit 643c575

Browse files
authored
refactor #768 Move some namespaces on Exceptions (loic425)
This PR was merged into the 1.11 branch. Discussion ---------- | Q | A | --------------- | ----- | Bug fix? | no | New feature? | no | BC breaks? | no | Deprecations? | no | Related tickets | | License | MIT Commits ------- 2a61679 Move some namespaces on Exceptions bfa6df9 Fix Psam errors 165873a Fix PHPStan errors 16cdabb Remove translatable factory spec 109800f Move spec file b96ee2b Test the alias cc473c0 Add InvalidArgumentException & Exception e945ee9 Test the aliases
2 parents ae389bf + e945ee9 commit 643c575

29 files changed

+327
-156
lines changed

phpstan.neon

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ parameters:
2525
- %currentWorkingDirectory%/src/Bundle/Tests/*
2626
- %currentWorkingDirectory%/src/Component/legacy/spec/*
2727
- %currentWorkingDirectory%/src/Component/legacy/src/Annotation/*
28+
- %currentWorkingDirectory%/src/Component/legacy/src/Exception/*
2829
- %currentWorkingDirectory%/src/Component/legacy/src/Factory/*
2930
- %currentWorkingDirectory%/src/Component/legacy/src/Generator/*
3031
- %currentWorkingDirectory%/src/Component/legacy/src/Metadata/*

psalm.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,7 @@
227227
<TypeDoesNotContainType>
228228
<errorLevel type="suppress">
229229
<directory name="src/Component/legacy/src/Annotation" />
230+
<directory name="src/Component/legacy/src/Exception" />
230231
<directory name="src/Component/legacy/src/Factory" />
231232
<directory name="src/Component/legacy/src/Generator" />
232233
<directory name="src/Component/legacy/src/Metadata" />

src/Bundle/Controller/ResourceController.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@
1616
use Doctrine\Persistence\ObjectManager;
1717
use FOS\RestBundle\View\View;
1818
use Sylius\Bundle\ResourceBundle\Event\ResourceControllerEvent;
19-
use Sylius\Component\Resource\Exception\DeleteHandlingException;
20-
use Sylius\Component\Resource\Exception\UpdateHandlingException;
2119
use Sylius\Resource\Doctrine\Persistence\RepositoryInterface;
20+
use Sylius\Resource\Exception\DeleteHandlingException;
21+
use Sylius\Resource\Exception\UpdateHandlingException;
2222
use Sylius\Resource\Factory\FactoryInterface;
2323
use Sylius\Resource\Metadata\MetadataInterface;
2424
use Sylius\Resource\Model\ResourceInterface;

src/Bundle/Form/EventSubscriber/AddCodeFormSubscriber.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
namespace Sylius\Bundle\ResourceBundle\Form\EventSubscriber;
1515

16-
use Sylius\Component\Resource\Exception\UnexpectedTypeException;
16+
use Sylius\Resource\Exception\UnexpectedTypeException;
1717
use Sylius\Resource\Model\CodeAwareInterface;
1818
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
1919
use Symfony\Component\Form\Extension\Core\Type\TextType;

src/Bundle/spec/Controller/ResourceControllerSpec.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@
3333
use Sylius\Bundle\ResourceBundle\Controller\StateMachineInterface;
3434
use Sylius\Bundle\ResourceBundle\Controller\ViewHandlerInterface;
3535
use Sylius\Bundle\ResourceBundle\Event\ResourceControllerEvent;
36-
use Sylius\Component\Resource\Exception\DeleteHandlingException;
3736
use Sylius\Resource\Doctrine\Persistence\RepositoryInterface;
37+
use Sylius\Resource\Exception\DeleteHandlingException;
3838
use Sylius\Resource\Factory\FactoryInterface;
3939
use Sylius\Resource\Metadata\MetadataInterface;
4040
use Sylius\Resource\Model\ResourceInterface;

src/Bundle/spec/Form/EventSubscriber/AddCodeFormSubscriberSpec.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
use PhpSpec\ObjectBehavior;
1717
use Prophecy\Argument;
18-
use Sylius\Component\Resource\Exception\UnexpectedTypeException;
18+
use Sylius\Resource\Exception\UnexpectedTypeException;
1919
use Sylius\Resource\Model\CodeAwareInterface;
2020
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
2121
use Symfony\Component\Form\Extension\Core\Type\FormType;

src/Component/legacy/spec/Exception/DeleteHandlingExceptionSpec.php

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -14,26 +14,12 @@
1414
namespace spec\Sylius\Component\Resource\Exception;
1515

1616
use PhpSpec\ObjectBehavior;
17+
use Sylius\Resource\Exception\DeleteHandlingException as NewDeleteHandlingException;
1718

1819
final class DeleteHandlingExceptionSpec extends ObjectBehavior
1920
{
20-
function it_extends_an_exception(): void
21+
function it_should_be_an_alias_of_delete_handling_exception(): void
2122
{
22-
$this->shouldHaveType(\Exception::class);
23-
}
24-
25-
function it_has_a_message(): void
26-
{
27-
$this->getMessage()->shouldReturn('Ups, something went wrong during deleting a resource, please try again.');
28-
}
29-
30-
function it_has_a_flash(): void
31-
{
32-
$this->getFlash()->shouldReturn('something_went_wrong_error');
33-
}
34-
35-
function it_has_an_api_response_code(): void
36-
{
37-
$this->getApiResponseCode()->shouldReturn(500);
23+
$this->shouldBeAnInstanceOf(NewDeleteHandlingException::class);
3824
}
3925
}

src/Component/legacy/spec/Exception/RaceConditionExceptionSpec.php

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -14,27 +14,12 @@
1414
namespace spec\Sylius\Component\Resource\Exception;
1515

1616
use PhpSpec\ObjectBehavior;
17-
use Sylius\Component\Resource\Exception\UpdateHandlingException;
17+
use Sylius\Resource\Exception\RaceConditionException as NewRaceConditionException;
1818

1919
final class RaceConditionExceptionSpec extends ObjectBehavior
2020
{
21-
function it_extends_an_update_handling_exception(): void
21+
function it_should_be_an_alias_of_race_condition_exception(): void
2222
{
23-
$this->shouldHaveType(UpdateHandlingException::class);
24-
}
25-
26-
function it_has_a_message(): void
27-
{
28-
$this->getMessage()->shouldReturn('Operated entity was previously modified.');
29-
}
30-
31-
function it_has_a_flash(): void
32-
{
33-
$this->getFlash()->shouldReturn('race_condition_error');
34-
}
35-
36-
function it_has_an_api_response_code(): void
37-
{
38-
$this->getApiResponseCode()->shouldReturn(409);
23+
$this->shouldBeAnInstanceOf(NewRaceConditionException::class);
3924
}
4025
}

src/Component/legacy/spec/Exception/UnexpectedTypeExceptionSpec.php

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
namespace spec\Sylius\Component\Resource\Exception;
1515

1616
use PhpSpec\ObjectBehavior;
17+
use Sylius\Resource\Exception\UnexpectedTypeException as NewUnexpectedTypeException;
1718

1819
final class UnexpectedTypeExceptionSpec extends ObjectBehavior
1920
{
@@ -22,13 +23,8 @@ function let(): void
2223
$this->beConstructedWith('stringValue', '\ExpectedType');
2324
}
2425

25-
function it_extends_invalid_argument_exception(): void
26+
function it_should_be_an_alias_of_unexpected_type_exception(): void
2627
{
27-
$this->shouldHaveType(\InvalidArgumentException::class);
28-
}
29-
30-
function it_has_a_message(): void
31-
{
32-
$this->getMessage()->shouldReturn('Expected argument of type "\ExpectedType", "string" given.');
28+
$this->shouldBeAnInstanceOf(NewUnexpectedTypeException::class);
3329
}
3430
}

src/Component/legacy/spec/Exception/UnsupportedMethodExceptionSpec.php

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
namespace spec\Sylius\Component\Resource\Exception;
1515

1616
use PhpSpec\ObjectBehavior;
17+
use Sylius\Resource\Exception\UnsupportedMethodException as NewUnsupportedMethodException;
1718

1819
final class UnsupportedMethodExceptionSpec extends ObjectBehavior
1920
{
@@ -22,13 +23,8 @@ function let(): void
2223
$this->beConstructedWith('methodName');
2324
}
2425

25-
function it_extends_exception(): void
26+
function it_should_be_an_alias_of_unsupported_method_exception(): void
2627
{
27-
$this->shouldHaveType(\Exception::class);
28-
}
29-
30-
function it_has_a_message(): void
31-
{
32-
$this->getMessage()->shouldReturn('The method "methodName" is not supported.');
28+
$this->shouldBeAnInstanceOf(NewUnsupportedMethodException::class);
3329
}
3430
}

0 commit comments

Comments
 (0)