mirror of
https://github.com/Sylius/Sylius.git
synced 2026-07-14 09:02:12 +00:00
Merge pull request #7490 from krisElphenor/master
createReviewerMapping: impossible override due to wrong array key
This commit is contained in:
commit
986d51793b
6 changed files with 59 additions and 25 deletions
38
app/migrations/Version20170214095710.php
Normal file
38
app/migrations/Version20170214095710.php
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
<?php
|
||||
|
||||
namespace Sylius\Migrations;
|
||||
|
||||
use Doctrine\DBAL\Migrations\AbstractMigration;
|
||||
use Doctrine\DBAL\Schema\Schema;
|
||||
|
||||
/**
|
||||
* Auto-generated Migration: Please modify to your needs!
|
||||
*/
|
||||
class Version20170214095710 extends AbstractMigration
|
||||
{
|
||||
/**
|
||||
* @param Schema $schema
|
||||
*/
|
||||
public function up(Schema $schema)
|
||||
{
|
||||
// this up() migration is auto-generated, please modify it to your needs
|
||||
$this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'mysql', 'Migration can only be executed safely on \'mysql\'.');
|
||||
|
||||
$this->addSql('ALTER TABLE sylius_product_review DROP FOREIGN KEY FK_C7056A99F675F31B');
|
||||
$this->addSql('ALTER TABLE sylius_product_review CHANGE author_id author_id INT NOT NULL');
|
||||
$this->addSql('ALTER TABLE sylius_product_review ADD CONSTRAINT FK_C7056A99F675F31B FOREIGN KEY (author_id) REFERENCES sylius_customer (id) ON DELETE CASCADE');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Schema $schema
|
||||
*/
|
||||
public function down(Schema $schema)
|
||||
{
|
||||
// this down() migration is auto-generated, please modify it to your needs
|
||||
$this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'mysql', 'Migration can only be executed safely on \'mysql\'.');
|
||||
|
||||
$this->addSql('ALTER TABLE sylius_product_review DROP FOREIGN KEY FK_C7056A99F675F31B');
|
||||
$this->addSql('ALTER TABLE sylius_product_review CHANGE author_id author_id INT DEFAULT NULL');
|
||||
$this->addSql('ALTER TABLE sylius_product_review ADD CONSTRAINT FK_C7056A99F675F31B FOREIGN KEY (author_id) REFERENCES sylius_customer (id)');
|
||||
}
|
||||
}
|
||||
|
|
@ -8,7 +8,7 @@ Feature: Deleting a product
|
|||
Given the store operates on a single channel in "United States"
|
||||
And the store has a product "Toyota GT86 model"
|
||||
And this product has "1:43" variant priced at "$15.00"
|
||||
And this product has one review
|
||||
And this product has one review from customer "john@doe.com"
|
||||
And I am logged in as an administrator
|
||||
|
||||
@ui
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ Feature: Deleting a product with its reviews
|
|||
|
||||
Background:
|
||||
Given the store has a product "Toyota GT86 model"
|
||||
And this product has one review
|
||||
And this product has one review from customer "john@doe.com"
|
||||
And I am logged in as an administrator
|
||||
|
||||
@domain @ui
|
||||
|
|
|
|||
|
|
@ -65,11 +65,11 @@ final class ProductReviewContext implements Context
|
|||
}
|
||||
|
||||
/**
|
||||
* @Given /^(this product) has one review$/
|
||||
* @Given /^(this product) has one review from (customer "[^"]+")$/
|
||||
*/
|
||||
public function productHasAReview(ProductInterface $product)
|
||||
public function productHasAReview(ProductInterface $product, CustomerInterface $customer)
|
||||
{
|
||||
$review = $this->createProductReview($product, 'Title', 5, 'Comment');
|
||||
$review = $this->createProductReview($product, 'Title', 5, 'Comment', $customer);
|
||||
|
||||
$this->productReviewRepository->add($review);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -84,14 +84,12 @@ final class LoadMetadataSubscriber implements EventSubscriber
|
|||
'fieldName' => 'reviewSubject',
|
||||
'targetEntity' => $reviewableEntity,
|
||||
'inversedBy' => 'reviews',
|
||||
'joinColumns' => [
|
||||
[
|
||||
'name' => $subject.'_id',
|
||||
'referencedColumnName' => $reviewableEntityMetadata->fieldMappings['id']['columnName'],
|
||||
'nullable' => false,
|
||||
'onDelete' => 'CASCADE',
|
||||
],
|
||||
],
|
||||
'joinColumns' => [[
|
||||
'name' => $subject.'_id',
|
||||
'referencedColumnName' => $reviewableEntityMetadata->fieldMappings['id']['columnName'],
|
||||
'nullable' => false,
|
||||
'onDelete' => 'CASCADE',
|
||||
]],
|
||||
];
|
||||
}
|
||||
|
||||
|
|
@ -106,12 +104,12 @@ final class LoadMetadataSubscriber implements EventSubscriber
|
|||
return [
|
||||
'fieldName' => 'author',
|
||||
'targetEntity' => $reviewerEntity,
|
||||
'joinColumn' => [
|
||||
'joinColumns' => [[
|
||||
'name' => 'author_id',
|
||||
'referencedColumnName' => $reviewerEntityMetadata->fieldMappings['id']['columnName'],
|
||||
'nullable' => false,
|
||||
'onDelete' => 'CASCADE',
|
||||
],
|
||||
]],
|
||||
'cascade' => ['persist'],
|
||||
];
|
||||
}
|
||||
|
|
|
|||
|
|
@ -80,25 +80,23 @@ final class LoadMetadataSubscriberSpec extends ObjectBehavior
|
|||
'fieldName' => 'reviewSubject',
|
||||
'targetEntity' => 'AcmeBundle\Entity\ReviewableModel',
|
||||
'inversedBy' => 'reviews',
|
||||
'joinColumns' => [
|
||||
[
|
||||
'name' => 'reviewable_id',
|
||||
'referencedColumnName' => 'id',
|
||||
'nullable' => false,
|
||||
'onDelete' => 'CASCADE',
|
||||
],
|
||||
],
|
||||
'joinColumns' => [[
|
||||
'name' => 'reviewable_id',
|
||||
'referencedColumnName' => 'id',
|
||||
'nullable' => false,
|
||||
'onDelete' => 'CASCADE',
|
||||
]],
|
||||
])->shouldBeCalled();
|
||||
|
||||
$metadata->mapManyToOne([
|
||||
'fieldName' => 'author',
|
||||
'targetEntity' => 'AcmeBundle\Entity\ReviewerModel',
|
||||
'joinColumn' => [
|
||||
'joinColumns' => [[
|
||||
'name' => 'author_id',
|
||||
'referencedColumnName' => 'id',
|
||||
'nullable' => false,
|
||||
'onDelete' => 'CASCADE',
|
||||
],
|
||||
]],
|
||||
'cascade' => ['persist'],
|
||||
])->shouldBeCalled();
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue