1
0
mirror of synced 2025-03-04 20:03:21 +03:00

Adding tests for DDC-1925

This commit is contained in:
Marco Pivetta 2012-07-19 22:00:56 +02:00
parent 93cef61270
commit 81f97e92d3
3 changed files with 207 additions and 0 deletions

View File

@ -0,0 +1,97 @@
<?php
namespace Doctrine\Tests\Models\DDC1925;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Tests\Models\DDC1925\DDC1925User;
/**
* @Table
* @Entity
*/
class DDC1925Product
{
/**
* @var integer $id
*
* @Column(name="id", type="integer")
* @Id
* @GeneratedValue(strategy="AUTO")
*/
private $id;
/**
* @var string $title
*
* @Column(name="title", type="string", length=255)
*/
private $title;
/**
* @ManyToMany(targetEntity="Doctrine\Tests\Models\DDC1925\DDC1925User")
* @JoinTable(
* name="user_purchases",
* joinColumns={@JoinColumn(name="product_id", referencedColumnName="id")},
* inverseJoinColumns={@JoinColumn(name="user_id", referencedColumnName="id")}
* )
*/
private $buyers;
/**
* Default constructor
*/
public function __construct()
{
$this->buyers = new ArrayCollection();
}
/**
* @return integer
*/
public function getId()
{
return $this->id;
}
/**
* @param string $title
*/
public function setTitle($title)
{
$this->title = $title;
}
/**
* Get title
*
* @return string
*/
public function getTitle()
{
return $this->title;
}
/**
* @param string $buyers
*/
public function setBuyers($buyers)
{
$this->buyers = $buyers;
}
/**
* @return string
*/
public function getBuyers()
{
return $this->buyers;
}
/**
* @param DDC1925User $buyer
*/
public function addBuyer(DDC1925User $buyer)
{
$this->buyers[] = $buyer;
}
}

View File

@ -0,0 +1,56 @@
<?php
namespace Doctrine\Tests\Models\DDC1925;
/**
* @Table
* @Entity
*/
class DDC1925User
{
/**
* @var integer
*
* @Column(name="id", type="integer")
* @Id
* @GeneratedValue(strategy="AUTO")
*/
private $id;
/**
* @var string
*
* @Column(name="title", type="string", length=255)
*/
private $title;
/**
* Get id
*
* @return integer
*/
public function getId()
{
return $this->id;
}
/**
* Set title
*
* @param string $title
*/
public function setTitle($title)
{
$this->title = $title;
}
/**
* Get title
*
* @return string
*/
public function getTitle()
{
return $this->title;
}
}

View File

@ -0,0 +1,54 @@
<?php
namespace Doctrine\Tests\ORM\Functional\Ticket;
use Doctrine\Tests\Models\ECommerce\ECommerceShipping;
use Doctrine\Tests\Models\DDC1925\DDC1925User;
use Doctrine\Tests\Models\DDC1925\DDC1925Product;
require_once __DIR__ . '/../../../TestInit.php';
/**
* @group DDC-1925
*/
class DDC1925Test extends \Doctrine\Tests\OrmFunctionalTestCase
{
/**
* @var \Doctrine\Tests\Models\Quote\User
*/
private $email;
protected function setUp()
{
parent::setUp();
//try {
$this->_schemaTool->createSchema(array(
$this->_em->getClassMetadata('Doctrine\Tests\Models\DDC1925\DDC1925User'),
$this->_em->getClassMetadata('Doctrine\Tests\Models\DDC1925\DDC1925Product'),
));
//} catch(\Exception $e) {
//}
}
public function testIssue()
{
$user = new DDC1925User();
$user->setTitle("Test User");
$this->_em->persist($user);
$product = new DDC1925Product();
$product->setTitle("Test product");
$this->_em->persist($product);
$this->_em->flush();
$product->addBuyer($user);
$this->_em->getUnitOfWork()->computeChangeSets();
$this->_em->persist($product);
$this->_em->flush();
}
}