Exemple #1
0
 /**
  * {@inheritdoc}
  */
 public function setType(Type $type)
 {
     if ($this->constructed) {
         $this->setOptions([OroOptions::KEY => [ExtendOptionsManager::TYPE_OPTION => $type->getName()]]);
     }
     return parent::setType($type);
 }
Exemple #2
0
 public static function getTypeByDoctrineType(Type $type)
 {
     $mapping = array_flip(self::$mapping);
     if (isset($mapping[$type->getName()])) {
         return $mapping[$type->getName()];
     } else {
         return TableInterface::TYPE_VARCHAR;
     }
 }
Exemple #3
0
 /**
  * {@inheritdoc}
  */
 public function isCommentedDoctrineType(Type $doctrineType)
 {
     if ($doctrineType->getName() === Type::BOOLEAN) {
         // We require a commented boolean type in order to distinguish between boolean and smallint
         // as both (have to) map to the same native type.
         return true;
     }
     return parent::isCommentedDoctrineType($doctrineType);
 }
 public function testArray()
 {
     $photo = new Photo();
     $photo->setNom('wohoo');
     $serialized = $this->type->convertToDatabaseValue([$photo], $this->plateform);
     $unserialized = $this->type->convertToPHPValue($serialized, $this->plateform);
     $this->assertInstanceOf(Photo::class, $unserialized[0]);
     /** @var Photo $var */
     $var = $unserialized[0];
     $this->assertEquals('wohoo', $var->getNom());
 }
Exemple #5
0
 public function doctrineColumnLookup($col_lookup)
 {
     if (isset($this->options['expr']) && isset($col_lookup[$this->options['expr']])) {
         /**
          * @var $col Column
          */
         $col = $col_lookup[$this->options['expr']];
         $this->type = $col->getType();
         $this->typeName = self::simplifyTypeName($this->type->getName());
     }
 }
 /**
  * @param Schema   $schema
  * @param QueryBag $queries
  * @param string   $tableName
  * @param string   $columnName
  * @param string   $type
  *
  * @throws \Exception
  */
 public function changePrimaryKeyType(Schema $schema, QueryBag $queries, $tableName, $columnName, $type)
 {
     $targetColumn = $schema->getTable($tableName)->getColumn($columnName);
     $type = Type::getType($type);
     if ($targetColumn->getType() === $type) {
         return;
     }
     /** @var ForeignKeyConstraint[] $foreignKeys */
     $foreignKeys = [];
     foreach ($schema->getTables() as $table) {
         /** @var ForeignKeyConstraint[] $tableForeignKeys */
         $tableForeignKeys = array_filter($table->getForeignKeys(), function (ForeignKeyConstraint $tableForeignKey) use($tableName, $columnName) {
             if ($tableForeignKey->getForeignTableName() !== $tableName) {
                 return false;
             }
             return $tableForeignKey->getForeignColumns() === [$columnName];
         });
         foreach ($tableForeignKeys as $tableForeignKey) {
             $foreignKeys[$tableForeignKey->getName()] = $tableForeignKey;
             $foreignKeyTableName = $tableForeignKey->getLocalTable()->getName();
             $foreignKeyColumnNames = $tableForeignKey->getLocalColumns();
             $queries->addPreQuery($this->platform->getDropForeignKeySQL($tableForeignKey, $foreignKeyTableName));
             $column = $schema->getTable($foreignKeyTableName)->getColumn(reset($foreignKeyColumnNames));
             if ($column instanceof ExtendColumn) {
                 $column->disableExtendOptions()->setType($type)->enableExtendOptions();
             } else {
                 $column->setType($type);
             }
         }
     }
     $targetColumn->setType($type);
     foreach ($foreignKeys as $foreignKey) {
         $queries->addPostQuery($this->platform->getCreateForeignKeySQL($foreignKey, $foreignKey->getLocalTable()));
     }
 }
 /**
  * Replaces default DateTime Doctrine types with their _immutable counterparts
  */
 public static function replaceImmutableTypes()
 {
     Type::overrideType(Type::DATE, DateTimeImmutable\DateImmutableType::class);
     Type::overrideType(Type::DATETIME, DateTimeImmutable\DateTimeImmutableType::class);
     Type::overrideType(Type::DATETIMETZ, DateTimeImmutable\DateTimeTzImmutableType::class);
     Type::overrideType(Type::TIME, DateTimeImmutable\TimeImmutableType::class);
 }
