57 lines
1.7 KiB
PHP
57 lines
1.7 KiB
PHP
<?php
|
|
|
|
namespace Doctrine\Tests\ORM\Mapping;
|
|
|
|
use Doctrine\ORM\Mapping\ClassMetadata;
|
|
use Doctrine\ORM\Events;
|
|
|
|
require_once __DIR__ . '/../../TestInit.php';
|
|
|
|
class AnnotationDriverTest extends AbstractMappingDriverTest
|
|
{
|
|
/**
|
|
* @group DDC-268
|
|
*/
|
|
public function testLoadMetadataForNonEntityThrowsException()
|
|
{
|
|
$cm = new ClassMetadata('stdClass');
|
|
$reader = new \Doctrine\Common\Annotations\AnnotationReader(new \Doctrine\Common\Cache\ArrayCache());
|
|
$annotationDriver = new \Doctrine\ORM\Mapping\Driver\AnnotationDriver($reader);
|
|
|
|
$this->setExpectedException('Doctrine\ORM\Mapping\MappingException');
|
|
$annotationDriver->loadMetadataForClass('stdClass', $cm);
|
|
}
|
|
|
|
/**
|
|
* @group DDC-268
|
|
*/
|
|
public function testColumnWithMissingTypeDefaultsToString()
|
|
{
|
|
$cm = new ClassMetadata('Doctrine\Tests\ORM\Mapping\ColumnWithoutType');
|
|
$reader = new \Doctrine\Common\Annotations\AnnotationReader(new \Doctrine\Common\Cache\ArrayCache());
|
|
$reader->setDefaultAnnotationNamespace('Doctrine\ORM\Mapping\\');
|
|
$annotationDriver = new \Doctrine\ORM\Mapping\Driver\AnnotationDriver($reader);
|
|
|
|
$annotationDriver->loadMetadataForClass('Doctrine\Tests\ORM\Mapping\InvalidColumn', $cm);
|
|
$this->assertEquals('string', $cm->fieldMappings['id']['type']);
|
|
}
|
|
|
|
|
|
protected function _loadDriver()
|
|
{
|
|
$cache = new \Doctrine\Common\Cache\ArrayCache();
|
|
$reader = new \Doctrine\Common\Annotations\AnnotationReader($cache);
|
|
$reader->setDefaultAnnotationNamespace('Doctrine\ORM\Mapping\\');
|
|
return new \Doctrine\ORM\Mapping\Driver\AnnotationDriver($reader);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* @Entity
|
|
*/
|
|
class ColumnWithoutType
|
|
{
|
|
/** @Id @Column */
|
|
public $id;
|
|
}
|