-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Opsrc-355/Add ability to add agreements to each form in Sylius (#10)
* Agreement extended body can be null * Fix GH actions * Fix GH actions * Add parent autocomplete function * Fix * Namespace fix * Add OS header * Agreement services cleaning * Add agreement adding/editing template * Add sylius 1.11 support * GHA fix * Fix 404 error after not accepting the required agreement * Add AutocompleteChoiceType test * Add Form/Type/Admin phpunit tests * Add Form/Type/Shop phpunit tests * Add agreement subscriber phpunit test * Function name fix & typo fix & change coding standard * Bug fix * Phpstan fix * Add behat tests for user registration with required agreement * Fix composer dependencies * Move translation to the proper place * Change composer plugin name * Fix translation path * Readme update * Fix infinity page reloading when set parent same as agreement (validator) * Fix phpstan * ecs fix * Fixed typo and changed snake case function names * Change behat declarations from yml files to xml * behat fix * Fix behat * Add compilerpass configuration to extend forms automatically * Resolvers repairing to allow extending other forms * Create custom event to allow extending other forms * Class, services and forms cleaning to allow extending other forms * Fix phpstan, ecs and phpunit tests * Code extraction to subscribers and handler * Add OS headers/fix ecs * Add PHPSpec * Add trait to order entity * Add event subscriber spec tests * Add handler spec tests * Fix typo * Fix typo * Add resolvers phpspec tests * Fix resolvers * Add resolver spec test * Resolvers cleaning * Remove phpunit * Remove phpunit * Fix PHPStan * Change rand to type name * Remove CompositeAgreementResolver * Remove CompositeAgreementResolverSpec * Use constraints instead of strings * Move getter train into custom event instead of subscriber * Use entity instead of mapped-superclass * Fix spec tests after custom event changes * Changed CompositeAgreementApprovalResolver to AgreementHistoryChecker * Remove unneccesary dependencies * ECS autofix * Add checker spec missing scenario * Move setAgreementHistoryProperties function to new class and spec it * Move determineState function to new class and spec it * Remove instanceof check (history resolver now can only return history object) * Change else to check that agreement history is null * Move functions to new classes and repair spec tests * Change return type * Remove unnecessary instanceof * ecs fix * Readme update * Throw exception when agreements array is empty * Add missing spec tests scenarios * Fix typo * Change array checking function from empty() to count()
- Loading branch information
1 parent
ab6e12b
commit 0398688
Showing
67 changed files
with
1,351 additions
and
2,256 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
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,4 @@ | ||
suites: | ||
main: | ||
namespace: BitBag\SyliusAgreementPlugin | ||
psr4_prefix: BitBag\SyliusAgreementPlugin |
This file was deleted.
Oops, something went wrong.
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,56 @@ | ||
<?php | ||
|
||
/* | ||
* This file was created by developers working at BitBag | ||
* Do you need more information about us and what we do? Visit our https://bitbag.io website! | ||
* We are hiring developers from all over the world. Join us and start your new, exciting adventure and become part of us: https://bitbag.io/career | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace spec\BitBag\SyliusAgreementPlugin\Checker; | ||
|
||
use BitBag\SyliusAgreementPlugin\Checker\AgreementHistoryChecker; | ||
use BitBag\SyliusAgreementPlugin\Entity\Agreement\AgreementHistoryInterface; | ||
use BitBag\SyliusAgreementPlugin\Entity\Agreement\AgreementInterface; | ||
use BitBag\SyliusAgreementPlugin\Resolver\AgreementHistoryResolverInterface; | ||
use PhpSpec\ObjectBehavior; | ||
|
||
final class AgreementHistoryCheckerSpec extends ObjectBehavior | ||
{ | ||
function let( | ||
AgreementHistoryResolverInterface $agreementHistoryResolver | ||
): void { | ||
$this->beConstructedWith( | ||
$agreementHistoryResolver | ||
); | ||
} | ||
|
||
function it_is_initializable(): void | ||
{ | ||
$this->shouldHaveType(AgreementHistoryChecker::class); | ||
} | ||
|
||
function it_resolves_agreement_correctly( | ||
AgreementInterface $agreement, | ||
AgreementHistoryInterface $agreementHistory, | ||
AgreementHistoryResolverInterface $agreementHistoryResolver | ||
): void { | ||
$agreementHistoryResolver->resolveHistory($agreement)->willReturn($agreementHistory); | ||
$agreementHistory->getState()->willReturn('accepted'); | ||
|
||
$this->isAgreementAccepted($agreement)->shouldReturn(true); | ||
} | ||
|
||
function it_not_resolves_agreement_when_state_is_other( | ||
AgreementInterface $agreement, | ||
AgreementHistoryInterface $agreementHistory, | ||
AgreementHistoryResolverInterface $agreementHistoryResolver | ||
): void { | ||
$agreementHistoryResolver->resolveHistory($agreement)->willReturn($agreementHistory); | ||
$agreementHistory->getState()->willReturn('rejected'); | ||
|
||
$this->isAgreementAccepted($agreement)->shouldReturn(false); | ||
} | ||
|
||
} |
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,79 @@ | ||
<?php | ||
|
||
/* | ||
* This file was created by developers working at BitBag | ||
* Do you need more information about us and what we do? Visit our https://bitbag.io website! | ||
* We are hiring developers from all over the world. Join us and start your new, exciting adventure and become part of us: https://bitbag.io/career | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace spec\BitBag\SyliusAgreementPlugin\DataModifier; | ||
|
||
use BitBag\SyliusAgreementPlugin\DataModifier\AgreementHistoryModifier; | ||
use BitBag\SyliusAgreementPlugin\Entity\Agreement\AgreementHistoryInterface; | ||
use BitBag\SyliusAgreementPlugin\Entity\Agreement\AgreementInterface; | ||
use BitBag\SyliusAgreementPlugin\Resolver\AgreementHistoryResolverInterface; | ||
use PhpSpec\ObjectBehavior; | ||
use Sylius\Component\Core\Model\OrderInterface; | ||
use Sylius\Component\Core\Model\ShopUserInterface; | ||
|
||
final class AgreementHistoryModifierSpec extends ObjectBehavior | ||
{ | ||
function let( | ||
AgreementHistoryResolverInterface $agreementHistoryResolver | ||
): void { | ||
$this->beConstructedWith( | ||
$agreementHistoryResolver | ||
); | ||
} | ||
|
||
function it_is_initializable(): void | ||
{ | ||
$this->shouldHaveType(AgreementHistoryModifier::class); | ||
} | ||
|
||
function it_returns_agreement_history_from_repository( | ||
OrderInterface $order, | ||
ShopUserInterface $shopUser, | ||
AgreementInterface $agreement, | ||
AgreementHistoryResolverInterface $agreementHistoryResolver, | ||
AgreementHistoryInterface $agreementHistory | ||
): void { | ||
$agreementHistoryResolver->resolveHistory($agreement)->willReturn($agreementHistory); | ||
$agreementHistory->getId()->willReturn('1'); | ||
|
||
$agreementHistory->setContext('registration_form')->shouldNotBeCalled(); | ||
|
||
$this->setAgreementHistoryProperties( | ||
'registration_form', | ||
$order, | ||
$shopUser, | ||
$agreement | ||
)->shouldReturn($agreementHistory); | ||
} | ||
|
||
function it_sets_data_when_history_id_is_null( | ||
OrderInterface $order, | ||
ShopUserInterface $shopUser, | ||
AgreementInterface $agreement, | ||
AgreementHistoryResolverInterface $agreementHistoryResolver, | ||
AgreementHistoryInterface $agreementHistory | ||
): void { | ||
$agreementHistoryResolver->resolveHistory($agreement)->willReturn($agreementHistory); | ||
$agreementHistory->getId()->willReturn(null); | ||
|
||
$agreementHistory->setContext('registration_form')->shouldBeCalled(); | ||
$agreementHistory->setShopUser($shopUser)->shouldBeCalled(); | ||
$agreementHistory->setOrder($order)->shouldBeCalled(); | ||
$agreementHistory->setAgreement($agreement)->shouldBeCalled(); | ||
|
||
$this->setAgreementHistoryProperties( | ||
'registration_form', | ||
$order, | ||
$shopUser, | ||
$agreement | ||
)->shouldReturn($agreementHistory); | ||
} | ||
|
||
} |
Oops, something went wrong.