Exemple #8
0
 protected function convertResultsInternal($results, AbstractPlatform $platform, CaseSensor $sensor)
 {
     if (is_array($results)) {
         $results = current($results);
     }
     return Type::getType($this->type)->convertToPHPValue($results, $platform);
 }
 /**
  * {@inheritdoc}
  */
 protected function _getPortableTableColumnDefinition($tableColumn)
 {
     $tableColumn = array_change_key_case($tableColumn, \CASE_LOWER);
     $length = null;
     $fixed = null;
     $unsigned = false;
     $scale = false;
     $precision = false;
     $type = $this->_platform->getDoctrineTypeMapping($tableColumn['typename']);
     switch (strtolower($tableColumn['typename'])) {
         case 'varchar':
             $length = $tableColumn['length'];
             $fixed = false;
             break;
         case 'character':
             $length = $tableColumn['length'];
             $fixed = true;
             break;
         case 'clob':
             $length = $tableColumn['length'];
             break;
         case 'decimal':
         case 'double':
         case 'real':
             $scale = $tableColumn['scale'];
             $precision = $tableColumn['length'];
             break;
     }
     $options = array('length' => $length, 'unsigned' => (bool) $unsigned, 'fixed' => (bool) $fixed, 'default' => $tableColumn['default'] == "NULL" ? null : $tableColumn['default'], 'notnull' => (bool) ($tableColumn['nulls'] == 'N'), 'scale' => null, 'precision' => null, 'platformOptions' => array());
     if ($scale !== null && $precision !== null) {
         $options['scale'] = $scale;
         $options['precision'] = $precision;
     }
     return new Column($tableColumn['colname'], \Doctrine\DBAL\Types\Type::getType($type), $options);
 }
Exemple #10
0
 public function buildForm(FormBuilderInterface $builder, array $options)
 {
     $schemaManager = $this->container['db']->getSchemaManager();
     foreach ($schemaManager->listTableColumns($this->table) as $column) {
         // here we try to display nicely database relations w/ foreign keys
         if (false !== strpos($column->getName(), '_id')) {
             $table = str_replace('_id', '', $column->getName());
             $dataMap = new DataMap($this->container['db'], $schemaManager);
             $choices = $dataMap->mapForeignKeys($table, $column);
             if (is_array($choices)) {
                 $column->setType(Type::getType('array'));
             }
         }
         switch ($column->getType()) {
             case 'Integer':
                 $builder->add($column->getName(), 'integer', array('read_only' => $column->getName() === 'id' ? true : false, 'required' => $column->getNotNull()));
                 break;
             case 'Array':
                 $builder->add($column->getName(), 'choice', array('choices' => $choices, 'required' => $column->getNotNull()));
                 break;
             case 'Boolean':
                 $builder->add($column->getName(), 'checkbox', array('required' => false));
                 break;
             case 'String':
                 $builder->add($column->getName(), 'text', array('required' => $column->getNotNull()));
                 break;
             case 'Text':
                 $builder->add($column->getName(), 'textarea', array('required' => $column->getNotNull()));
                 break;
         }
     }
 }
Exemple #11
0
 protected function setUp()
 {
     parent::setUp();
     DDC2494TinyIntType::$calls = array();
     Type::addType('ddc2494_tinyint', __NAMESPACE__ . '\\DDC2494TinyIntType');
     $this->_schemaTool->createSchema(array($this->_em->getClassMetadata(DDC2494Currency::CLASSNAME), $this->_em->getClassMetadata(DDC2494Campaign::CLASSNAME)));
 }
Exemple #12
0
 protected function setUp()
 {
     parent::setUp();
     Type::addType(DDC2012TsVectorType::MYTYPE, __NAMESPACE__ . '\\DDC2012TsVectorType');
     DDC2012TsVectorType::$calls = array();
     $this->_schemaTool->createSchema(array($this->_em->getClassMetadata(__NAMESPACE__ . '\\DDC2012Item'), $this->_em->getClassMetadata(__NAMESPACE__ . '\\DDC2012ItemPerson')));
 }
 /**
  * Create service
  *
  * @param  ServiceLocatorInterface $validators
  * @return mixed
  */
 public function createService(ServiceLocatorInterface $validators)
 {
     if (isset($this->options['enum'])) {
         $this->options['enum'] = DoctrineType::getType($this->options['enum']);
     }
     return new EnumValidator($this->options);
 }
 public function boot()
 {
     if (!Type::hasType('branch_logo')) {
         Type::addType('branch_logo', 'Diamante\\DeskBundle\\Infrastructure\\Persistence\\Doctrine\\DBAL\\Types\\BranchLogoType');
     }
     if (!Type::hasType('priority')) {
         Type::addType('priority', 'Diamante\\DeskBundle\\Infrastructure\\Persistence\\Doctrine\\DBAL\\Types\\TicketPriorityType');
     }
     if (!Type::hasType('file')) {
         Type::addType('file', 'Diamante\\DeskBundle\\Infrastructure\\Persistence\\Doctrine\\DBAL\\Types\\AttachmentFileType');
     }
     if (!Type::hasType('status')) {
         Type::addType('status', 'Diamante\\DeskBundle\\Infrastructure\\Persistence\\Doctrine\\DBAL\\Types\\TicketStatusType');
     }
     if (!Type::hasType('source')) {
         Type::addType('source', 'Diamante\\DeskBundle\\Infrastructure\\Persistence\\Doctrine\\DBAL\\Types\\TicketSourceType');
     }
     if (!Type::hasType('ticket_sequence_number')) {
         Type::addType('ticket_sequence_number', 'Diamante\\DeskBundle\\Infrastructure\\Persistence\\Doctrine\\DBAL\\Types\\TicketSequenceNumberType');
     }
     if (!Type::hasType('ticket_unique_id')) {
         Type::addType('ticket_unique_id', 'Diamante\\DeskBundle\\Infrastructure\\Persistence\\Doctrine\\DBAL\\Types\\TicketUniqueIdType');
     }
     foreach ($this->dataAuditTypes as $type) {
         if (!AuditFieldTypeRegistry::hasType($type)) {
             AuditFieldTypeRegistry::addType($type, $type);
         }
     }
     $em = $this->container->get('doctrine.orm.default_entity_manager');
     $conn = $em->getConnection();
     $conn->getDatabasePlatform()->registerDoctrineTypeMapping('FILE', 'string');
 }
Exemple #15
0
 public static function getEntityManager($smart = FALSE, $path_to_entity = null, $proxyPath = null, $proxyNamespace = null)
 {
     if (empty(self::$em)) {
         if ($path_to_entity === NULL) {
             //$path_to_entity = PATH_ROOT . '/' . Sokol::getApp()->name . '/Entity';
             $path_to_entity = PATH_ROOT . '/Entity';
         }
         $isDev = Sokol::getApp()->isDev;
         $connectionParams = Sokol::getConfig('db');
         //---Table Prefix---
         $tablePrefix = !empty($connectionParams['tablePrefix']) ? $connectionParams['tablePrefix'] : null;
         if ($tablePrefix) {
             $evm = new EventManager();
             $tablePrefix = new TablePrefix($tablePrefix);
             $evm->addEventListener(Events::loadClassMetadata, $tablePrefix);
         }
         //---/Table Prefix---
         if ($smart) {
             self::$em = self::getEmSmart($path_to_entity, $isDev, $connectionParams, $evm);
         } else {
             if ($proxyPath === NULL) {
                 $proxyPath = PATH_ROOT . '/' . Sokol::getApp()->name . '/Proxy';
             }
             if ($proxyNamespace === NULL) {
                 $proxyNamespace = Sokol::getApp()->getNamespace() . '\\Proxy';
             }
             self::$em = self::getEm($path_to_entity, $isDev, $connectionParams, $evm, $proxyPath, $proxyNamespace);
         }
         //подключаем тип данных "html"
         Type::addType('html', 'Sokol\\Doctrine\\Extension\\HtmlType');
         self::$em->getConnection()->getDatabasePlatform()->registerDoctrineTypeMapping('db_html', 'html');
     }
     return self::$em;
 }
 /**
  * Adds doctrine point type
  *
  * @param LoadClassMetadataEventArgs $eventArgs
  */
 public function loadClassMetadata(LoadClassMetadataEventArgs $eventArgs)
 {
     $classMetadata = $eventArgs->getClassMetadata();
     if (null === $classMetadata->reflClass) {
         return;
     }
     if ($this->isGeocodable($classMetadata)) {
         if (!Type::hasType('point')) {
             Type::addType('point', 'Knp\\DoctrineBehaviors\\DBAL\\Types\\PointType');
         }
         $em = $eventArgs->getEntityManager();
         $con = $em->getConnection();
         // skip non-postgres platforms
         if (!$con->getDatabasePlatform() instanceof PostgreSqlPlatform && !$con->getDatabasePlatform() instanceof MySqlPlatform) {
             return;
         }
         // skip platforms with registerd stuff
         if (!$con->getDatabasePlatform()->hasDoctrineTypeMappingFor('point')) {
             $con->getDatabasePlatform()->registerDoctrineTypeMapping('point', 'point');
             if ($con->getDatabasePlatform() instanceof PostgreSqlPlatform) {
                 $em->getConfiguration()->addCustomNumericFunction('DISTANCE', 'Knp\\DoctrineBehaviors\\ORM\\Geocodable\\Query\\AST\\Functions\\DistanceFunction');
             }
         }
         $classMetadata->mapField(['fieldName' => 'location', 'type' => 'point', 'nullable' => true]);
     }
 }
 public function __construct(Connection $con)
 {
     $this->con = $con;
     $this->platform = $con->getDatabasePlatform();
     $this->phpType = Type::getType(PhpTypeType::NAME);
     $this->insertStmt = $con->prepare(self::INSERT_SQL);
 }
 /**
  * Boots the bundle
  *
  * @return void
  */
 public function boot()
 {
     if ($this->container->has('doctrine')) {
         Type::addType(MbStringType::TYPE_NAME, MbStringType::class);
         Type::addType(StdStringType::TYPE_NAME, StdStringType::class);
         Type::addType(DateTimeType::TYPE_NAME, DateTimeType::class);
         Type::addType(DateType::TYPE_NAME, DateType::class);
         Type::addType(TimeType::TYPE_NAME, TimeType::class);
         Type::addType(TimezoneType::TYPE_NAME, TimezoneType::class);
         Type::addType(UuidType::TYPE_NAME, UuidType::class);
         Type::addType(CurrencyType::TYPE_NAME, CurrencyType::class);
         Type::addType(MoneyType::TYPE_NAME, MoneyType::class);
         Type::addType(UriType::TYPE_NAME, UriType::class);
         Type::addType(UrlType::TYPE_NAME, UrlType::class);
         /** @var EntityManager $entityManager */
         $entityManager = $this->container->get('doctrine')->getManager();
         /** @var AbstractPlatform $platform */
         $platform = $entityManager->getConnection()->getDatabasePlatform();
         $platform->registerDoctrineTypeMapping('db_' . MbStringType::TYPE_NAME, MbStringType::TYPE_NAME);
         $platform->registerDoctrineTypeMapping('db_' . StdStringType::TYPE_NAME, StdStringType::TYPE_NAME);
         $platform->registerDoctrineTypeMapping('db_' . DateTimeType::TYPE_NAME, DateTimeType::TYPE_NAME);
         $platform->registerDoctrineTypeMapping('db_' . DateType::TYPE_NAME, DateType::TYPE_NAME);
         $platform->registerDoctrineTypeMapping('db_' . TimeType::TYPE_NAME, TimeType::TYPE_NAME);
         $platform->registerDoctrineTypeMapping('db_' . TimezoneType::TYPE_NAME, TimezoneType::TYPE_NAME);
         $platform->registerDoctrineTypeMapping('db_' . UuidType::TYPE_NAME, UuidType::TYPE_NAME);
         $platform->registerDoctrineTypeMapping('db_' . CurrencyType::TYPE_NAME, CurrencyType::TYPE_NAME);
         $platform->registerDoctrineTypeMapping('db_' . MoneyType::TYPE_NAME, MoneyType::TYPE_NAME);
         $platform->registerDoctrineTypeMapping('db_' . UriType::TYPE_NAME, UriType::TYPE_NAME);
         $platform->registerDoctrineTypeMapping('db_' . UrlType::TYPE_NAME, UrlType::TYPE_NAME);
     }
 }
 protected function setUp()
 {
     $this->platform = $this->getMockBuilder('Doctrine\\DBAL\\Platforms\\AbstractPlatform')->setMethods(array('getVarcharTypeDeclarationSQL'))->getMockForAbstractClass();
     $this->platform->expects($this->any())->method('getVarcharTypeDeclarationSQL')->will($this->returnValue('DUMMYVARCHAR()'));
     $this->type = Type::getType('phone_number');
     $this->phoneNumberUtil = PhoneNumberUtil::getInstance();
 }
 public function __construct($setConfigFiles = true)
 {
     if ($setConfigFiles) {
         $this->configFile = __DIR__ . '/../../../config.php';
         $this->localConfigFile = __DIR__ . '/../../../config.local.php';
     }
     parent::__construct();
     $isDevMode = false;
     $cache = new \Doctrine\Common\Cache\FilesystemCache(__DIR__ . '/../../tmp');
     $config = Setup::createConfiguration($isDevMode, __DIR__ . '/../../tmp', $cache);
     $config->setProxyDir(__DIR__ . '/../../tmp');
     $config->setProxyNamespace('MyProject\\Proxies');
     $config->setAutoGenerateProxyClasses(true);
     $paths = [__DIR__ . '/../Entity'];
     $driver = new \Doctrine\ORM\Mapping\Driver\AnnotationDriver(new AnnotationReader(), $paths);
     \Doctrine\Common\Annotations\AnnotationRegistry::registerLoader('class_exists');
     $config->setMetadataDriverImpl($driver);
     //$config->setSQLLogger(new \Doctrine\DBAL\Logging\EchoSQLLogger());
     $conn = ['driver' => 'mysqli', 'host' => '127.0.0.1', 'user' => $this->databaseFactory->getUserName(), 'password' => $this->databaseFactory->getPassword(), 'dbname' => $this->databaseFactory->getDatabaseName()];
     $this->entityManager = EntityManager::create($conn, $config);
     $this->entityManager->getConnection()->getDatabasePlatform()->registerDoctrineTypeMapping('enum', 'string');
     \Doctrine\DBAL\Types\Type::addType('enum', StringType::class);
     $this->entityManager->getConfiguration()->addCustomStringFunction('DATE', DateFunction::class);
     $this->user = $this->entityManager->createQueryBuilder()->select('u')->from(Sources\Tests\Entity\User::class, 'u');
 }
 /**
  * @param array $column
  *
  * @return Column
  */
 protected function _getPortableTableColumnDefinition($column)
 {
     $type = $this->orient2Doctrine[$column['type']];
     $type = $this->_platform->getDoctrineTypeMapping($type);
     $options = array('default' => isset($column['defaultValue']) ? $column['defaultValue'] : null, 'notnull' => isset($column['notNull']) ? $column['notNull'] : null, 'collate' => isset($column['collate']) ? $column['collate'] : null, 'length' => null, 'unsigned' => false, 'fixed' => false, 'scale' => null, 'precision' => null, 'autoincrement' => false, 'comment' => null);
     return new Column($column['name'], Type::getType($type), $options);
 }
 /**
  * {@inheritdoc}
  */
 public function convertValue($value, array $options, ConversionHints $hints)
 {
     if (2 === $hints->conversionStrategy || 3 === $hints->conversionStrategy) {
         return DBALType::getType('date')->convertToDatabaseValue($value, $hints->connection->getDatabasePlatform());
     }
     return (int) $value;
 }
 public function test_importSchemaArray()
 {
     $instance = new Xoops\Core\Database\Schema\ExportVisitor();
     $table = new Doctrine\DBAL\Schema\Table('system_group');
     $type = Type::getType(Type::INTEGER);
     $col_name = 'groupid';
     $column = new Doctrine\DBAL\Schema\Column($col_name, $type);
     $instance->acceptColumn($table, $column);
     $columns = array('groupid');
     $fk_table = 'system_permission';
     $fk_name = 'fk_name';
     $fk_options = array('o' => 'o1');
     $fk_columns = array('system_permission');
     $fk_constraint = new Doctrine\DBAL\Schema\ForeignKeyConstraint($columns, $fk_table, $fk_columns, $fk_name, $fk_options);
     $instance->acceptForeignKey($table, $fk_constraint);
     $name = 'index_name';
     $columns = array('name', 'description');
     $unique = true;
     $primary = true;
     $index = new Doctrine\DBAL\Schema\Index($name, $columns, $unique, $primary);
     $instance->acceptIndex($table, $index);
     $name = 'sequence_name';
     $alloc_size = 10;
     $initial_value = 11;
     $sequence = new Doctrine\DBAL\Schema\Sequence($name, $alloc_size, $initial_value);
     $instance->acceptSequence($sequence);
     $schema = $instance->getSchemaArray();
     $import = new $this->myClass();
     $value = $import->importSchemaArray($schema);
     $this->assertInstanceOf('Doctrine\\DBAL\\Schema\\Schema', $value);
 }
 /**
  * Walks down a SelectStatement AST node, modifying it to retrieve DISTINCT ids
  * of the root Entity
  *
  * @param SelectStatement $AST
  * @return void
  */
 public function walkSelectStatement(SelectStatement $AST)
 {
     $parent = null;
     $parentName = null;
     $selectExpressions = array();
     foreach ($this->_getQueryComponents() as $dqlAlias => $qComp) {
         // preserve mixed data in query for ordering
         if (isset($qComp['resultVariable'])) {
             $selectExpressions[] = new SelectExpression($qComp['resultVariable'], $dqlAlias);
             continue;
         }
         if ($qComp['parent'] === null && $qComp['nestingLevel'] == 0) {
             $parent = $qComp;
             $parentName = $dqlAlias;
             continue;
         }
     }
     $identifier = $parent['metadata']->getSingleIdentifierFieldName();
     $this->_getQuery()->setHint(self::IDENTIFIER_TYPE, Type::getType($parent['metadata']->getTypeOfField($identifier)));
     $pathExpression = new PathExpression(PathExpression::TYPE_STATE_FIELD | PathExpression::TYPE_SINGLE_VALUED_ASSOCIATION, $parentName, $identifier);
     $pathExpression->type = PathExpression::TYPE_STATE_FIELD;
     array_unshift($selectExpressions, new SelectExpression($pathExpression, '_dctrn_id'));
     $AST->selectClause->selectExpressions = $selectExpressions;
     if (isset($AST->orderByClause)) {
         foreach ($AST->orderByClause->orderByItems as $item) {
             if ($item->expression instanceof PathExpression) {
                 $pathExpression = new PathExpression(PathExpression::TYPE_STATE_FIELD | PathExpression::TYPE_SINGLE_VALUED_ASSOCIATION, $item->expression->identificationVariable, $item->expression->field);
                 $pathExpression->type = PathExpression::TYPE_STATE_FIELD;
                 $AST->selectClause->selectExpressions[] = new SelectExpression($pathExpression, '_dctrn_ord' . $this->_aliasCounter++);
             }
         }
     }
     $AST->selectClause->isDistinct = true;
 }
 /**
  * @group DDC-1337
  * @return void
  */
 public function testCreateTemporaryTableNotAutoCommitTransaction()
 {
     if ($this->_conn->getDatabasePlatform()->getName() == 'sqlanywhere' || $this->_conn->getDatabasePlatform()->getName() == 'oracle') {
         $this->markTestSkipped("Test does not work on Oracle and SQL Anywhere.");
     }
     $platform = $this->_conn->getDatabasePlatform();
     $columnDefinitions = array("id" => array("type" => Type::getType("integer"), "notnull" => true));
     $tempTable = $platform->getTemporaryTableName("my_temporary");
     $createTempTableSQL = $platform->getCreateTemporaryTableSnippetSQL() . ' ' . $tempTable . ' (' . $platform->getColumnDeclarationListSQL($columnDefinitions) . ')';
     $table = new Table("nontemporary");
     $table->addColumn("id", "integer");
     $table->setPrimaryKey(array('id'));
     foreach ($platform->getCreateTableSQL($table) as $sql) {
         $this->_conn->executeQuery($sql);
     }
     $this->_conn->beginTransaction();
     $this->_conn->insert("nontemporary", array("id" => 1));
     $this->_conn->exec($createTempTableSQL);
     $this->_conn->insert("nontemporary", array("id" => 2));
     $this->_conn->rollback();
     try {
         $this->_conn->exec($platform->getDropTemporaryTableSQL($tempTable));
     } catch (\Exception $e) {
     }
     $rows = $this->_conn->fetchAll('SELECT * FROM nontemporary');
     $this->assertEquals(array(), $rows, "In an event of an error this result has one row, because of an implicit commit.");
 }
 protected function setUp()
 {
     if (!Type::hasType(PercentType::TYPE)) {
         Type::addType(PercentType::TYPE, 'Oro\\DBAL\\Types\\PercentType');
     }
     $this->percentType = Type::getType(PercentType::TYPE);
 }
 function let()
 {
     if (!Type::hasType(GeographicLocationType::NAME)) {
         Type::addType(GeographicLocationType::NAME, 'DoctrineExt\\DBAL\\Types\\GeographicLocationType');
     }
     $this->beConstructedThrough('getType', [GeographicLocationType::NAME]);
 }
 public function boot()
 {
     if (!Type::hasType('string_simple_array')) {
         // this should be optional if using a different ORM
         Type::addType('string_simple_array', 'Giosh94mhz\\GeonamesBundle\\Doctrine\\Types\\StringSimpleArrayType');
     }
 }
