1
0
mirror of synced 2024-12-05 03:06:05 +03:00

Add DefaultQuoteStrategyTest::testGetJoinTableName() test

This commit is contained in:
molchanoviv 2015-02-26 17:11:42 +03:00 committed by Marco Pivetta
parent f244db80fb
commit ab740abe96
2 changed files with 106 additions and 0 deletions

View File

@ -0,0 +1,79 @@
<?php
namespace Doctrine\Tests\Models\NonPublicSchemaJoins;
/**
* Doctrine\Tests\Models\NonPublicSchemaJoins\User
*
* @Entity
* @Table(name="readers.user")
*/
class User
{
/**
* @Column(type="integer")
* @Id
*/
private $id;
/**
* @ManyToMany(targetEntity="Doctrine\Tests\Models\NonPublicSchemaJoins\User", inversedBy="authors")
* @JoinTable(name="author_reader", schema="readers",
* joinColumns={@JoinColumn(name="author_id", referencedColumnName="id")},
* inverseJoinColumns={@JoinColumn(name="reader_id", referencedColumnName="id")}
* )
*
* @var User[]
*/
private $readers;
/**
* @ManyToMany(targetEntity="Doctrine\Tests\Models\NonPublicSchemaJoins\User", mappedBy="readers")
*
* @var User[]
*/
private $authors;
public function setId($id)
{
$this->id = $id;
}
/**
* @return User[]
*/
public function getReaders()
{
return $this->readers;
}
/**
* @param User[] $readers
* @return User
*/
public function setReaders($readers)
{
$this->readers = $readers;
return $this;
}
/**
* @return User[]
*/
public function getAuthors()
{
return $this->authors;
}
/**
* @param User[] $authors
* @return User
*/
public function setAuthors($authors)
{
$this->authors = $authors;
return $this;
}
}

View File

@ -0,0 +1,27 @@
<?php
namespace Doctrine\Tests\ORM\Mapping;
use Doctrine\ORM\Mapping\DefaultQuoteStrategy;
use Doctrine\Tests\OrmTestCase;
/**
* Doctrine\Tests\ORM\Mapping\DefaultQuoteStrategyTest
*
* @author Ivan Molchanov <ivan.molchanov@opensoftdev.ru>
*/
class DefaultQuoteStrategyTest extends OrmTestCase
{
const TEST_ENTITY = 'Doctrine\Tests\Models\NonPublicSchemaJoins\User';
public function testGetJoinTableName()
{
$em = $this->_getTestEntityManager();
$metadata = $em->getClassMetadata(self::TEST_ENTITY);
$platform = $em->getConnection()->getDatabasePlatform();
$strategy = new DefaultQuoteStrategy();
$tableName = $strategy->getJoinTableName($metadata->associationMappings['readers'], $metadata, $platform);
$this->assertEquals($tableName, 'readers.author_reader');
}
}