forked from propelorm/Propel2
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
change methods that instantiate abstract classes
- Loading branch information
Showing
6 changed files
with
150 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
55 changes: 55 additions & 0 deletions
55
tests/Propel/Tests/Generator/Builder/Om/TestableQueryBuilder.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
<?php | ||
|
||
/** | ||
* MIT License. This file is part of the Propel package. | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Propel\Tests\Generator\Builder\Om; | ||
|
||
use Propel\Generator\Builder\Om\QueryBuilder; | ||
use Propel\Generator\Builder\Util\SchemaReader; | ||
use Propel\Generator\Config\QuickGeneratorConfig; | ||
use Propel\Generator\Platform\DefaultPlatform; | ||
|
||
/** | ||
* Utility class for QueryBuilder. | ||
*/ | ||
class TestableQueryBuilder extends QueryBuilder | ||
{ | ||
/** | ||
* Build a TestableQueryBuilder for a table given in schema xml format. | ||
* | ||
* @param string $schemaXml | ||
* @param string $tableName | ||
* | ||
* @return self | ||
*/ | ||
public static function forTableFromXml(string $schemaXml, string $tableName): self | ||
{ | ||
$reader = new SchemaReader(); | ||
$schema = $reader->parseString($schemaXml); | ||
$table = $schema->getDatabase()->getTable($tableName); | ||
$builder = new static($table); | ||
$builder->setGeneratorConfig(new QuickGeneratorConfig()); | ||
$builder->setPlatform(new DefaultPlatform()); | ||
|
||
return $builder; | ||
} | ||
|
||
/** | ||
* Call a (usually protected) script builder function by name and return the result. | ||
* | ||
* @param string $scriptBuilderFunctionName | ||
* | ||
* @return string | ||
*/ | ||
public function buildScript(string $scriptBuilderFunctionName): string | ||
{ | ||
$script = ''; | ||
call_user_func_array([$this, $scriptBuilderFunctionName], [&$script]); | ||
|
||
return $script; | ||
} | ||
} |