Exemple #29
0
 public function testContainer()
 {
     $container = $this->createYamlBundleTestContainer();
     $this->assertInstanceOf('Symfony\\Bridge\\Doctrine\\Logger\\DbalLogger', $container->get('doctrine.dbal.logger'));
     $this->assertInstanceOf('Symfony\\Bridge\\Doctrine\\DataCollector\\DoctrineDataCollector', $container->get('data_collector.doctrine'));
     $this->assertInstanceOf('Doctrine\\DBAL\\Configuration', $container->get('doctrine.dbal.default_connection.configuration'));
     $this->assertInstanceOf('Doctrine\\Common\\EventManager', $container->get('doctrine.dbal.default_connection.event_manager'));
     $this->assertInstanceOf('Doctrine\\DBAL\\Connection', $container->get('doctrine.dbal.default_connection'));
     $this->assertInstanceOf('Doctrine\\Common\\Annotations\\Reader', $container->get('doctrine.orm.metadata.annotation_reader'));
     $this->assertInstanceOf('Doctrine\\ORM\\Configuration', $container->get('doctrine.orm.default_configuration'));
     $this->assertInstanceOf('Doctrine\\ORM\\Mapping\\Driver\\DriverChain', $container->get('doctrine.orm.default_metadata_driver'));
     $this->assertInstanceOf('Doctrine\\Common\\Cache\\ArrayCache', $container->get('doctrine.orm.default_metadata_cache'));
     $this->assertInstanceOf('Doctrine\\Common\\Cache\\ArrayCache', $container->get('doctrine.orm.default_query_cache'));
     $this->assertInstanceOf('Doctrine\\Common\\Cache\\ArrayCache', $container->get('doctrine.orm.default_result_cache'));
     $this->assertInstanceOf('Doctrine\\ORM\\EntityManager', $container->get('doctrine.orm.default_entity_manager'));
     $this->assertInstanceOf('Doctrine\\DBAL\\Connection', $container->get('database_connection'));
     $this->assertInstanceOf('Doctrine\\ORM\\EntityManager', $container->get('doctrine.orm.entity_manager'));
     $this->assertInstanceOf('Doctrine\\Common\\EventManager', $container->get('doctrine.orm.default_entity_manager.event_manager'));
     $this->assertInstanceOf('Doctrine\\Common\\EventManager', $container->get('doctrine.dbal.event_manager'));
     $this->assertInstanceOf('Symfony\\Bridge\\Doctrine\\CacheWarmer\\ProxyCacheWarmer', $container->get('doctrine.orm.proxy_cache_warmer'));
     $this->assertInstanceOf('Doctrine\\Common\\Persistence\\ManagerRegistry', $container->get('doctrine'));
     $this->assertInstanceOf('Symfony\\Bridge\\Doctrine\\Validator\\Constraints\\UniqueEntityValidator', $container->get('doctrine.orm.validator.unique'));
     $this->assertSame($container->get('my.platform'), $container->get('doctrine.dbal.default_connection')->getDatabasePlatform());
     $this->assertTrue(Type::hasType('test'));
     if (version_compare(PHP_VERSION, '5.3.6', '<')) {
         $this->assertInstanceOf('Doctrine\\DBAL\\Event\\Listeners\\MysqlSessionInit', $container->get('doctrine.dbal.default_connection.events.mysqlsessioninit'));
     } else {
         $this->assertFalse($container->has('doctrine.dbal.default_connection.events.mysqlsessioninit'));
     }
 }
 /**
  * @return Schema[]
  */
 protected function prepareSchemas()
 {
     Type::addType('int', 'Doctrine\\DBAL\\Types\\IntegerType');
     $fromSchema = new Schema();
     $table = $fromSchema->createTable('oro_entity_extend_test_table');
     $table->addColumn('id', 'integer', ['autoincrement' => true]);
     $table->addColumn('someExternalColumn', 'string');
     $table->addColumn('relation_id', 'int');
     $table->addIndex(['someExternalColumn'], 'some_external_index_name');
     $table->setPrimaryKey(['id']);
     $tableRelation = $fromSchema->createTable('oro_entity_extend_test_relation');
     $tableRelation->addColumn('id', 'integer', ['autoincrement' => true]);
     $tableRelation->addColumn('someExtendColumn', 'string');
     $tableRelation->addIndex(['someExtendColumn'], 'oro_idx_index_name');
     $tableRelation->setPrimaryKey(['id']);
     $table->addForeignKeyConstraint($tableRelation, ['relation_id'], ['id']);
     $toSchema = new Schema();
     $table = $toSchema->createTable('oro_entity_extend_test_table');
     $table->addColumn('id', 'integer', ['autoincrement' => true]);
     $table->setPrimaryKey(['id']);
     $tableRelation = $toSchema->createTable('oro_entity_extend_test_relation');
     $tableRelation->addColumn('id', 'integer', ['autoincrement' => true]);
     $tableRelation->setPrimaryKey(['id']);
     return [$fromSchema, $toSchema];
 }