1
0
mirror of synced 2025-02-09 00:39:25 +03:00

#1169 DDC-3343 - refactoring test to use pre-existing test models

This commit is contained in:
Marco Pivetta 2015-01-24 11:54:03 +01:00
parent 24ebfb69cb
commit 7292920b15
2 changed files with 76 additions and 0 deletions

View File

@ -0,0 +1,34 @@
<?php
namespace Doctrine\Tests\Models\Tweet;
/**
* @Entity
* @Table(name="tweet_tweet")
*/
class Tweet
{
const CLASSNAME = __CLASS__;
/**
* @Id
* @GeneratedValue
* @Column(type="integer")
*/
public $id;
/**
* @Column(type="string")
*/
public $content;
/**
* @ManyToOne(targetEntity="User", inversedBy="tweets")
*/
public $author;
public function setAuthor(User $user)
{
$this->author = $user;
}
}

View File

@ -0,0 +1,42 @@
<?php
namespace Doctrine\Tests\Models\Tweet;
use Doctrine\Common\Collections\ArrayCollection;
/**
* @Entity
* @Table(name="tweet_user")
*/
class User
{
const CLASSNAME = __CLASS__;
/**
* @Id
* @GeneratedValue
* @Column(type="integer")
*/
public $id;
/**
* @Column(type="string")
*/
public $name;
/**
* @OneToMany(targetEntity="Tweet", mappedBy="author", cascade={"persist"}, fetch="EXTRA_LAZY")
*/
public $tweets;
public function __construct()
{
$this->tweets = new ArrayCollection();
}
public function addTweet(Tweet $tweet)
{
$tweet->setAuthor($this);
$this->tweets->add($tweet);
}
}