-
-
Notifications
You must be signed in to change notification settings - Fork 130
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Change owning side of relationship, add test.
- Loading branch information
1 parent
3d0a9e5
commit e3ec9aa
Showing
7 changed files
with
133 additions
and
26 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Application\Migrations; | ||
|
||
use Doctrine\DBAL\Schema\Schema; | ||
use Doctrine\Migrations\AbstractMigration; | ||
|
||
/** | ||
* Auto-generated Migration: Please modify to your needs! | ||
*/ | ||
final class Version20250206150857 extends AbstractMigration | ||
{ | ||
public function getDescription(): string | ||
{ | ||
return ''; | ||
} | ||
|
||
public function up(Schema $schema): void | ||
{ | ||
// TODO Move sylius_order_loopeat_credentials.order_id to sylius_order.loopeat_credentials_id | ||
|
||
$this->addSql('ALTER TABLE sylius_order ADD loopeat_credentials_id INT DEFAULT NULL'); | ||
$this->addSql('ALTER TABLE sylius_order ADD CONSTRAINT FK_6196A1F9BD145500 FOREIGN KEY (loopeat_credentials_id) REFERENCES sylius_order_loopeat_credentials (id) NOT DEFERRABLE INITIALLY IMMEDIATE'); | ||
$this->addSql('CREATE UNIQUE INDEX UNIQ_6196A1F9BD145500 ON sylius_order (loopeat_credentials_id)'); | ||
$this->addSql('ALTER TABLE sylius_order_loopeat_credentials DROP CONSTRAINT fk_dec04c298d9f6d38'); | ||
$this->addSql('DROP INDEX uniq_dec04c298d9f6d38'); | ||
$this->addSql('ALTER TABLE sylius_order_loopeat_credentials DROP order_id'); | ||
} | ||
|
||
public function down(Schema $schema): void | ||
{ | ||
// TODO Move sylius_order.loopeat_credentials_id to sylius_order_loopeat_credentials.order_id | ||
|
||
$this->addSql('ALTER TABLE sylius_order_loopeat_credentials ADD order_id INT DEFAULT NULL'); | ||
$this->addSql('ALTER TABLE sylius_order_loopeat_credentials ADD CONSTRAINT fk_dec04c298d9f6d38 FOREIGN KEY (order_id) REFERENCES sylius_order (id) NOT DEFERRABLE INITIALLY IMMEDIATE'); | ||
$this->addSql('CREATE UNIQUE INDEX uniq_dec04c298d9f6d38 ON sylius_order_loopeat_credentials (order_id)'); | ||
$this->addSql('ALTER TABLE sylius_order DROP CONSTRAINT FK_6196A1F9BD145500'); | ||
$this->addSql('DROP INDEX UNIQ_6196A1F9BD145500'); | ||
$this->addSql('ALTER TABLE sylius_order DROP loopeat_credentials_id'); | ||
} | ||
} |
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 |
---|---|---|
|
@@ -2362,3 +2362,68 @@ Feature: Carts | |
"redirectUrl":"@string@||@null@" | ||
} | ||
""" | ||
|
||
@debug | ||
Scenario: Assign cart to guest customer moves Loopeat credentials | ||
Given the fixtures files are loaded: | ||
| sylius_channels.yml | | ||
| payment_methods.yml | | ||
| products.yml | | ||
| restaurants.yml | | ||
And the setting "guest_checkout_enabled" has value "1" | ||
And the restaurant with id "1" has products: | ||
| code | | ||
| PIZZA | | ||
| HAMBURGER | | ||
When I add "Content-Type" header equal to "application/ld+json" | ||
And I add "Accept" header equal to "application/ld+json" | ||
And I send a "POST" request to "/api/carts/session" with body: | ||
""" | ||
{ | ||
"restaurant": "/api/restaurants/1" | ||
} | ||
""" | ||
Then print last response | ||
Then the response status code should be 200 | ||
And the response should be in JSON | ||
And the JSON should match: | ||
""" | ||
{ | ||
"token":@string@, | ||
"cart":{ | ||
"@context":"/api/contexts/Order", | ||
"@id":"/api/orders/1", | ||
"@type":"http://schema.org/Order", | ||
"customer":null, | ||
"restaurant":"/api/restaurants/1", | ||
"@*@":"@*@" | ||
} | ||
} | ||
""" | ||
Given the order with id "1" has Loopeat credentials | ||
Given the client is authenticated with last response token | ||
When I add "Content-Type" header equal to "application/ld+json" | ||
And I add "Accept" header equal to "application/ld+json" | ||
And I send an authenticated "PUT" request to "/api/orders/1/assign" with body: | ||
""" | ||
{ | ||
"guest": true, | ||
"email": "[email protected]", | ||
"telephone": "+33193166989" | ||
} | ||
""" | ||
Then print last response | ||
Then the response status code should be 200 | ||
And the response should be in JSON | ||
And the JSON should match: | ||
""" | ||
{ | ||
"@context":"/api/contexts/Order", | ||
"@id":"/api/orders/1", | ||
"@type":"http://schema.org/Order", | ||
"customer":"/api/customers/1", | ||
"restaurant":"/api/restaurants/1", | ||
"@*@":"@*@" | ||
} | ||
""" | ||
And the customer with id "1" should have Loopeat credentials |
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