Skip to content
Browse files

Merge branch 'master' into survos

  • Loading branch information...
2 parents 3c669d6 + e53ccc8 commit 993562335e9b9a916ae96b9912bcfafcd3cd2317 @kcivey kcivey committed Jan 16, 2014
View
7 generator/lib/config/GeneratorConfig.php
@@ -164,11 +164,12 @@ public function getBuilderClassname($type)
public function getConfiguredPlatform(PDO $con = null, $database = null)
{
$buildConnection = $this->getBuildConnection($database);
- if (null !== $buildConnection['adapter']) {
- $clazz = Phing::import('platform.' . ucfirst($buildConnection['adapter']) . 'Platform');
- } elseif ($this->getBuildProperty('platformClass')) {
+ //First try to load platform from the user provided build properties
+ if ($this->getBuildProperty('platformClass')) {
// propel.platform.class = platform.${propel.database}Platform by default
$clazz = $this->getClassname('platformClass');
+ } elseif (null !== $buildConnection['adapter']) {
+ $clazz = Phing::import('platform.' . ucfirst($buildConnection['adapter']) . 'Platform');
} else {
return null;
}
View
6 test/fixtures/generator/platform/CustomPlatform.php
@@ -0,0 +1,6 @@
+<?php
+
+class CustomPlatform extends DefaultPlatform
+{
+
+}
View
19 test/fixtures/generator/platform/buildtime-conf.xml
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<config>
+ <log>
+ <level>7</level>
+ </log>
+ <propel>
+ <datasources>
+ <datasource id="default">
+ <!-- I want to use this platform but with my custom platform -->
+ <adapter>pgsql</adapter>
+ <connection>
+ <dsn>pgsql:host=localhost;port=5432;dbname=postgres;</dsn>
+ <user>postgres</user>
+ <password>password</password>
+ </connection>
+ </datasource>
+ </datasources>
+ </propel>
+</config>
View
31 test/testsuite/generator/platform/CustomPlatformTest.php
@@ -0,0 +1,31 @@
+<?php
+
+class CustomPlatformTest extends PHPUnit_Framework_TestCase
+{
+ /**
+ * @var GeneratorConfig
+ */
+ protected $generatorConfig;
+
+ public function setUp()
+ {
+ $projectDir = realpath(__DIR__ . '/../../../fixtures/generator/platform/');
+ $platformClass = str_replace('/', '.', $projectDir) . '.CustomPlatform';
+ $props = array(
+ "propel.project" => "kfw-propel",
+ "propel.database" => "pgsql", // Or anything else
+ "propel.projectDir" => $projectDir,
+ "propel.platform.class" => $platformClass,
+ "propel.buildtime.conf.file" => "buildtime-conf.xml"
+
+ );
+
+ $this->generatorConfig = new GeneratorConfig($props);
+ }
+
+ public function testGetPLatform()
+ {
+ $this->assertInstanceOf('CustomPlatform', $this->generatorConfig->getConfiguredPlatform());
+ $this->assertInstanceOf('CustomPlatform', $this->generatorConfig->getConfiguredPlatform(null, 'default'));
+ }
+}

0 comments on commit 9935623

Please sign in to comment.
Something went wrong with that request. Please try again.