DDC-1384 - Fix all tests on Oracle
This commit is contained in:
parent
50e028212d
commit
30731e0727
@ -67,7 +67,9 @@ class SchemaTool
|
||||
/**
|
||||
* Creates the database schema for the given array of ClassMetadata instances.
|
||||
*
|
||||
* @throws ToolsException
|
||||
* @param array $classes
|
||||
* @return void
|
||||
*/
|
||||
public function createSchema(array $classes)
|
||||
{
|
||||
@ -75,7 +77,11 @@ class SchemaTool
|
||||
$conn = $this->_em->getConnection();
|
||||
|
||||
foreach ($createSchemaSql as $sql) {
|
||||
try {
|
||||
$conn->executeQuery($sql);
|
||||
} catch(\Exception $e) {
|
||||
throw ToolsException::schemaToolFailure($sql, $e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,11 +1,38 @@
|
||||
<?php
|
||||
/*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* This software consists of voluntary contributions made by many individuals
|
||||
* and is licensed under the LGPL. For more information, see
|
||||
* <http://www.doctrine-project.org>.
|
||||
*/
|
||||
|
||||
namespace Doctrine\ORM\Tools;
|
||||
|
||||
use Doctrine\ORM\ORMException;
|
||||
|
||||
/**
|
||||
* Tools related Exceptions
|
||||
*
|
||||
* @author Benjamin Eberlei <kontakt@beberlei.de>
|
||||
*/
|
||||
class ToolsException extends ORMException
|
||||
{
|
||||
public static function schemaToolFailure($sql, \Exception $e)
|
||||
{
|
||||
return new self("Schema-Tool failed with Error '" . $e->getMessage() . "' while executing DDL: " . $sql, "0", $e);
|
||||
}
|
||||
|
||||
public static function couldNotMapDoctrine1Type($type)
|
||||
{
|
||||
return new self("Could not map doctrine 1 type '$type'!");
|
||||
|
@ -21,7 +21,7 @@ class LegacyUser
|
||||
*/
|
||||
public $_username;
|
||||
/**
|
||||
* @Column(type="string", length=255)
|
||||
* @Column(type="string", length=255, name="name")
|
||||
*/
|
||||
public $_name;
|
||||
/**
|
||||
|
@ -23,12 +23,12 @@ class LegacyUserReference
|
||||
private $_target;
|
||||
|
||||
/**
|
||||
* @column(type="string")
|
||||
* @column(type="string", name="description")
|
||||
*/
|
||||
private $_description;
|
||||
|
||||
/**
|
||||
* @column(type="datetime")
|
||||
* @column(type="datetime", name="created")
|
||||
*/
|
||||
private $_created;
|
||||
|
||||
|
@ -27,14 +27,14 @@ class ReadOnlyTest extends \Doctrine\Tests\OrmFunctionalTestCase
|
||||
$this->_em->flush();
|
||||
|
||||
$readOnly->name = "Test2";
|
||||
$readOnly->number = 4321;
|
||||
$readOnly->numericValue = 4321;
|
||||
|
||||
$this->_em->flush();
|
||||
$this->_em->clear();
|
||||
|
||||
$dbReadOnly = $this->_em->find('Doctrine\Tests\ORM\Functional\ReadOnlyEntity', $readOnly->id);
|
||||
$this->assertEquals("Test1", $dbReadOnly->name);
|
||||
$this->assertEquals(1234, $dbReadOnly->number);
|
||||
$this->assertEquals(1234, $dbReadOnly->numericValue);
|
||||
}
|
||||
}
|
||||
|
||||
@ -51,11 +51,11 @@ class ReadOnlyEntity
|
||||
/** @column(type="string") */
|
||||
public $name;
|
||||
/** @Column(type="integer") */
|
||||
public $number;
|
||||
public $numericValue;
|
||||
|
||||
public function __construct($name, $number)
|
||||
{
|
||||
$this->name = $name;
|
||||
$this->number = $number;
|
||||
$this->numericValue = $number;
|
||||
}
|
||||
}
|
@ -44,11 +44,10 @@ class DDC1040Test extends \Doctrine\Tests\OrmFunctionalTestCase
|
||||
->setParameter('author', $user)
|
||||
->getResult();
|
||||
|
||||
$dql = "SELECT a FROM Doctrine\Tests\Models\CMS\CmsArticle a WHERE a.topic = :topic AND a.user = :author AND a.user = :author AND a.text = :text";
|
||||
$dql = "SELECT a FROM Doctrine\Tests\Models\CMS\CmsArticle a WHERE a.topic = :topic AND a.user = :author AND a.user = :author";
|
||||
$farticle = $this->_em->createQuery($dql)
|
||||
->setParameter('author', $user)
|
||||
->setParameter('topic', 'This is John Galt speaking!')
|
||||
->setParameter('text', 'Yadda Yadda!')
|
||||
->getSingleResult();
|
||||
|
||||
$this->assertSame($article, $farticle);
|
||||
@ -70,12 +69,11 @@ class DDC1040Test extends \Doctrine\Tests\OrmFunctionalTestCase
|
||||
$this->_em->persist($article);
|
||||
$this->_em->flush();
|
||||
|
||||
$dql = "SELECT a FROM Doctrine\Tests\Models\CMS\CmsArticle a WHERE a.topic = ?1 AND a.user = ?2 AND a.user = ?3 AND a.text = ?4";
|
||||
$dql = "SELECT a FROM Doctrine\Tests\Models\CMS\CmsArticle a WHERE a.topic = ?1 AND a.user = ?2 AND a.user = ?3";
|
||||
$farticle = $this->_em->createQuery($dql)
|
||||
->setParameter(1, 'This is John Galt speaking!')
|
||||
->setParameter(2, $user)
|
||||
->setParameter(3, $user)
|
||||
->setParameter(4, 'Yadda Yadda!')
|
||||
->getSingleResult();
|
||||
|
||||
$this->assertSame($article, $farticle);
|
||||
|
@ -106,7 +106,7 @@ class DDC1209_3
|
||||
{
|
||||
/**
|
||||
* @Id
|
||||
* @Column(type="datetime")
|
||||
* @Column(type="datetime", name="somedate")
|
||||
*/
|
||||
private $date;
|
||||
|
||||
|
@ -21,7 +21,7 @@ class DDC1228Test extends \Doctrine\Tests\OrmFunctionalTestCase
|
||||
$this->_em->getClassMetadata(__NAMESPACE__ . '\\DDC1228User'),
|
||||
$this->_em->getClassMetadata(__NAMESPACE__ . '\\DDC1228Profile'),
|
||||
));
|
||||
} catch(\PDOException $e) {
|
||||
} catch(\Exception $e) {
|
||||
|
||||
}
|
||||
}
|
||||
@ -90,10 +90,10 @@ class DDC1228User
|
||||
public $id;
|
||||
|
||||
/**
|
||||
* @column(type="string")
|
||||
* @Column(type="string")
|
||||
* @var string
|
||||
*/
|
||||
public $name = '';
|
||||
public $name = 'Bar';
|
||||
|
||||
/**
|
||||
* @OneToOne(targetEntity="DDC1228Profile")
|
||||
|
@ -19,7 +19,7 @@ class DDC1238Test extends \Doctrine\Tests\OrmFunctionalTestCase
|
||||
$this->_schemaTool->createSchema(array(
|
||||
$this->_em->getClassMetadata(__NAMESPACE__ . '\\DDC1238User'),
|
||||
));
|
||||
} catch(\PDOException $e) {
|
||||
} catch(\Exception $e) {
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -7,17 +7,17 @@ use DateTime;
|
||||
require_once __DIR__ . '/../../../TestInit.php';
|
||||
|
||||
/**
|
||||
* @group DDC-1135
|
||||
* @group DDC-1335
|
||||
*/
|
||||
class DDC1135Test extends \Doctrine\Tests\OrmFunctionalTestCase
|
||||
class DDC1335Test extends \Doctrine\Tests\OrmFunctionalTestCase
|
||||
{
|
||||
protected function setUp()
|
||||
{
|
||||
parent::setUp();
|
||||
try {
|
||||
$this->_schemaTool->createSchema(array(
|
||||
$this->_em->getClassMetadata(__NAMESPACE__ . '\DDC1135User'),
|
||||
$this->_em->getClassMetadata(__NAMESPACE__ . '\DDC1135Phone'),
|
||||
$this->_em->getClassMetadata(__NAMESPACE__ . '\DDC1335User'),
|
||||
$this->_em->getClassMetadata(__NAMESPACE__ . '\DDC1335Phone'),
|
||||
));
|
||||
$this->loadFixture();
|
||||
} catch(\Exception $e) {
|
||||
@ -27,7 +27,7 @@ class DDC1135Test extends \Doctrine\Tests\OrmFunctionalTestCase
|
||||
|
||||
public function testDql()
|
||||
{
|
||||
$dql = 'SELECT u FROM ' . __NAMESPACE__ . '\DDC1135User u INDEX BY u.id';
|
||||
$dql = 'SELECT u FROM ' . __NAMESPACE__ . '\DDC1335User u INDEX BY u.id';
|
||||
$query = $this->_em->createQuery($dql);
|
||||
$result = $query->getResult();
|
||||
|
||||
@ -36,7 +36,7 @@ class DDC1135Test extends \Doctrine\Tests\OrmFunctionalTestCase
|
||||
$this->assertArrayHasKey(2, $result);
|
||||
$this->assertArrayHasKey(3, $result);
|
||||
|
||||
$dql = 'SELECT u, p FROM '.__NAMESPACE__ . '\DDC1135User u INDEX BY u.email INNER JOIN u.phones p INDEX BY p.id';
|
||||
$dql = 'SELECT u, p FROM '.__NAMESPACE__ . '\DDC1335User u INDEX BY u.email INNER JOIN u.phones p INDEX BY p.id';
|
||||
$query = $this->_em->createQuery($dql);
|
||||
$result = $query->getResult();
|
||||
|
||||
@ -65,7 +65,7 @@ class DDC1135Test extends \Doctrine\Tests\OrmFunctionalTestCase
|
||||
public function testTicket()
|
||||
{
|
||||
$builder = $this->_em->createQueryBuilder();
|
||||
$builder->select('u')->from(__NAMESPACE__ . '\DDC1135User', 'u', 'u.id');
|
||||
$builder->select('u')->from(__NAMESPACE__ . '\DDC1335User', 'u', 'u.id');
|
||||
|
||||
$dql = $builder->getQuery()->getDQL();
|
||||
$result = $builder->getQuery()->getResult();
|
||||
@ -74,13 +74,13 @@ class DDC1135Test extends \Doctrine\Tests\OrmFunctionalTestCase
|
||||
$this->assertArrayHasKey(1, $result);
|
||||
$this->assertArrayHasKey(2, $result);
|
||||
$this->assertArrayHasKey(3, $result);
|
||||
$this->assertEquals('SELECT u FROM ' . __NAMESPACE__ . '\DDC1135User u INDEX BY u.id', $dql);
|
||||
$this->assertEquals('SELECT u FROM ' . __NAMESPACE__ . '\DDC1335User u INDEX BY u.id', $dql);
|
||||
}
|
||||
|
||||
public function testIndexByUnique()
|
||||
{
|
||||
$builder = $this->_em->createQueryBuilder();
|
||||
$builder->select('u')->from(__NAMESPACE__ . '\DDC1135User', 'u', 'u.email');
|
||||
$builder->select('u')->from(__NAMESPACE__ . '\DDC1335User', 'u', 'u.email');
|
||||
|
||||
$dql = $builder->getQuery()->getDQL();
|
||||
$result = $builder->getQuery()->getResult();
|
||||
@ -89,14 +89,14 @@ class DDC1135Test extends \Doctrine\Tests\OrmFunctionalTestCase
|
||||
$this->assertArrayHasKey('foo@foo.com', $result);
|
||||
$this->assertArrayHasKey('bar@bar.com', $result);
|
||||
$this->assertArrayHasKey('foobar@foobar.com', $result);
|
||||
$this->assertEquals('SELECT u FROM ' . __NAMESPACE__ . '\DDC1135User u INDEX BY u.email', $dql);
|
||||
$this->assertEquals('SELECT u FROM ' . __NAMESPACE__ . '\DDC1335User u INDEX BY u.email', $dql);
|
||||
}
|
||||
|
||||
public function testIndexWithJoin()
|
||||
{
|
||||
$builder = $this->_em->createQueryBuilder();
|
||||
$builder->select('u','p')
|
||||
->from(__NAMESPACE__ . '\DDC1135User', 'u', 'u.email')
|
||||
->from(__NAMESPACE__ . '\DDC1335User', 'u', 'u.email')
|
||||
->join('u.phones', 'p', null, null, 'p.id');
|
||||
|
||||
$dql = $builder->getQuery()->getDQL();
|
||||
@ -123,7 +123,7 @@ class DDC1135Test extends \Doctrine\Tests\OrmFunctionalTestCase
|
||||
$this->assertArrayHasKey(8, $result['foobar@foobar.com']->phones->toArray());
|
||||
$this->assertArrayHasKey(9, $result['foobar@foobar.com']->phones->toArray());
|
||||
|
||||
$this->assertEquals('SELECT u, p FROM '.__NAMESPACE__ . '\DDC1135User u INDEX BY u.email INNER JOIN u.phones p INDEX BY p.id', $dql);
|
||||
$this->assertEquals('SELECT u, p FROM '.__NAMESPACE__ . '\DDC1335User u INDEX BY u.email INNER JOIN u.phones p INDEX BY p.id', $dql);
|
||||
}
|
||||
|
||||
private function loadFixture()
|
||||
@ -132,9 +132,9 @@ class DDC1135Test extends \Doctrine\Tests\OrmFunctionalTestCase
|
||||
$p2 = array('22 xxxx-xxxx','22 yyyy-yyyy','22 zzzz-zzzz');
|
||||
$p3 = array('33 xxxx-xxxx','33 yyyy-yyyy','33 zzzz-zzzz');
|
||||
|
||||
$u1 = new DDC1135User("foo@foo.com", "Foo",$p1);
|
||||
$u2 = new DDC1135User("bar@bar.com", "Bar",$p2);
|
||||
$u3 = new DDC1135User("foobar@foobar.com", "Foo Bar",$p3);
|
||||
$u1 = new DDC1335User("foo@foo.com", "Foo",$p1);
|
||||
$u2 = new DDC1335User("bar@bar.com", "Bar",$p2);
|
||||
$u3 = new DDC1335User("foobar@foobar.com", "Foo Bar",$p3);
|
||||
|
||||
$this->_em->persist($u1);
|
||||
$this->_em->persist($u2);
|
||||
@ -148,7 +148,7 @@ class DDC1135Test extends \Doctrine\Tests\OrmFunctionalTestCase
|
||||
/**
|
||||
* @Entity
|
||||
*/
|
||||
class DDC1135User
|
||||
class DDC1335User
|
||||
{
|
||||
/**
|
||||
* @Id @Column(type="integer")
|
||||
@ -167,7 +167,7 @@ class DDC1135User
|
||||
public $name;
|
||||
|
||||
/**
|
||||
* @OneToMany(targetEntity="DDC1135Phone", mappedBy="user", cascade={"persist", "remove"})
|
||||
* @OneToMany(targetEntity="DDC1335Phone", mappedBy="user", cascade={"persist", "remove"})
|
||||
*/
|
||||
public $phones;
|
||||
|
||||
@ -178,7 +178,7 @@ class DDC1135User
|
||||
$this->phones = new \Doctrine\Common\Collections\ArrayCollection();
|
||||
|
||||
foreach ($numbers as $number) {
|
||||
$this->phones->add(new DDC1135Phone($this,$number));
|
||||
$this->phones->add(new DDC1335Phone($this,$number));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -186,22 +186,22 @@ class DDC1135User
|
||||
/**
|
||||
* @Entity
|
||||
*/
|
||||
class DDC1135Phone
|
||||
class DDC1335Phone
|
||||
{
|
||||
/**
|
||||
* @Id
|
||||
* @Column(name="id", type="integer")
|
||||
* @GeneratedValue(strategy="AUTO")
|
||||
* @GeneratedValue
|
||||
*/
|
||||
public $id;
|
||||
|
||||
/**
|
||||
* @Column(name="number", type="string", nullable = false)
|
||||
* @Column(name="numericalValue", type="string", nullable = false)
|
||||
*/
|
||||
public $number;
|
||||
public $numericalValue;
|
||||
|
||||
/**
|
||||
* @ManyToOne(targetEntity="DDC1135User", inversedBy="phones")
|
||||
* @ManyToOne(targetEntity="DDC1335User", inversedBy="phones")
|
||||
* @JoinColumn(name="user_id", referencedColumnName="id", nullable = false)
|
||||
*/
|
||||
public $user;
|
||||
@ -209,6 +209,6 @@ class DDC1135Phone
|
||||
public function __construct($user, $number)
|
||||
{
|
||||
$this->user = $user;
|
||||
$this->number = $number;
|
||||
$this->numericalValue = $number;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user