Add DefaultQuoteStrategyTest::testGetJoinTableName() test
This commit is contained in:
parent
f244db80fb
commit
ab740abe96
2 changed files with 106 additions and 0 deletions
tests/Doctrine/Tests
79
tests/Doctrine/Tests/Models/NonPublicSchemaJoins/User.php
Normal file
79
tests/Doctrine/Tests/Models/NonPublicSchemaJoins/User.php
Normal 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;
|
||||||
|
}
|
||||||
|
}
|
|
@ -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');
|
||||||
|
}
|
||||||
|
}
|
Loading…
Add table
Reference in a new issue