mirror of
https://github.com/Sylius/Sylius.git
synced 2026-07-14 17:10:53 +00:00
[Product] Remove softdeletable form ProductVariant
This commit is contained in:
parent
fe757e8650
commit
3b35136919
7 changed files with 40 additions and 42 deletions
34
app/migrations/Version20160229145014.php
Normal file
34
app/migrations/Version20160229145014.php
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
<?php
|
||||
|
||||
namespace Sylius\Migrations;
|
||||
|
||||
use Doctrine\DBAL\Migrations\AbstractMigration;
|
||||
use Doctrine\DBAL\Schema\Schema;
|
||||
|
||||
/**
|
||||
* Auto-generated Migration: Please modify to your needs!
|
||||
*/
|
||||
class Version20160229145014 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_variant DROP deleted_at');
|
||||
}
|
||||
|
||||
/**
|
||||
* @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_variant ADD deleted_at DATETIME DEFAULT NULL');
|
||||
}
|
||||
}
|
||||
|
|
@ -32,9 +32,6 @@
|
|||
<field name="updatedAt" column="updated_at" type="datetime" nullable="true">
|
||||
<gedmo:timestampable on="update"/>
|
||||
</field>
|
||||
<field name="deletedAt" column="deleted_at" type="datetime" nullable="true" />
|
||||
|
||||
<gedmo:soft-deleteable field-name="deletedAt" />
|
||||
</mapped-superclass>
|
||||
|
||||
</doctrine-mapping>
|
||||
|
|
|
|||
|
|
@ -354,7 +354,7 @@ class Product implements ProductInterface
|
|||
public function getVariants()
|
||||
{
|
||||
return $this->variants->filter(function (BaseVariantInterface $variant) {
|
||||
return !$variant->isDeleted() && !$variant->isMaster();
|
||||
return !$variant->isMaster();
|
||||
});
|
||||
}
|
||||
|
||||
|
|
@ -364,7 +364,7 @@ class Product implements ProductInterface
|
|||
public function getAvailableVariants()
|
||||
{
|
||||
return $this->variants->filter(function (BaseVariantInterface $variant) {
|
||||
return !$variant->isDeleted() && !$variant->isMaster() && $variant->isAvailable();
|
||||
return $variant->isMaster() && $variant->isAvailable();
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -176,10 +176,9 @@ class ProductSpec extends ObjectBehavior
|
|||
function it_should_not_add_master_variant_twice_to_collection(VariantInterface $variant)
|
||||
{
|
||||
$variant->isMaster()->willReturn(true);
|
||||
$variant->isDeleted()->willReturn(false);
|
||||
|
||||
$variant->setProduct($this)->shouldBeCalled();
|
||||
$variant->setMaster(true)->shouldBeCalled();
|
||||
$variant->setProduct($this)->shouldBeCalledTimes(1);
|
||||
$variant->setMaster(true)->shouldBeCalledTimes(2);
|
||||
|
||||
$this->setMasterVariant($variant);
|
||||
$this->setMasterVariant($variant);
|
||||
|
|
@ -195,7 +194,6 @@ class ProductSpec extends ObjectBehavior
|
|||
function its_hasVariants_should_return_true_only_if_any_variants_defined(VariantInterface $variant)
|
||||
{
|
||||
$variant->isMaster()->willReturn(false);
|
||||
$variant->isDeleted()->willReturn(false);
|
||||
|
||||
$variant->setProduct($this)->shouldBeCalled();
|
||||
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ use Sylius\Component\Resource\Model\TimestampableTrait;
|
|||
*/
|
||||
class Variant implements VariantInterface
|
||||
{
|
||||
use SoftDeletableTrait, TimestampableTrait;
|
||||
use TimestampableTrait;
|
||||
|
||||
/**
|
||||
* @var mixed
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ use Sylius\Component\Resource\Model\TimestampableInterface;
|
|||
/**
|
||||
* @author Paweł Jędrzejewski <pawel@sylius.org>
|
||||
*/
|
||||
interface VariantInterface extends SoftDeletableInterface, TimestampableInterface, ResourceInterface
|
||||
interface VariantInterface extends TimestampableInterface, ResourceInterface
|
||||
{
|
||||
/**
|
||||
* Checks whether variant is master.
|
||||
|
|
|
|||
|
|
@ -137,35 +137,4 @@ class VariantSpec extends ObjectBehavior
|
|||
{
|
||||
$this->getUpdatedAt()->shouldReturn(null);
|
||||
}
|
||||
|
||||
function it_should_not_have_deletion_date_by_default()
|
||||
{
|
||||
$this->getDeletedAt()->shouldReturn(null);
|
||||
}
|
||||
|
||||
function its_deletion_date_should_be_mutable()
|
||||
{
|
||||
$deletedAt = new \DateTime('now');
|
||||
|
||||
$this->setDeletedAt($deletedAt);
|
||||
$this->getDeletedAt()->shouldReturn($deletedAt);
|
||||
}
|
||||
|
||||
function it_is_deleted_only_if_deletion_date_is_in_past()
|
||||
{
|
||||
$deletedAt = new \DateTime('yesterday');
|
||||
|
||||
$this->setDeletedAt($deletedAt);
|
||||
$this->shouldBeDeleted();
|
||||
|
||||
$deletedAt = new \DateTime('tomorrow');
|
||||
|
||||
$this->setDeletedAt($deletedAt);
|
||||
$this->shouldNotBeDeleted();
|
||||
}
|
||||
|
||||
function it_should_not_be_deleted_by_default()
|
||||
{
|
||||
$this->shouldNotBeDeleted();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue