Skip to content

Commit

Permalink
phpcbf
Browse files Browse the repository at this point in the history
  • Loading branch information
Nicolas FRANÇOIS committed Jan 23, 2018
1 parent f96001d commit cdd3830
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
* @Entity()
* @Table(name="manytomanypersister_child")
*/
class ChildClass {
class ChildClass
{

/**
* @var integer
Expand Down Expand Up @@ -40,7 +41,8 @@ class ChildClass {
*/
public $parents;

public function __construct() {
public function __construct()
{
$this->parents = new ArrayCollection();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,19 @@

namespace Doctrine\Tests\Models\ManyToManyPersister;


/**
* Class OtherParentClass
* @package Doctrine\Tests\Models\ManyToManyPersister
* @Entity()
* @Table(name="manytomanypersister_other_parent")
*/
class OtherParentClass {
class OtherParentClass
{

/**
* @var integer
* @Id()
* @Column(name="id", type="integer")
*/
public $id;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

namespace Doctrine\Tests\Models\ManyToManyPersister;


use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping\Entity;
Expand All @@ -15,7 +14,8 @@
* @Entity()
* @Table(name="manytomanypersister_parent")
*/
class ParentClass {
class ParentClass
{

/**
* @var integer
Expand All @@ -30,7 +30,8 @@ class ParentClass {
*/
public $children;

public function __construct() {
public function __construct()
{
$this->children = new ArrayCollection();
}
}
}
29 changes: 15 additions & 14 deletions tests/Doctrine/Tests/ORM/Persisters/ManyToManyPersisterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,31 +14,34 @@
* Tests for {@see ManyToManyPersister}
* @covers Doctrine\ORM\Persisters\Collection\ManyToManyPersister
*/
class ManyToManyPersisterTest extends OrmTestCase {
class ManyToManyPersisterTest extends OrmTestCase
{

/** @var EntityManager */
private $em;

/** @var ManyToManyPersister */
private $persister;

protected function setUp() {
protected function setUp()
{
parent::setUp();
$this->em = $this->_getTestEntityManager();
$this->em = $this->_getTestEntityManager();
$this->persister = new ManyToManyPersister($this->em);
}

/**
* @group ManyToManyPersister
* @throws \Doctrine\ORM\ORMException
*/
public function testDeleteManyToManyCollection() {
$parent = new ParentClass();
$parent->id = 1;
$otherParent = new OtherParentClass();
$otherParent->id = 42;
$child = new ChildClass();
$child->id1 = 1;
public function testDeleteManyToManyCollection()
{
$parent = new ParentClass();
$parent->id = 1;
$otherParent = new OtherParentClass();
$otherParent->id = 42;
$child = new ChildClass();
$child->id1 = 1;
$child->otherParent = $otherParent;
$parent->children->add($child);
$this->em->persist($parent);
Expand All @@ -51,12 +54,10 @@ public function testDeleteManyToManyCollection() {
/** @var ConnectionMock $conn */
$conn = $this->em->getConnection();

$updates = $conn->getExecuteUpdates();
$updates = $conn->getExecuteUpdates();
$lastUpdate = array_pop($updates);

$this->assertEquals('DELETE FROM parent_child WHERE child_id1 = ? AND child_id2 = ?', $lastUpdate['query']);
$this->assertEquals([1,42], $lastUpdate['params']);

}

}
}

0 comments on commit cdd3830

Please sign in to comment.