Skip to content

Commit

Permalink
[sonata-project#318] Add conflict with "doctrine/dbal:2.7.0"
Browse files Browse the repository at this point in the history
  • Loading branch information
phansys committed Apr 8, 2018
1 parent 44c94e9 commit 6df9538
Show file tree
Hide file tree
Showing 3 changed files with 72 additions and 5 deletions.
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
"fabpot/php-cs-fixer": "^1.11"
},
"conflict": {
"doctrine/dbal": "2.7.0",
"gedmo/doctrine-extensions": "<2.3.1",
"symfony/framework-bundle": "<2.7",
"doctrine/doctrine-bundle": "<1.4"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<?php

namespace SimpleThings\EntityAudit\Tests\Fixtures\Issue;

use Doctrine\ORM\Mapping as ORM;

/**
* @ORM\Entity
*/
class Issue318User
{
/** @ORM\Id @ORM\Column(type="integer") @ORM\GeneratedValue(strategy="AUTO") */
private $id;

/**
* @var string
* @ORM\Column(type="string", nullable=false, length=255)
*/
protected $alias;

public function getId()
{
return $this->id;
}

/**
* @return string
*/
public function getAlias()
{
return $this->alias;
}

/**
* @param string $alias
* @return self
*/
public function setAlias($alias)
{
$this->alias = $alias;
return $this;
}
}
33 changes: 28 additions & 5 deletions tests/SimpleThings/Tests/EntityAudit/IssueTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
use SimpleThings\EntityAudit\Tests\Fixtures\Issue\Issue196Entity;
use SimpleThings\EntityAudit\Tests\Fixtures\Issue\Issue31Reve;
use SimpleThings\EntityAudit\Tests\Fixtures\Issue\Issue31User;
use SimpleThings\EntityAudit\Tests\Fixtures\Issue\Issue318User;
use SimpleThings\EntityAudit\Tests\Fixtures\Issue\Issue87Organization;
use SimpleThings\EntityAudit\Tests\Fixtures\Issue\Issue87Project;
use SimpleThings\EntityAudit\Tests\Fixtures\Issue\Issue87ProjectComment;
Expand Down Expand Up @@ -68,6 +69,7 @@ class IssueTest extends BaseTest
'SimpleThings\EntityAudit\Tests\Fixtures\Issue\Issue198Car',
'SimpleThings\EntityAudit\Tests\Fixtures\Issue\Issue198Owner',
'SimpleThings\EntityAudit\Tests\Fixtures\Issue\Issue196Entity',
'SimpleThings\EntityAudit\Tests\Fixtures\Issue\Issue318User',
'SimpleThings\EntityAudit\Tests\Fixtures\Issue\ConvertToPHPEntity',
);

Expand All @@ -92,6 +94,7 @@ class IssueTest extends BaseTest
'SimpleThings\EntityAudit\Tests\Fixtures\Issue\Issue196Entity',
'SimpleThings\EntityAudit\Tests\Fixtures\Issue\Issue198Car',
'SimpleThings\EntityAudit\Tests\Fixtures\Issue\Issue198Owner',
'SimpleThings\EntityAudit\Tests\Fixtures\Issue\Issue318User',
'SimpleThings\EntityAudit\Tests\Fixtures\Issue\ConvertToPHPEntity',
);

Expand Down Expand Up @@ -277,27 +280,27 @@ public function testIssue196()
'Current revision of audited entity is not equivalent to persisted entity:'
);
}

public function testIssue198()
{
$owner = new Issue198Owner();
$car = new Issue198Car();

$this->em->persist($owner);
$this->em->persist($car);
$this->em->flush();

$owner->addCar($car);

$this->em->persist($owner);
$this->em->persist($car);
$this->em->flush();

$auditReader = $this->auditManager->createAuditReader($this->em);

$car1 = $auditReader->find(get_class($car), $car->getId(), 1);
$this->assertNull($car1->getOwner());

$car2 = $auditReader->find(get_class($car), $car->getId(), 2);
$this->assertEquals($car2->getOwner()->getId(), $owner->getId());
}
Expand All @@ -322,4 +325,24 @@ public function testConvertToPHP()
'Current revision of audited entity is not equivalent to persisted entity:'
);
}

public function testIssue318()
{
$user = new Issue318User();
$user->setAlias('alias');
$this->em->persist($user);
$this->em->flush();
$userMetadata = $this->em->getClassMetadata(get_class($user));
$classes = [$userMetadata];
$schema = $this->getSchemaTool()->getSchemaFromMetadata($classes);
$schemaName = $schema->getName();
$config = $this->getAuditManager()->getConfiguration();
$entityTableUser = $schema->getTable(sprintf('%s.issue318user', $schemaName));
$revisionsTableUser = $schema->getTable(sprintf('%s.%sissue318user%s', $schemaName, $config->getTablePrefix(), $config->getTableSuffix()));
$userNotNullColumnName = 'alias';
$userIdColumnName = 'id';

$this->assertFalse($revisionsTableUser->getColumn($userNotNullColumnName)->getNotnull());
$this->assertFalse($revisionsTableUser->getColumn($userIdColumnName)->getAutoincrement());
}
}

0 comments on commit 6df9538

Please sign in to comment.