diff --git a/.github/workflows/continuous-integration.yml b/.github/workflows/continuous-integration.yml index fa22ce9c6..89c8770bf 100644 --- a/.github/workflows/continuous-integration.yml +++ b/.github/workflows/continuous-integration.yml @@ -2,6 +2,8 @@ name: "Continuous Integration" on: pull_request: + branches: + - master paths: - .github/workflows/continuous-integration.yml - composer.* @@ -29,6 +31,7 @@ jobs: php-version: - "8.2" - "8.3" + - "8.4" steps: - name: Checkout diff --git a/lib/Doctrine/Cli.php b/lib/Doctrine/Cli.php index f6cd3dd4f..b366ef2d7 100644 --- a/lib/Doctrine/Cli.php +++ b/lib/Doctrine/Cli.php @@ -71,10 +71,10 @@ class Doctrine_Cli /** * __construct * - * @param array [$config=array()] - * @param object|null [$formatter=null] Doctrine_Cli_Formatter + * @param array $config + * @param Doctrine_Cli_Formatter|null $formatter */ - public function __construct(array $config = array(), Doctrine_Cli_Formatter $formatter = null) + public function __construct(array $config = array(), ?Doctrine_Cli_Formatter $formatter = null) { $this->setConfig($config); $this->setFormatter($formatter ? $formatter : new Doctrine_Cli_AnsiColorFormatter()); diff --git a/lib/Doctrine/Collection.php b/lib/Doctrine/Collection.php index 610d5e025..b290a60a6 100644 --- a/lib/Doctrine/Collection.php +++ b/lib/Doctrine/Collection.php @@ -923,10 +923,10 @@ protected function compareRecords($a, $b) * Saves all records of this collection and processes the * difference of the last snapshot and the current data * - * @param Doctrine_Connection $conn optional connection parameter + * @param Doctrine_Connection|null $conn optional connection parameter * @return Doctrine_Collection */ - public function save(Doctrine_Connection $conn = null, $processDiff = true) + public function save(?Doctrine_Connection $conn = null, $processDiff = true) { if ($conn == null) { $conn = $this->_table->getConnection(); @@ -958,10 +958,10 @@ public function save(Doctrine_Connection $conn = null, $processDiff = true) * Replaces all records of this collection and processes the * difference of the last snapshot and the current data * - * @param Doctrine_Connection $conn optional connection parameter + * @param Doctrine_Connection|null $conn optional connection parameter * @return Doctrine_Collection */ - public function replace(Doctrine_Connection $conn = null, $processDiff = true) + public function replace(?Doctrine_Connection $conn = null, $processDiff = true) { if ($conn == null) { $conn = $this->_table->getConnection(); @@ -994,7 +994,7 @@ public function replace(Doctrine_Connection $conn = null, $processDiff = true) * * @return Doctrine_Collection */ - public function delete(Doctrine_Connection $conn = null, $clearColl = true) + public function delete(?Doctrine_Connection $conn = null, $clearColl = true) { if ($conn == null) { $conn = $this->_table->getConnection(); diff --git a/lib/Doctrine/Connection.php b/lib/Doctrine/Connection.php index 73a7e5fa7..6bb9e7ce8 100644 --- a/lib/Doctrine/Connection.php +++ b/lib/Doctrine/Connection.php @@ -52,6 +52,8 @@ * @version $Revision$ * @author Konsta Vesterinen * @author Lukas Smith (MDB2 library) + * + * @property Doctrine_Export $export */ abstract class Doctrine_Connection extends Doctrine_Configurable implements Countable, IteratorAggregate, Serializable { @@ -241,26 +243,19 @@ public function isConnected() } /** - * getOptions - * * Get array of all options * - * @return void + * @return array */ - public function getOptions() + public function getOptions(): array { return $this->options; } /** - * getOption - * - * Retrieves option - * - * @param string $option - * @return void + * @return null|mixed */ - public function getOption($option) + public function getOption(string $option) { if (isset($this->options[$option])) { return $this->options[$option]; @@ -268,14 +263,11 @@ public function getOption($option) } /** - * setOption - * * Set option value * - * @param string $option - * @return void + * @return mixed */ - public function setOption($option, $value) + public function setOption(string $option, $value) { return $this->options[$option] = $value; } @@ -1545,8 +1537,8 @@ public function dropDatabase() * which is always guaranteed to exist. Mysql: 'mysql', PostgreSQL: 'postgres', etc. * This value is set in the Doctrine_Export_{DRIVER} classes if required * - * @param string $info - * @return void + * @param array $info + * @return Doctrine_Connection */ public function getTmpConnection($info) { @@ -1569,7 +1561,7 @@ public function getTmpConnection($info) $username = $this->getOption('username'); $password = $this->getOption('password'); - $conn = $this->getManager()->openConnection(array($pdoDsn, $username, $password), 'doctrine_tmp_connection', false); + $conn = $this->getManager()->openConnection([$pdoDsn, $username, $password], 'doctrine_tmp_connection', false); $conn->setOption('username', $username); $conn->setOption('password', $password); diff --git a/lib/Doctrine/Connection/Mssql.php b/lib/Doctrine/Connection/Mssql.php index ecce33f10..ac6a1e7e1 100644 --- a/lib/Doctrine/Connection/Mssql.php +++ b/lib/Doctrine/Connection/Mssql.php @@ -108,12 +108,12 @@ public function quoteIdentifier($identifier, $checkOption = false) * @param mixed $limit * @param mixed $offset * @param boolean $isSubQuery - * @param Doctrine_Query $queryOrigin + * @param Doctrine_Query|null $queryOrigin * @link https://github.com/doctrine/dbal/blob/master/lib/Doctrine/DBAL/Platforms/MsSqlPlatform.php#L607 * @link http://www.toosweettobesour.com/2010/09/16/doctrine-1-2-mssql-alternative-limitpaging/ * @return string */ - public function modifyLimitQuery($query, $limit = false, $offset = false, $isManip = false, $isSubQuery = false, Doctrine_Query $queryOrigin = null) + public function modifyLimitQuery($query, $limit = false, $offset = false, $isManip = false, $isSubQuery = false, ?Doctrine_Query $queryOrigin = null) { if ($limit === false || !($limit > 0)) { return $query; diff --git a/lib/Doctrine/Import/Schema.php b/lib/Doctrine/Import/Schema.php index 65ea075d5..25dc4869b 100644 --- a/lib/Doctrine/Import/Schema.php +++ b/lib/Doctrine/Import/Schema.php @@ -154,7 +154,7 @@ class Doctrine_Import_Schema /** * Returns an array of definition keys that can be applied at the global level. - * + * * @return array */ public static function getGlobalDefinitionKeys() @@ -165,7 +165,7 @@ public static function getGlobalDefinitionKeys() /** * getOption * - * @param string $name + * @param string $name * @return void */ public function getOption($name) @@ -188,8 +188,8 @@ public function getOptions() /** * setOption * - * @param string $name - * @param string $value + * @param string $name + * @param string $value * @return void */ public function setOption($name, $value) @@ -198,11 +198,11 @@ public function setOption($name, $value) $this->_options[$name] = $value; } } - + /** * setOptions * - * @param string $options + * @param array $options * @return void */ public function setOptions($options) @@ -230,7 +230,7 @@ public function buildSchema($schema, $format) $e = explode('.', $s); if (end($e) === $format) { $array = array_merge($array, $this->parseSchema($s, $format)); - } + } } else if (is_dir($s)) { $it = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($s), RecursiveIteratorIterator::LEAVES_ONLY); @@ -270,20 +270,20 @@ public function importSchema($schema, $format = 'yml', $directory = null, $model $builder = new Doctrine_Import_Builder(); $builder->setTargetPath($directory); $builder->setOptions($this->getOptions()); - + $array = $this->buildSchema($schema, $format); - if (count($array) == 0) { + if (count($array) == 0) { throw new Doctrine_Import_Exception( sprintf('No ' . $format . ' schema found in ' . implode(", ", $schema)) - ); + ); } foreach ($array as $name => $definition) { if ( ! empty($models) && !in_array($definition['className'], $models)) { continue; } - + $builder->buildRecord($definition); } } @@ -313,7 +313,7 @@ public function parseSchema($schema, $type) 'package' => null, 'inheritance' => array(), 'detect_relations' => false); - + $array = Doctrine_Parser::load($schema, $type); // Loop over and build up all the global values and remove them from the array @@ -431,14 +431,14 @@ public function parseSchema($schema, $type) $build[$className][$key] = isset($build[$className][$key]) ? $build[$className][$key]:$defaultValue; } } - + $build[$className]['className'] = $className; $build[$className]['tableName'] = $tableName; $build[$className]['columns'] = $columns; - + // Make sure that anything else that is specified in the schema makes it to the final array $build[$className] = Doctrine_Lib::arrayDeepMerge($table, $build[$className]); - + // We need to keep track of the className for the connection $build[$className]['connectionClassName'] = $build[$className]['className']; } @@ -448,11 +448,11 @@ public function parseSchema($schema, $type) /** * _processInheritance - * + * * Perform some processing on inheritance. * Sets the default type and sets some default values for certain types * - * @param string $array + * @param string $array * @return void */ protected function _processInheritance($array) @@ -472,9 +472,9 @@ protected function _processInheritance($array) if ($array[$className]['inheritance']['type'] == 'column_aggregation') { // Set the keyField to 'type' by default if ( ! isset($array[$className]['inheritance']['keyField'])) { - $array[$className]['inheritance']['keyField'] = 'type'; + $array[$className]['inheritance']['keyField'] = 'type'; } - + // Set the keyValue to the name of the child class if it does not exist if ( ! isset($array[$className]['inheritance']['keyValue'])) { $array[$className]['inheritance']['keyValue'] = $className; @@ -510,22 +510,22 @@ protected function _processInheritance($array) // Populate the parents subclasses if ($definition['inheritance']['type'] == 'column_aggregation') { - // Fix for 2015: loop through superclasses' inheritance to the base-superclass to - // make sure we collect all keyFields needed (and not only the first) - $inheritanceFields = array($definition['inheritance']['keyField'] => $definition['inheritance']['keyValue']); + // Fix for 2015: loop through superclasses' inheritance to the base-superclass to + // make sure we collect all keyFields needed (and not only the first) + $inheritanceFields = array($definition['inheritance']['keyField'] => $definition['inheritance']['keyValue']); - $superClass = $definition['inheritance']['extends']; - $multiInheritanceDef = $array[$superClass]; + $superClass = $definition['inheritance']['extends']; + $multiInheritanceDef = $array[$superClass]; - while (count($multiInheritanceDef['inheritance']) > 0 && array_key_exists('extends', $multiInheritanceDef['inheritance']) && $multiInheritanceDef['inheritance']['type'] == 'column_aggregation') { + while (count($multiInheritanceDef['inheritance']) > 0 && array_key_exists('extends', $multiInheritanceDef['inheritance']) && $multiInheritanceDef['inheritance']['type'] == 'column_aggregation') { $superClass = $multiInheritanceDef['inheritance']['extends']; - + // keep original keyField with it's keyValue - if ( ! isset($inheritanceFields[$multiInheritanceDef['inheritance']['keyField']])) { + if ( ! isset($inheritanceFields[$multiInheritanceDef['inheritance']['keyField']])) { $inheritanceFields[$multiInheritanceDef['inheritance']['keyField']] = $multiInheritanceDef['inheritance']['keyValue']; - } - $multiInheritanceDef = $array[$superClass]; - } + } + $multiInheritanceDef = $array[$superClass]; + } $array[$parent]['inheritance']['subclasses'][$definition['className']] = $inheritanceFields; } @@ -555,10 +555,10 @@ protected function _findBaseSuperClass($array, $class) * buildRelationships * * Loop through an array of schema information and build all the necessary relationship information - * Will attempt to auto complete relationships and simplify the amount of information required + * Will attempt to auto complete relationships and simplify the amount of information required * for defining a relationship * - * @param string $array + * @param string $array * @return void */ protected function _buildRelationships($array) @@ -591,10 +591,10 @@ protected function _buildRelationships($array) if ( ! isset($properties['relations'])) { continue; } - + $className = $properties['className']; $relations = $properties['relations']; - + foreach ($relations as $alias => $relation) { $class = isset($relation['class']) ? $relation['class']:$alias; if ( ! isset($array[$class])) { @@ -602,7 +602,7 @@ protected function _buildRelationships($array) } $relation['class'] = $class; $relation['alias'] = isset($relation['alias']) ? $relation['alias'] : $alias; - + // Attempt to guess the local and foreign if (isset($relation['refClass'])) { $relation['local'] = isset($relation['local']) ? $relation['local']:Doctrine_Inflector::tableize($name) . '_id'; @@ -611,11 +611,11 @@ protected function _buildRelationships($array) $relation['local'] = isset($relation['local']) ? $relation['local']:Doctrine_Inflector::tableize($relation['class']) . '_id'; $relation['foreign'] = isset($relation['foreign']) ? $relation['foreign']:'id'; } - + if (isset($relation['refClass'])) { $relation['type'] = 'many'; } - + if (isset($relation['type']) && $relation['type']) { $relation['type'] = $relation['type'] === 'one' ? Doctrine_Relation::ONE:Doctrine_Relation::MANY; } else { @@ -625,18 +625,18 @@ protected function _buildRelationships($array) if (isset($relation['foreignType']) && $relation['foreignType']) { $relation['foreignType'] = $relation['foreignType'] === 'one' ? Doctrine_Relation::ONE:Doctrine_Relation::MANY; } - + $relation['key'] = $this->_buildUniqueRelationKey($relation); - + $this->_validateSchemaElement('relation', array_keys($relation), $className . '->relation->' . $relation['alias']); - + $this->_relations[$className][$alias] = $relation; } } - + // Now we auto-complete opposite ends of relationships $this->_autoCompleteOppositeRelations(); - + // Make sure we do not have any duplicate relations $this->_fixDuplicateRelations(); @@ -644,7 +644,7 @@ protected function _buildRelationships($array) foreach ($this->_relations as $className => $relations) { $array[$className]['relations'] = $relations; } - + return $array; } @@ -663,22 +663,22 @@ protected function _autoCompleteOppositeRelations() if ((isset($relation['equal']) && $relation['equal']) || (isset($relation['autoComplete']) && $relation['autoComplete'] === false)) { continue; } - + $newRelation = array(); $newRelation['foreign'] = $relation['local']; $newRelation['local'] = $relation['foreign']; $newRelation['class'] = isset($relation['foreignClass']) ? $relation['foreignClass']:$className; $newRelation['alias'] = isset($relation['foreignAlias']) ? $relation['foreignAlias']:$className; $newRelation['foreignAlias'] = $alias; - + // this is so that we know that this relation was autogenerated and // that we do not need to include it if it is explicitly declared in the schema by the users. - $newRelation['autogenerated'] = true; - + $newRelation['autogenerated'] = true; + if (isset($relation['refClass'])) { $newRelation['refClass'] = $relation['refClass']; $newRelation['type'] = isset($relation['foreignType']) ? $relation['foreignType']:$relation['type']; - } else { + } else { if (isset($relation['foreignType'])) { $newRelation['type'] = $relation['foreignType']; } else { @@ -720,7 +720,7 @@ protected function _fixDuplicateRelations() } } } - + $this->_relations[$className] = $uniqueRelations; } } @@ -731,7 +731,7 @@ protected function _fixDuplicateRelations() * Build a unique key to identify a relationship by * Md5 hash of all the relationship parameters * - * @param string $relation + * @param string $relation * @return void */ protected function _buildUniqueRelationKey($relation) @@ -742,8 +742,8 @@ protected function _buildUniqueRelationKey($relation) /** * _validateSchemaElement * - * @param string $name - * @param string $value + * @param string $name + * @param string $value * @return void */ protected function _validateSchemaElement($name, $element, $path) @@ -768,4 +768,4 @@ protected function _validateSchemaElement($name, $element, $path) } } } -} \ No newline at end of file +} diff --git a/lib/Doctrine/Manager.php b/lib/Doctrine/Manager.php index a2b08944d..9c07f8d3e 100644 --- a/lib/Doctrine/Manager.php +++ b/lib/Doctrine/Manager.php @@ -274,7 +274,7 @@ public static function connection($adapter = null, $name = null) /** * Opens a new connection and saves it to Doctrine_Manager->connections * - * @param PDO|Doctrine_Adapter_Interface $adapter database driver + * @param array|string|PDO|Doctrine_Adapter_Interface $adapter database driver * @param string $name name of the connection, if empty numeric key is used * @throws Doctrine_Manager_Exception if trying to bind a connection with an existing name * @throws Doctrine_Manager_Exception if trying to open connection for unknown driver @@ -292,17 +292,17 @@ public function openConnection($adapter, $name = null, $setCurrent = true) if ( ! isset($adapter[0])) { throw new Doctrine_Manager_Exception('Empty data source name given.'); } - $e = explode(':', $adapter[0]); + $schema = explode(':', $adapter[0]); - if ($e[0] == 'uri') { - $e[0] = 'odbc'; + if ($schema[0] === 'uri') { + $schema[0] = 'odbc'; } $parts['dsn'] = $adapter[0]; - $parts['scheme'] = $e[0]; - $parts['user'] = (isset($adapter[1])) ? $adapter[1] : null; - $parts['pass'] = (isset($adapter[2])) ? $adapter[2] : null; - $driverName = $e[0]; + $parts['scheme'] = $schema[0]; + $parts['user'] = $adapter[1] ?? null; + $parts['pass'] = $adapter[2] ?? null; + $driverName = $schema[0]; $adapter = $parts; } else { $parts = $this->parseDsn($adapter); @@ -329,7 +329,7 @@ public function openConnection($adapter, $name = null, $setCurrent = true) return $this->_connections[$name]; } } else { - $name = $this->_index; + $name = (string) $this->_index; $this->_index++; } @@ -352,11 +352,23 @@ public function openConnection($adapter, $name = null, $setCurrent = true) /** * Parse a pdo style dsn in to an array of parts * - * @param array $dsn An array of dsn information - * @return array The array parsed + * @param string $dsn An array of dsn information + * @return array{ + * dsn: string, + * scheme: string, + * host: ?string, + * user: ?string, + * pass: ?string, + * password: ?string, + * port: ?string, + * path: ?string, + * query: ?string, + * fragment: ?string, + * unix_socket: ?string, + * } * @todo package:dbal */ - public function parsePdoDsn($dsn) + public function parsePdoDsn($dsn): array { $parts = array(); @@ -401,7 +413,7 @@ public function parsePdoDsn($dsn) * @param string $dsn * @return array $parts */ - protected function _buildDsnPartsArray($dsn) + protected function _buildDsnPartsArray(string $dsn) { // fix sqlite dsn so that it will parse correctly $dsn = str_replace("////", "/", $dsn); @@ -437,7 +449,7 @@ protected function _buildDsnPartsArray($dsn) * @return array Parsed contents of DSN * @todo package:dbal */ - public function parseDsn($dsn) + public function parseDsn(string $dsn) { $parts = $this->_buildDsnPartsArray($dsn); diff --git a/lib/Doctrine/Migration.php b/lib/Doctrine/Migration.php index 0208ce540..e05eed9fc 100644 --- a/lib/Doctrine/Migration.php +++ b/lib/Doctrine/Migration.php @@ -187,7 +187,7 @@ public function loadMigrationClass($name, $path = null) } if ($class === false) { - return false; + return; } if (empty($this->_migrationClasses)) { @@ -305,17 +305,15 @@ public function getNextMigrationClassVersion() * migrate to. It will automatically know whether you are migrating up or down * based on the current version of the database. * - * @param integer $to Version to migrate to - * @param boolean $dryRun Whether or not to run the migrate process as a dry run - * @return integer $to Version number migrated to + * @param int $to Version to migrate to + * @param bool $dryRun Whether or not to run the migrate process as a dry run + * @return int|false Returns the migration version reached by the migration, false otherwise * @throws Doctrine_Exception */ public function migrate($to = null, $dryRun = false) { $this->clearErrors(); - $this->_createMigrationTable(); - $this->_connection->beginTransaction(); try { @@ -335,24 +333,22 @@ public function migrate($to = null, $dryRun = false) if ($dryRun) { return false; - } else { - $this->_throwErrorsException(); } - } else { - if ($dryRun) { - $this->_connection->rollback(); - if ($this->hasErrors()) { - return false; - } else { - return $to; - } - } else { - $this->_connection->commit(); - $this->setCurrentVersion($to); - return $to; + $this->_throwErrorsException(); + } + + if ($dryRun) { + $this->_connection->rollback(); + if ($this->hasErrors()) { + return false; } + return $to; } - return false; + + $this->_connection->commit(); + $this->setCurrentVersion($to); + + return $to; } /** @@ -435,12 +431,12 @@ public function getMigrationClass($num) } /** - * Throw an exception with all the errors trigged during the migration + * Throw an exception with all the errors triggered during the migration * - * @return void - * @throws Doctrine_Migration_Exception $e + * @return never-returns + * @throws Doctrine_Migration_Exception */ - protected function _throwErrorsException() + protected function _throwErrorsException(): void { $messages = array(); $num = 0; diff --git a/lib/Doctrine/Parser.php b/lib/Doctrine/Parser.php index d9c8c124d..8d7571e98 100644 --- a/lib/Doctrine/Parser.php +++ b/lib/Doctrine/Parser.php @@ -62,7 +62,7 @@ abstract public function dumpData($array, $path = null, $charset = null); * Get instance of the specified parser * * @param string $type - * @return void + * @return Doctrine_Parser * @author Jonathan H. Wage */ static public function getParser($type) @@ -94,7 +94,7 @@ static public function load($path, $type = 'xml', $charset = 'UTF-8') * * Interface for pulling and dumping data to a file * - * @param string $array + * @param array $array * @param string $path * @param string $type * @param string $charset The charset of the data being dumped @@ -115,7 +115,7 @@ static public function dump($array, $type = 'xml', $path = null, $charset = null * Either should allow php code in it. * * @param string $path - * @return void + * @return false|string */ public function doLoad($path) { diff --git a/lib/Doctrine/Query.php b/lib/Doctrine/Query.php index 2724cea31..683fb3504 100644 --- a/lib/Doctrine/Query.php +++ b/lib/Doctrine/Query.php @@ -187,10 +187,7 @@ public static function create($conn = null, $class = null) return new $class($conn); } - /** - * Clears all the sql parts. - */ - protected function clear() + protected function clear(): void { $this->_preQueried = false; $this->_pendingJoinConditions = array(); @@ -2214,9 +2211,9 @@ public function query($query, $params = array(), $hydrationMode = null) /** * Copies a Doctrine_Query object. * - * @return Doctrine_Query Copy of the Doctrine_Query instance. + * @return Doctrine_Query|null Copy of the Doctrine_Query instance. */ - public function copy(Doctrine_Query $query = null) + public function copy(?Doctrine_Query $query = null) { if ( ! $query) { $query = $this; diff --git a/lib/Doctrine/Query/Abstract.php b/lib/Doctrine/Query/Abstract.php index 821de85ad..b0873442b 100644 --- a/lib/Doctrine/Query/Abstract.php +++ b/lib/Doctrine/Query/Abstract.php @@ -334,14 +334,15 @@ abstract class Doctrine_Query_Abstract /** * Constructor. * - * @param Doctrine_Connection $connection The connection object the query will use. - * @param Doctrine_Hydrator_Abstract $hydrator The hydrator that will be used for generating result sets. + * @param Doctrine_Connection|null $connection The connection object the query will use. + * @param Doctrine_Hydrator_Abstract|null $hydrator The hydrator that will be used for generating result sets. * * @throws Doctrine_Connection_Exception */ - public function __construct(Doctrine_Connection $connection = null, - Doctrine_Hydrator_Abstract $hydrator = null) - { + public function __construct( + ?Doctrine_Connection $connection = null, + ?Doctrine_Hydrator_Abstract $hydrator = null + ) { if ($connection === null) { $connection = Doctrine_Manager::getInstance()->getCurrentConnection(); } else { @@ -1997,10 +1998,8 @@ public function offset($offset) /** * Resets all the sql parts. - * - * @return void */ - protected function clear() + protected function clear(): void { $this->_sqlParts = array( 'select' => array(), diff --git a/lib/Doctrine/Query/Part.php b/lib/Doctrine/Query/Part.php index 629ed2ad4..dc5a35759 100644 --- a/lib/Doctrine/Query/Part.php +++ b/lib/Doctrine/Query/Part.php @@ -42,7 +42,7 @@ abstract class Doctrine_Query_Part /** * @param Doctrine_Query $query the query object associated with this parser */ - public function __construct($query, Doctrine_Query_Tokenizer $tokenizer = null) + public function __construct($query, ?Doctrine_Query_Tokenizer $tokenizer = null) { $this->query = $query; diff --git a/lib/Doctrine/RawSql.php b/lib/Doctrine/RawSql.php index 82810d38d..e35f3ad93 100644 --- a/lib/Doctrine/RawSql.php +++ b/lib/Doctrine/RawSql.php @@ -46,10 +46,10 @@ class Doctrine_RawSql extends Doctrine_Query_Abstract /** * Constructor. * - * @param Doctrine_Connection The connection object the query will use. - * @param Doctrine_Hydrator_Abstract The hydrator that will be used for generating result sets. + * @param Doctrine_Connection|null $connection The connection object the query will use. + * @param Doctrine_Hydrator_Abstract|null $hydrator The hydrator that will be used for generating result sets. */ - function __construct(Doctrine_Connection $connection = null, Doctrine_Hydrator_Abstract $hydrator = null) { + function __construct(?Doctrine_Connection $connection = null, ?Doctrine_Hydrator_Abstract $hydrator = null) { parent::__construct($connection, $hydrator); // Fix #1472. It's alid to disable QueryCache since there's no DQL for RawSql. @@ -57,7 +57,7 @@ function __construct(Doctrine_Connection $connection = null, Doctrine_Hydrator_A $this->useQueryCache(false); } - protected function clear() + protected function clear(): void { $this->_preQueried = false; $this->_pendingJoinConditions = array(); @@ -108,9 +108,9 @@ protected function _addDqlQueryPart($queryPartName, $queryPart, $append = false) /** * Add select parts to fields. * - * @param $queryPart sting The name of the querypart + * @param $queryPart string The name of the querypart */ - private function _parseSelectFields($queryPart) + private function _parseSelectFields(string $queryPart): void { preg_match_all('/{([^}{]*)}/U', $queryPart, $m); $this->fields = $m[1]; diff --git a/lib/Doctrine/Record.php b/lib/Doctrine/Record.php index ba1cbbc96..685ea6cfc 100644 --- a/lib/Doctrine/Record.php +++ b/lib/Doctrine/Record.php @@ -1729,7 +1729,7 @@ public function resetPendingUnlinks() * @throws Exception if record is not valid and validation is active * @return void */ - public function save(Doctrine_Connection $conn = null) + public function save(?Doctrine_Connection $conn = null) { if ($conn === null) { $conn = $this->_table->getConnection(); @@ -1746,7 +1746,7 @@ public function save(Doctrine_Connection $conn = null) * @param Doctrine_Connection $conn optional connection parameter * @return TRUE if the record was saved sucessfully without errors, FALSE otherwise. */ - public function trySave(Doctrine_Connection $conn = null) { + public function trySave(?Doctrine_Connection $conn = null) { try { $this->save($conn); return true; @@ -1772,7 +1772,7 @@ public function trySave(Doctrine_Connection $conn = null) { * @throws Doctrine_Connection_Exception if something fails at database level * @return integer number of rows affected */ - public function replace(Doctrine_Connection $conn = null) + public function replace(?Doctrine_Connection $conn = null) { if ($conn === null) { $conn = $this->_table->getConnection(); @@ -1985,7 +1985,7 @@ public function merge($data, $deep = true) * @link http://www.doctrine-project.org/documentation/manual/1_1/en/working-with-models * @param string $array array of data, see link for documentation * @param bool $deep whether or not to act on relations - * @return void + * @return Doctrine_Record */ public function fromArray(array $array, $deep = true) { @@ -2197,7 +2197,7 @@ public function getIterator() * * @return boolean true if successful */ - public function delete(Doctrine_Connection $conn = null) + public function delete(?Doctrine_Connection $conn = null) { if ($conn == null) { $conn = $this->_table->getConnection(); diff --git a/lib/Doctrine/Record/Filter.php b/lib/Doctrine/Record/Filter.php index b122ff723..24123b6d4 100644 --- a/lib/Doctrine/Record/Filter.php +++ b/lib/Doctrine/Record/Filter.php @@ -33,6 +33,9 @@ */ abstract class Doctrine_Record_Filter { + /** + * @var Doctrine_Table|null + */ protected $_table; public function setTable(Doctrine_Table $table) @@ -40,6 +43,9 @@ public function setTable(Doctrine_Table $table) $this->_table = $table; } + /** + * @return Doctrine_Table|null + */ public function getTable() { return $this->_table; @@ -56,7 +62,7 @@ public function init() * * @return Doctrine_Record the given record * - * @thrown Doctrine_Exception when this way is not available + * @throws Doctrine_Exception when this way is not available */ abstract public function filterSet(Doctrine_Record $record, $propertyOrRelation, $value); @@ -67,7 +73,7 @@ abstract public function filterSet(Doctrine_Record $record, $propertyOrRelation, * * @return mixed * - * @thrown Doctrine_Exception when this way is not available + * @throws Doctrine_Exception when this way is not available */ abstract public function filterGet(Doctrine_Record $record, $propertyOrRelation); } diff --git a/lib/Doctrine/Record/Filter/Compound.php b/lib/Doctrine/Record/Filter/Compound.php index 0fe769bc0..f4e212af8 100644 --- a/lib/Doctrine/Record/Filter/Compound.php +++ b/lib/Doctrine/Record/Filter/Compound.php @@ -57,13 +57,9 @@ public function init() } /** - * Provides a way for setting property or relation value to the given record. + * @return Doctrine_Record * - * @param string $propertyOrRelation - * - * @return Doctrine_Record the given record - * - * @thrown Doctrine_Record_UnknownPropertyException when this way is not available + * @throws Doctrine_Record_UnknownPropertyException */ public function filterSet(Doctrine_Record $record, $propertyOrRelation, $value) { @@ -90,13 +86,9 @@ public function filterSet(Doctrine_Record $record, $propertyOrRelation, $value) } /** - * Provides a way for getting property or relation value from the given record. - * - * @param string $propertyOrRelation - * * @return mixed * - * @thrown Doctrine_Record_UnknownPropertyException when this way is not available + * @throws Doctrine_Record_UnknownPropertyException */ public function filterGet(Doctrine_Record $record, $propertyOrRelation) { @@ -107,6 +99,7 @@ public function filterGet(Doctrine_Record $record, $propertyOrRelation) if ( ! $record->exists()) { if (isset($record[$alias][$propertyOrRelation])) { + return $record[$alias][$propertyOrRelation]; } } else { if (isset($record[$alias][$propertyOrRelation])) { diff --git a/lib/Doctrine/Record/Filter/Standard.php b/lib/Doctrine/Record/Filter/Standard.php index f2a665358..54e41cdec 100644 --- a/lib/Doctrine/Record/Filter/Standard.php +++ b/lib/Doctrine/Record/Filter/Standard.php @@ -33,21 +33,11 @@ */ class Doctrine_Record_Filter_Standard extends Doctrine_Record_Filter { - /** - * @param string $propertyOrRelation - * - * @thrown Doctrine_Record_UnknownPropertyException - */ public function filterSet(Doctrine_Record $record, $propertyOrRelation, $value) { throw new Doctrine_Record_UnknownPropertyException(sprintf('Unknown record property / related component "%s" on "%s"', $propertyOrRelation, get_class($record))); } - /** - * @param string $propertyOrRelation - * - * @thrown Doctrine_Record_UnknownPropertyException - */ public function filterGet(Doctrine_Record $record, $propertyOrRelation) { throw new Doctrine_Record_UnknownPropertyException(sprintf('Unknown record property / related component "%s" on "%s"', $propertyOrRelation, get_class($record))); diff --git a/lib/Doctrine/Table.php b/lib/Doctrine/Table.php index eb9454647..0e08e5a4e 100644 --- a/lib/Doctrine/Table.php +++ b/lib/Doctrine/Table.php @@ -1179,7 +1179,7 @@ public function getColumnName($fieldName) return $this->_columnNames[$fieldName]; } - if (is_null($fieldName)) { + if (null === $fieldName) { return ''; } @@ -2066,10 +2066,10 @@ public function enumIndex($fieldName, $value) * * @param string $fieldName * @param string $value - * @param Doctrine_Record $record record to consider; if it does not exists, it is created + * @param Doctrine_Record|null $record record to consider; if it does not exist, it is created * @return Doctrine_Validator_ErrorStack $errorStack */ - public function validateField($fieldName, $value, Doctrine_Record $record = null) + public function validateField($fieldName, $value, ?Doctrine_Record $record = null) { if ($record instanceof Doctrine_Record) { $errorStack = $record->getErrorStack(); @@ -2222,7 +2222,7 @@ public function removeColumn($fieldName) * * @return array numeric array */ - public function getColumnNames(array $fieldNames = null) + public function getColumnNames(?array $fieldNames = null) { if ($fieldNames === null) { return array_keys($this->_columns); diff --git a/lib/Doctrine/Tree/Interface.php b/lib/Doctrine/Tree/Interface.php index 4a88116c4..e7f5f688c 100644 --- a/lib/Doctrine/Tree/Interface.php +++ b/lib/Doctrine/Tree/Interface.php @@ -35,9 +35,9 @@ interface Doctrine_Tree_Interface { /** * creates root node from given record or from a new record * - * @param Doctrine_Record $record instance of Doctrine_Record + * @param Doctrine_Record|null $record instance of Doctrine_Record */ - public function createRoot(Doctrine_Record $record = null); + public function createRoot(?Doctrine_Record $record = null); /** * returns root node diff --git a/lib/Doctrine/Tree/NestedSet.php b/lib/Doctrine/Tree/NestedSet.php index 53ba87269..b44371b61 100644 --- a/lib/Doctrine/Tree/NestedSet.php +++ b/lib/Doctrine/Tree/NestedSet.php @@ -82,9 +82,9 @@ public function setTableDefinition() * the records id will be assigned to the root id. You must use numeric columns for the id * and root id columns. * - * @param object $record instance of Doctrine_Record + * @param Doctrine_Record|null $record instance of Doctrine_Record */ - public function createRoot(Doctrine_Record $record = null) + public function createRoot(?Doctrine_Record $record = null) { if ($this->getAttribute('hasManyRoots')) { if ( ! $record || ( ! $record->exists() && ! $record->getNode()->getRootValue()) diff --git a/lib/Doctrine/Validator.php b/lib/Doctrine/Validator.php index bab8fe82c..75e63dbbb 100644 --- a/lib/Doctrine/Validator.php +++ b/lib/Doctrine/Validator.php @@ -89,7 +89,7 @@ public function validateRecord(Doctrine_Record $record) */ public static function validateLength($value, $type, $maximumLength) { - if ($maximumLength === null ) { + if ($maximumLength === null || $value === null) { return true; } if ($type == 'timestamp' || $type == 'integer' || $type == 'enum') { diff --git a/tests/BaseTestCase.php b/tests/BaseTestCase.php index 5a865cab2..ae65c91f3 100644 --- a/tests/BaseTestCase.php +++ b/tests/BaseTestCase.php @@ -45,7 +45,7 @@ public function testAggressiveModelLoading() // Make sure it does not include the base classes $this->assertTrue( ! isset($models['BaseAggressiveModelLoadingUser'])); - + $filteredModels = Doctrine_Core::filterInvalidModels($models); // Make sure filterInvalidModels filters out base abstract classes @@ -85,7 +85,7 @@ public function testModelLoadingCacheInformation() $this->assertTrue(in_array('AggressiveModelLoadingUser', $models)); $this->assertTrue(in_array('ConservativeModelLoadingProfile', $models)); $this->assertTrue(in_array('ConservativeModelLoadingContact', $models)); - + $modelFiles = Doctrine_Core::getLoadedModelFiles(); $this->assertTrue(file_exists($modelFiles['ConservativeModelLoadingUser'])); $this->assertTrue(file_exists($modelFiles['ConservativeModelLoadingProfile'])); diff --git a/tests/ConnectionTestCase.php b/tests/ConnectionTestCase.php index 70d3f28be..9a4b0072a 100644 --- a/tests/ConnectionTestCase.php +++ b/tests/ConnectionTestCase.php @@ -30,10 +30,10 @@ * @since 1.0 * @version $Revision$ */ -class Doctrine_Connection_TestCase extends Doctrine_UnitTestCase +class Doctrine_Connection_TestCase extends Doctrine_UnitTestCase { - public function testUnknownModule() + public function testUnknownModule() { try { $this->connection->unknown; @@ -43,7 +43,7 @@ public function testUnknownModule() } } - public function testGetModule() + public function testGetModule() { $this->assertTrue($this->connection->unitOfWork instanceof Doctrine_Connection_UnitOfWork); //$this->assertTrue($this->connection->dataDict instanceof Doctrine_DataDict); @@ -52,7 +52,7 @@ public function testGetModule() $this->assertTrue($this->connection->export instanceof Doctrine_Export); } - public function testFetchAll() + public function testFetchAll() { $this->conn->exec('DROP TABLE entity'); $this->conn->exec('CREATE TABLE entity (id INT, name TEXT)'); @@ -80,16 +80,16 @@ public function testFetchAll() public function testFetchOne() { $c = $this->conn->fetchOne('SELECT COUNT(1) FROM entity'); - + $this->assertEqual($c, 2); - + $c = $this->conn->fetchOne('SELECT COUNT(1) FROM entity WHERE id = ?', array(1)); - + $this->assertEqual($c, 1); } - - public function testFetchColumn() + + public function testFetchColumn() { $a = $this->conn->fetchColumn('SELECT * FROM entity'); @@ -105,7 +105,7 @@ public function testFetchColumn() )); } - public function testFetchArray() + public function testFetchArray() { $a = $this->conn->fetchArray('SELECT * FROM entity'); @@ -122,7 +122,7 @@ public function testFetchArray() )); } - public function testFetchRow() + public function testFetchRow() { $c = $this->conn->fetchRow('SELECT * FROM entity'); @@ -132,24 +132,24 @@ public function testFetchRow() )); $c = $this->conn->fetchRow('SELECT * FROM entity WHERE id = ?', array(1)); - + $this->assertEqual($c, array ( 'id' => '1', 'name' => 'zYne', )); } - public function testFetchPairs() + public function testFetchPairs() { $this->conn->exec('DROP TABLE entity'); } - public function testGetManager() + public function testGetManager() { $this->assertTrue($this->connection->getManager() === $this->manager); } - public function testDeleteOnTransientRecordIsIgnored() + public function testDeleteOnTransientRecordIsIgnored() { $user = $this->connection->create('User'); try { @@ -159,7 +159,7 @@ public function testDeleteOnTransientRecordIsIgnored() } } - public function testGetTable() + public function testGetTable() { $table = $this->connection->getTable('Group'); $this->assertTrue($table instanceof Doctrine_Table); @@ -176,23 +176,23 @@ public function testGetTable() } - public function testCreate() + public function testCreate() { $email = $this->connection->create('Email'); $this->assertTrue($email instanceof Email); } - public function testGetDbh() + public function testGetDbh() { $this->assertTrue($this->connection->getDbh() instanceof PDO); } - public function testCount() + public function testCount() { $this->assertTrue(is_integer(count($this->connection))); } - public function testGetIterator() + public function testGetIterator() { $this->assertTrue($this->connection->getIterator() instanceof ArrayIterator); } @@ -203,12 +203,12 @@ public function testGetState() $this->assertEqual(Doctrine_Lib::getConnectionStateAsString($this->connection->transaction->getState()), 'open'); } - public function testGetTables() + public function testGetTables() { $this->assertTrue(is_array($this->connection->getTables())); } - public function testRollback() + public function testRollback() { $this->connection->beginTransaction(); $this->assertEqual($this->connection->transaction->getTransactionLevel(),1); diff --git a/tests/Data/ExportTestCase.php b/tests/Data/ExportTestCase.php index 3c176c3d0..03d6e5fa2 100644 --- a/tests/Data/ExportTestCase.php +++ b/tests/Data/ExportTestCase.php @@ -30,7 +30,7 @@ * @since 1.0 * @version $Revision$ */ -class Doctrine_Data_Export_TestCase extends Doctrine_UnitTestCase +class Doctrine_Data_Export_TestCase extends Doctrine_UnitTestCase { public function prepareTables() { @@ -93,4 +93,4 @@ public function setUp() { $this->actAs('I18n', array('fields' => array('name', 'title'))); } -} \ No newline at end of file +} diff --git a/tests/Data/ImportTestCase.php b/tests/Data/ImportTestCase.php index fa07a25cd..76e67dccb 100644 --- a/tests/Data/ImportTestCase.php +++ b/tests/Data/ImportTestCase.php @@ -30,7 +30,7 @@ * @since 1.0 * @version $Revision$ */ -class Doctrine_Data_Import_TestCase extends Doctrine_UnitTestCase +class Doctrine_Data_Import_TestCase extends Doctrine_UnitTestCase { public function prepareTables() { @@ -43,17 +43,17 @@ public function prepareTables() $this->tables[] = 'I18nNumberLang'; parent::prepareTables(); } - + public function testInlineMany() { $yml = <<assertEqual($i[4]['rgt'], 3); $this->assertEqual($i[4]['level'], 1); $this->assertEqual($i[4]['root_id'], $i[3]['root_id']); - + $this->assertEqual($i[5]['name'], 'Item 2.2'); $this->assertEqual($i[5]['lft'], 4); $this->assertEqual($i[5]['rgt'], 11); @@ -367,7 +367,7 @@ public function testMany2ManyManualDataFixtures() unlink('test.yml'); } - + public function testInvalidElementThrowsException() { self::prepareTables(); @@ -609,4 +609,4 @@ public function setUp() { $this->actAs('I18n', array('fields' => array('name', 'title'))); } -} \ No newline at end of file +} diff --git a/tests/DoctrineTest/Doctrine_UnitTestCase.php b/tests/DoctrineTest/Doctrine_UnitTestCase.php index a1f0fb2f7..c158d5da2 100644 --- a/tests/DoctrineTest/Doctrine_UnitTestCase.php +++ b/tests/DoctrineTest/Doctrine_UnitTestCase.php @@ -48,6 +48,7 @@ class Doctrine_UnitTestCase extends UnitTestCase protected $generic = false; protected $conn; protected $adapter; + /** @var Doctrine_Export */ protected $export; protected $expr; protected $dataDict; @@ -215,6 +216,7 @@ public function init() } } } + public function prepareTables() { foreach($this->tables as $name) { $name = ucwords($name); @@ -229,6 +231,7 @@ public function prepareTables() { $this->conn->export->exportClasses($this->tables); $this->objTable = $this->connection->getTable('User'); } + public function prepareData() { $groups = new Doctrine_Collection($this->connection->getTable('Group')); diff --git a/tests/DoctrineTest/GroupTest.php b/tests/DoctrineTest/GroupTest.php index b17f5e37e..c76147471 100644 --- a/tests/DoctrineTest/GroupTest.php +++ b/tests/DoctrineTest/GroupTest.php @@ -52,7 +52,7 @@ public function shouldBeRun($testCase, $filter) } return true; } - public function run(DoctrineTest_Reporter $reporter = null, $filter = null) + public function run(?DoctrineTest_Reporter $reporter = null, $filter = null) { set_time_limit(900); @@ -109,4 +109,4 @@ public function getTestCases() { return $this->_testCases; } -} \ No newline at end of file +} diff --git a/tests/DoctrineTest/UnitTestCase.php b/tests/DoctrineTest/UnitTestCase.php index f1aca2fe5..0865b40f7 100644 --- a/tests/DoctrineTest/UnitTestCase.php +++ b/tests/DoctrineTest/UnitTestCase.php @@ -2,9 +2,7 @@ class UnitTestCase { protected $_passed = 0; - protected $_failed = 0; - protected $_messages = array(); protected static $_passesAndFails = array('passes' => array(), 'fails' => array()); @@ -115,7 +113,7 @@ public function assertNotNull($expr) } } - public function pass() + public function pass() { $class = get_class($this); if ( ! isset(self::$_passesAndFails['fails'][$class])) { @@ -126,7 +124,7 @@ public function pass() public function fail($message = "") { - $this->_fail($message); + $this->_fail($message); } public function _fail($message = "") @@ -157,7 +155,7 @@ public function _fail($message = "") self::$_passesAndFails['fails'][$class] = $class; } - public function run(DoctrineTest_Reporter $reporter = null, $filter = null) + public function run(?DoctrineTest_Reporter $reporter = null, $filter = null) { foreach (get_class_methods($this) as $method) { if ($this->isTestMethod($method)) { @@ -166,7 +164,7 @@ public function run(DoctrineTest_Reporter $reporter = null, $filter = null) } } - public function getMessages() + public function getMessages() { return $this->_messages; } diff --git a/tests/DriverTestCase.php b/tests/DriverTestCase.php index c247eed3c..1369d39c6 100644 --- a/tests/DriverTestCase.php +++ b/tests/DriverTestCase.php @@ -1,29 +1,29 @@ name = $name; } - public function getName() + public function getName() { return $this->name; } - public function pop() + public function pop() { return array_pop($this->queries); } - public function forceException($name, $message = '', $code = 0) + public function forceException($name, $message = '', $code = 0) { $this->exception = array($name, $message, $code); } @@ -102,7 +102,7 @@ public function lastInsertId() } public function beginTransaction() - { + { $this->queries[] = 'BEGIN TRANSACTION'; } @@ -111,8 +111,8 @@ public function commit() $this->queries[] = 'COMMIT'; } - public function rollBack() - { + public function rollBack() + { $this->queries[] = 'ROLLBACK'; } @@ -142,7 +142,7 @@ public function setAttribute($attribute, $value) class AdapterStatementMock { private $mock; - + private $query; public function __construct(AdapterMock $mock, $query) @@ -180,6 +180,7 @@ class Doctrine_Driver_UnitTestCase extends UnitTestCase protected $manager; protected $conn; protected $adapter; + /** @var Doctrine_Export */ protected $export; protected $dataDict; protected $transaction; @@ -224,12 +225,12 @@ public function init() if ($this->adapter->getName() == 'oci') $name = 'Oracle'; - + $tx = 'Doctrine_Transaction_' . ucwords($name); $dataDict = 'Doctrine_DataDict_' . ucwords($name); - + $exc = 'Doctrine_Connection_' . ucwords($name) . '_Exception'; - + $this->exc = new $exc(); if (class_exists($tx)) $this->transaction = new $tx($this->conn); diff --git a/tests/Export/SchemaTestCase.php b/tests/Export/SchemaTestCase.php index b1f0d2943..fabb76a0a 100644 --- a/tests/Export/SchemaTestCase.php +++ b/tests/Export/SchemaTestCase.php @@ -30,7 +30,7 @@ * @since 1.0 * @version $Revision$ */ -class Doctrine_Export_Schema_TestCase extends Doctrine_UnitTestCase +class Doctrine_Export_Schema_TestCase extends Doctrine_UnitTestCase { public $tables = array('Entity', 'EntityReference', diff --git a/tests/Export/SqliteTestCase.php b/tests/Export/SqliteTestCase.php index 377696153..0227f02aa 100644 --- a/tests/Export/SqliteTestCase.php +++ b/tests/Export/SqliteTestCase.php @@ -30,7 +30,7 @@ * @since 1.0 * @version $Revision$ */ -class Doctrine_Export_Sqlite_TestCase extends Doctrine_UnitTestCase +class Doctrine_Export_Sqlite_TestCase extends Doctrine_UnitTestCase { public function testCreateDatabaseDoesNotExecuteSqlAndCreatesSqliteFile() { @@ -44,17 +44,17 @@ public function testDropDatabaseDoesNotExecuteSqlAndDeletesSqliteFile() $this->assertFalse(file_exists('sqlite.db')); } - public function testCreateTableSupportsAutoincPks() + public function testCreateTableSupportsAutoincPks() { $name = 'mytable'; - + $fields = array('id' => array('type' => 'integer', 'unsigned' => 1, 'autoincrement' => true)); $this->export->createTable($name, $fields); $this->assertEqual($this->adapter->pop(), 'CREATE TABLE mytable (id INTEGER PRIMARY KEY AUTOINCREMENT)'); } - public function testCreateTableSupportsDefaultAttribute() + public function testCreateTableSupportsDefaultAttribute() { $name = 'mytable'; $fields = array('name' => array('type' => 'char', 'length' => 10, 'default' => 'def'), @@ -66,15 +66,15 @@ public function testCreateTableSupportsDefaultAttribute() $this->assertEqual($this->adapter->pop(), 'CREATE TABLE mytable (name CHAR(10) DEFAULT \'def\', type INTEGER DEFAULT 12, PRIMARY KEY(name, type))'); } - public function testCreateTableSupportsMultiplePks() + public function testCreateTableSupportsMultiplePks() { $name = 'mytable'; $fields = array('name' => array('type' => 'char', 'length' => 10), 'type' => array('type' => 'integer', 'length' => 3)); - + $options = array('primary' => array('name', 'type')); $this->export->createTable($name, $fields, $options); - + $this->assertEqual($this->adapter->pop(), 'CREATE TABLE mytable (name CHAR(10), type INTEGER, PRIMARY KEY(name, type))'); } public function testCreateTableSupportsIndexes() @@ -89,7 +89,7 @@ public function testCreateTableSupportsIndexes() $this->export->createTable('sometable', $fields, $options); - //this was the old line, but it looks like the table is created first + //this was the old line, but it looks like the table is created first //and then the index so i replaced it with the ones below //$this->assertEqual($var, 'CREATE TABLE sometable (id INTEGER PRIMARY KEY AUTOINCREMENT, name VARCHAR(4), INDEX myindex (id, name))'); @@ -111,7 +111,7 @@ public function testIdentifierQuoting() $this->export->createTable('sometable', $fields, $options); - //this was the old line, but it looks like the table is created first + //this was the old line, but it looks like the table is created first //and then the index so i replaced it with the ones below //$this->assertEqual($var, 'CREATE TABLE sometable (id INTEGER PRIMARY KEY AUTOINCREMENT, name VARCHAR(4), INDEX myindex (id, name))'); @@ -121,17 +121,17 @@ public function testIdentifierQuoting() $this->conn->setAttribute(Doctrine_Core::ATTR_QUOTE_IDENTIFIER, false); } - public function testQuoteMultiplePks() + public function testQuoteMultiplePks() { $this->conn->setAttribute(Doctrine_Core::ATTR_QUOTE_IDENTIFIER, true); $name = 'mytable'; $fields = array('name' => array('type' => 'char', 'length' => 10), 'type' => array('type' => 'integer', 'length' => 3)); - + $options = array('primary' => array('name', 'type')); $this->export->createTable($name, $fields, $options); - + $this->assertEqual($this->adapter->pop(), 'CREATE TABLE "mytable" ("name" CHAR(10), "type" INTEGER, PRIMARY KEY("name", "type"))'); $this->conn->setAttribute(Doctrine_Core::ATTR_QUOTE_IDENTIFIER, false); @@ -157,14 +157,14 @@ public function testCreateTableSupportsIndexesWithCustomSorting() $options = array('primary' => array('id'), 'indexes' => array('myindex' => array( 'fields' => array( - 'id' => array('sorting' => 'ASC'), + 'id' => array('sorting' => 'ASC'), 'name' => array('sorting' => 'DESC') ) )) ); $this->export->createTable('sometable', $fields, $options); - + //removed this assertion and inserted the two below // $this->assertEqual($this->adapter->pop(), 'CREATE TABLE sometable (id INTEGER PRIMARY KEY AUTOINCREMENT, name VARCHAR(4), INDEX myindex (id ASC, name DESC))'); diff --git a/tests/Import/BuilderTestCase.php b/tests/Import/BuilderTestCase.php index 84f0804c5..5de915e88 100644 --- a/tests/Import/BuilderTestCase.php +++ b/tests/Import/BuilderTestCase.php @@ -30,7 +30,7 @@ * @since 1.0 * @version $Revision$ */ -class Doctrine_Import_Builder_TestCase extends Doctrine_UnitTestCase +class Doctrine_Import_Builder_TestCase extends Doctrine_UnitTestCase { public function testInheritanceGeneration() { @@ -55,10 +55,10 @@ public function testInheritanceGeneration() $this->assertTrue($schemaTestInheritanceParent->isSubclassOf('PackageSchemaTestInheritanceParent')); $this->assertTrue($schemaTestInheritanceChild1->isSubclassOf('BaseSchemaTestInheritanceChild1')); $this->assertTrue($schemaTestInheritanceChild2->isSubclassOf('BaseSchemaTestInheritanceChild2')); - + $this->assertTrue($schemaTestInheritanceChild1->isSubclassOf('SchemaTestInheritanceParent')); $this->assertTrue($schemaTestInheritanceChild1->isSubclassOf('BaseSchemaTestInheritanceParent')); - + $this->assertTrue($schemaTestInheritanceChild2->isSubclassOf('SchemaTestInheritanceParent')); $this->assertTrue($schemaTestInheritanceChild2->isSubclassOf('BaseSchemaTestInheritanceParent')); $this->assertTrue($schemaTestInheritanceChild2->isSubclassOf('SchemaTestInheritanceChild1')); diff --git a/tests/Import/PluginHierarchyTestCase.php b/tests/Import/PluginHierarchyTestCase.php index 26df10f42..0d286e1fb 100644 --- a/tests/Import/PluginHierarchyTestCase.php +++ b/tests/Import/PluginHierarchyTestCase.php @@ -75,11 +75,11 @@ public function testImportOfHieriarchyOfPluginGeneration() 3 => 'CREATE TABLE wiki_test (id INTEGER PRIMARY KEY AUTOINCREMENT)', 4 => 'CREATE UNIQUE INDEX wiki_test_translation_sluggable_idx ON wiki_test_translation (slug)', ); - + foreach($sql as $idx => $req) { $this->assertEqual($req, $result[$idx]); - } - + } + Doctrine_Lib::removeDirectories($path); unlink('wiki.yml'); } diff --git a/tests/Import/SchemaTestCase.php b/tests/Import/SchemaTestCase.php index c47a30358..05b021b60 100644 --- a/tests/Import/SchemaTestCase.php +++ b/tests/Import/SchemaTestCase.php @@ -30,11 +30,11 @@ * @since 1.0 * @version $Revision$ */ -class Doctrine_Import_Schema_TestCase extends Doctrine_UnitTestCase +class Doctrine_Import_Schema_TestCase extends Doctrine_UnitTestCase { public $buildSchema; public $schema; - + public function testYmlImport() { $path = __DIR__ . '/import_builder_test'; @@ -45,7 +45,7 @@ public function testYmlImport() if ( ! file_exists($path . '/SchemaTestUser.php')) { $this->fail(); } - + if ( ! file_exists($path . '/SchemaTestProfile.php')) { $this->fail(); } @@ -54,7 +54,7 @@ public function testYmlImport() Doctrine_Lib::removeDirectories($path); } - + public function testBuildSchema() { $schema = new Doctrine_Import_Schema(); @@ -77,7 +77,7 @@ public function testBuildSchema() $this->assertTrue(array_key_exists('detect_relations', $model) && is_bool($model['detect_relations'])); $this->assertEqual($array['AliasTest']['columns']['test_col']['name'], 'test_col as test_col_alias'); } - + public function testSchemaRelationshipCompletion() { $this->buildSchema = new Doctrine_Import_Schema(); @@ -87,22 +87,22 @@ public function testSchemaRelationshipCompletion() foreach ($properties['relations'] as $alias => $relation) { if ( ! $this->_verifyMultiDirectionalRelationship($name, $alias, $relation)) { $this->fail(); - + return false; } } } - + $this->pass(); } - + protected function _verifyMultiDirectionalRelationship($class, $relationAlias, $relation) { $foreignClass = $relation['class']; $foreignAlias = isset($relation['foreignAlias']) ? $relation['foreignAlias']:$class; - + $foreignClassRelations = $this->schema[$foreignClass]['relations']; - + // Check to see if the foreign class has the opposite end defined for the class/foreignAlias if (isset($foreignClassRelations[$foreignAlias])) { return true; diff --git a/tests/ImportTestCase.php b/tests/ImportTestCase.php index 8d062a252..3fbe5f276 100644 --- a/tests/ImportTestCase.php +++ b/tests/ImportTestCase.php @@ -30,11 +30,11 @@ * @since 1.0 * @version $Revision$ */ -class Doctrine_Import_TestCase extends Doctrine_UnitTestCase +class Doctrine_Import_TestCase extends Doctrine_UnitTestCase { - public function prepareTables() + public function prepareTables() { } - public function prepareData() + public function prepareData() { } public function testImport() @@ -51,4 +51,4 @@ public function testImport() $this->assertTrue(file_exists('Import/_files/generated/BaseImportTestUser.php')); Doctrine_Lib::removeDirectories('Import/_files'); } -} \ No newline at end of file +} diff --git a/tests/Migration/DiffTestCase.php b/tests/Migration/DiffTestCase.php index 7f6eb78d8..bfd0b2514 100644 --- a/tests/Migration/DiffTestCase.php +++ b/tests/Migration/DiffTestCase.php @@ -30,7 +30,7 @@ * @since 1.0 * @version $Revision$ */ -class Doctrine_Migration_Diff_TestCase extends Doctrine_UnitTestCase +class Doctrine_Migration_Diff_TestCase extends Doctrine_UnitTestCase { public function testTest() { @@ -60,7 +60,7 @@ public function testTest() $this->assertEqual(count($files), 2); $this->assertTrue(strpos($files[0], '_version1.php')); $this->assertTrue(strpos($files[1], '_version2.php')); - + $code1 = file_get_contents($files[0]); $this->assertTrue(strpos($code1, 'this->dropTable')); $this->assertTrue(strpos($code1, 'this->createTable')); diff --git a/tests/MigrationTestCase.php b/tests/MigrationTestCase.php index 59b2b336c..7b718ba54 100644 --- a/tests/MigrationTestCase.php +++ b/tests/MigrationTestCase.php @@ -128,29 +128,3 @@ public function testMigrationClassNameInflected() } } } - -class MigrationPhonenumber extends Doctrine_Record -{ - public function setTableDefinition() - { - $this->hasColumn('user_id', 'integer'); - $this->hasColumn('phonenumber', 'string', 255); - } -} - -class MigrationUser extends Doctrine_Record -{ - public function setTableDefinition() - { - $this->hasColumn('username', 'string', 255); - $this->hasColumn('password', 'string', 255); - } -} - -class MigrationProfile extends Doctrine_Record -{ - public function setTableDefinition() - { - $this->hasColumn('name', 'string', 255); - } -} diff --git a/tests/ParserTestCase.php b/tests/ParserTestCase.php index 7f5e54862..8afca682d 100644 --- a/tests/ParserTestCase.php +++ b/tests/ParserTestCase.php @@ -30,19 +30,19 @@ * @since 1.0 * @version $Revision$ */ -class Doctrine_Parser_TestCase extends Doctrine_UnitTestCase +class Doctrine_Parser_TestCase extends Doctrine_UnitTestCase { public function testGetParserInstance() { $instance = Doctrine_Parser::getParser('Yml'); - + if ($instance instanceof Doctrine_Parser_Yml) { $this->pass(); } else { $this->fail(); } } - + public function testFacadeLoadAndDump() { Doctrine_Parser::dump(array('test' => 'good job', 'test2' => true, array('testing' => false)), 'yml', 'test.yml'); @@ -51,7 +51,7 @@ public function testFacadeLoadAndDump() $this->assertEqual($array, array('test' => 'good job', 'test2' => true, array('testing' => false))); unlink('test.yml'); } - + public function testParserSupportsEmbeddingPhpSyntax() { $parser = Doctrine_Parser::getParser('Yml'); @@ -62,12 +62,12 @@ public function testParserSupportsEmbeddingPhpSyntax() w00t: not now "; $data = $parser->doLoad($yml); - + $array = $parser->loadData($data); - + $this->assertEqual($array, array('test' => 'good job', 'test2' => true, 'testing' => false, 'w00t' => 'not now')); } - + public function testParserWritingToDisk() { $parser = Doctrine_Parser::getParser('Yml'); @@ -76,15 +76,15 @@ public function testParserWritingToDisk() $this->assertEqual('test', file_get_contents('test.yml')); unlink('test.yml'); } - + public function testParserReturningLoadedData() { $parser = Doctrine_Parser::getParser('Yml'); $result = $parser->doDump('test'); - + $this->assertEqual('test', $result); } - + public function testLoadFromString() { $yml = "--- diff --git a/tests/Relation/OneToOneTestCase.php b/tests/Relation/OneToOneTestCase.php index b65f9dcf0..11264350f 100644 --- a/tests/Relation/OneToOneTestCase.php +++ b/tests/Relation/OneToOneTestCase.php @@ -30,14 +30,14 @@ * @since 1.0 * @version $Revision$ */ -class Doctrine_Relation_OneToOne_TestCase extends Doctrine_UnitTestCase +class Doctrine_Relation_OneToOne_TestCase extends Doctrine_UnitTestCase { - public function prepareData() + public function prepareData() { } - public function prepareTables() - { - $this->tables = array('gnatUser','gnatEmail','Email','Entity','Record_City', 'Record_Country', 'SelfRefTest'); - + public function prepareTables() + { + $this->tables = array('GnatUser','GnatEmail','Email','Entity','Record_City', 'Record_Country', 'SelfRefTest'); + parent::prepareTables(); } @@ -46,27 +46,27 @@ public function testOneToOneAggregateRelationWithAliasesIsSupported() $city = new Record_City(); $country = $city->Country; - $this->assertTrue($country instanceof Record_Country); + $this->assertTrue($country instanceof Record_Country); } - + public function testSelfReferentialOneToOneRelationsAreSupported() { $ref = new SelfRefTest(); - + $rel = $ref->getTable()->getRelation('createdBy'); $this->assertEqual($rel->getForeign(), 'id'); $this->assertEqual($rel->getLocal(), 'created_by'); - + $ref->name = 'ref 1'; $ref->createdBy->name = 'ref 2'; - + $ref->save(); } public function testSelfReferentialOneToOneRelationsAreSupported2() { $this->connection->clear(); - + $ref = $this->conn->queryOne("FROM SelfRefTest s WHERE s.name = 'ref 1'"); $this->assertEqual($ref->name, 'ref 1'); $this->assertEqual($ref->createdBy->name, 'ref 2'); @@ -88,14 +88,14 @@ public function testUnsetRelation() public function testSavingRelatedObjects() { - $user = new gnatUser(); + $user = new GnatUser(); $user->name = 'test'; - $email = new gnatEmail(); + $email = new GnatEmail(); $email->address = 'test3@test.com'; $user->Email = $email; $user->save(); - $this->assertTrue($user->Email instanceOf gnatEmail); + $this->assertTrue($user->Email instanceOf GnatEmail); $this->assertEqual($user->foreign_id, $user->Email->id); - + } } diff --git a/tests/Ticket/1118TestCase.php b/tests/Ticket/1118TestCase.php index 44aa90c50..3f0d9a54b 100644 --- a/tests/Ticket/1118TestCase.php +++ b/tests/Ticket/1118TestCase.php @@ -30,7 +30,7 @@ * @since 1.0 * @version $Revision$ */ -class Doctrine_Ticket_1118_TestCase extends Doctrine_UnitTestCase +class Doctrine_Ticket_1118_TestCase extends Doctrine_UnitTestCase { // Test that when a foreign key is detected that it sets the foreign key to the same type and length // of the related table primary key @@ -70,4 +70,4 @@ public function testTest() unlink('test.yml'); } -} \ No newline at end of file +} diff --git a/tests/Ticket/1351TestCase.php b/tests/Ticket/1351TestCase.php index 8a7a6b27a..e402926ea 100644 --- a/tests/Ticket/1351TestCase.php +++ b/tests/Ticket/1351TestCase.php @@ -30,7 +30,7 @@ * @since 1.0 * @version $Revision$ */ -class Doctrine_Ticket_1351_TestCase extends Doctrine_UnitTestCase +class Doctrine_Ticket_1351_TestCase extends Doctrine_UnitTestCase { public function prepareTables() { @@ -76,4 +76,4 @@ public function setUp() $i18n0->addChild($searchable1); $this->actAs($i18n0); } -} \ No newline at end of file +} diff --git a/tests/Ticket/1527TestCase.php b/tests/Ticket/1527TestCase.php index 2935039a2..6d23902df 100644 --- a/tests/Ticket/1527TestCase.php +++ b/tests/Ticket/1527TestCase.php @@ -30,7 +30,7 @@ * @since 1.0 * @version $Revision$ */ -class Doctrine_Ticket_1527_TestCase extends Doctrine_UnitTestCase +class Doctrine_Ticket_1527_TestCase extends Doctrine_UnitTestCase { public function testTest() { diff --git a/tests/Ticket/1617TestCase.php b/tests/Ticket/1617TestCase.php index fc36a8bd9..8c8f71be6 100644 --- a/tests/Ticket/1617TestCase.php +++ b/tests/Ticket/1617TestCase.php @@ -29,7 +29,7 @@ * @since 1.1 * @version $Revision$ */ -class Doctrine_Ticket_1617_TestCase extends Doctrine_UnitTestCase +class Doctrine_Ticket_1617_TestCase extends Doctrine_UnitTestCase { public function testBuildSchema() { @@ -38,4 +38,4 @@ public function testBuildSchema() $this->assertEqual($array['term']['columns']['language']['name'], 'lang as language'); } -} \ No newline at end of file +} diff --git a/tests/Ticket/2355TestCase.php b/tests/Ticket/2355TestCase.php index c661703ca..918038635 100644 --- a/tests/Ticket/2355TestCase.php +++ b/tests/Ticket/2355TestCase.php @@ -30,7 +30,7 @@ * @since 1.0 * @version $Revision$ */ -class Doctrine_Ticket_2355_TestCase extends Doctrine_UnitTestCase +class Doctrine_Ticket_2355_TestCase extends Doctrine_UnitTestCase { public function setUp() { @@ -163,7 +163,7 @@ public function setTableDefinition() $this->index('episode', array( - 'fields' => + 'fields' => array( 0 => 'season', 1 => 'number', @@ -300,4 +300,4 @@ public function setUp() 'foreign' => 'id', 'onDelete' => 'CASCADE')); } -} \ No newline at end of file +} diff --git a/tests/Ticket/915TestCase.php b/tests/Ticket/915TestCase.php index c73ca976a..93ee51ce8 100644 --- a/tests/Ticket/915TestCase.php +++ b/tests/Ticket/915TestCase.php @@ -36,7 +36,7 @@ public function prepareData() { } public function prepareTables() { $this->tables[] = 'Account'; - parent::prepareTables(); + parent::prepareTables(); } public function testBug() @@ -72,4 +72,4 @@ public function testBug() $this->pass(); } } -} \ No newline at end of file +} diff --git a/tests/Ticket/DC147TestCase.php b/tests/Ticket/DC147TestCase.php index 2b0eb5487..d2783dbad 100644 --- a/tests/Ticket/DC147TestCase.php +++ b/tests/Ticket/DC147TestCase.php @@ -30,7 +30,7 @@ * @since 1.0 * @version $Revision$ */ -class Doctrine_Ticket_DC147_TestCase extends Doctrine_UnitTestCase +class Doctrine_Ticket_DC147_TestCase extends Doctrine_UnitTestCase { public function prepareTables() { @@ -50,8 +50,8 @@ public function testInlineMultiple() name: isbn2 ISBN3: name: isbn3 -DC147_Product: - Product_1: +DC147_Product: + Product_1: name: book3 MultipleValues: Multi_1: @@ -60,7 +60,7 @@ public function testInlineMultiple() Multi_2: value: 232323233 Multiple: ISBN3 - Product_2: + Product_2: name: book4 MultipleValues: Multi_3: @@ -171,4 +171,4 @@ public function setUp() $this->hasOne('DC147_Product as Product', array('local' => 'product_id', 'foreign' => 'id')); } -} \ No newline at end of file +} diff --git a/tests/Ticket/DC23TestCase.php b/tests/Ticket/DC23TestCase.php index 20de702d7..2c17a2e6c 100644 --- a/tests/Ticket/DC23TestCase.php +++ b/tests/Ticket/DC23TestCase.php @@ -30,7 +30,7 @@ * @since 1.0 * @version $Revision$ */ -class Doctrine_Ticket_DC23_TestCase extends Doctrine_UnitTestCase +class Doctrine_Ticket_DC23_TestCase extends Doctrine_UnitTestCase { public function prepareTables() { @@ -54,8 +54,8 @@ public function testTest() title: Test body: Testing -Ticket_DC23_User: - User_1: +Ticket_DC23_User: + User_1: name: jwage Contact: name: Test Contact @@ -196,4 +196,4 @@ public function setUp() ) ); } -} \ No newline at end of file +} diff --git a/tests/Ticket/DC23bTestCase.php b/tests/Ticket/DC23bTestCase.php index 682844ff2..b28d63149 100644 --- a/tests/Ticket/DC23bTestCase.php +++ b/tests/Ticket/DC23bTestCase.php @@ -30,7 +30,7 @@ * @since 1.0 * @version $Revision$ */ -class Doctrine_Ticket_DC23b_TestCase extends Doctrine_UnitTestCase +class Doctrine_Ticket_DC23b_TestCase extends Doctrine_UnitTestCase { public function prepareTables() { @@ -45,8 +45,8 @@ public function testInlineSite() { $yml = <<hasOne('Ticket_Product as Product', array('local' => 'product_id', 'foreign' => 'id')); } -} \ No newline at end of file +} diff --git a/tests/Ticket/DC95TestCase.php b/tests/Ticket/DC95TestCase.php index f09d31f2d..c4d2bdcbd 100644 --- a/tests/Ticket/DC95TestCase.php +++ b/tests/Ticket/DC95TestCase.php @@ -30,7 +30,7 @@ * @since 1.0 * @version $Revision$ */ -class Doctrine_Ticket_DC95_TestCase extends Doctrine_UnitTestCase +class Doctrine_Ticket_DC95_TestCase extends Doctrine_UnitTestCase { public function testClassDoesNotExistBeforeImport() { diff --git a/tests/ValidatorTestCase.php b/tests/ValidatorTestCase.php index 92943fa29..28cb5fa5e 100644 --- a/tests/ValidatorTestCase.php +++ b/tests/ValidatorTestCase.php @@ -123,7 +123,19 @@ public function testIsValidType() $this->assertTrue(Doctrine_Validator::isValidType($var, 'object')); } - public function testValidate2() + public function testIsValidLength() + { + // Test length is less than maximum length + $this->assertTrue(Doctrine_Validator::validateLength(1.2345, "decimal", 5)); + + // Test null value is less than maximum length + $this->assertTrue(Doctrine_Validator::validateLength(null, "decimal", 4)); + + // Test length is greater than maximum length + $this->assertFalse(Doctrine_Validator::validateLength(1.2345, "decimal", 4)); + } + + public function testValidate2() { $test = new ValidatorTest(); $test->mymixed = "message"; diff --git a/tests/bin/test b/tests/bin/test index 20d8d6aee..2df829884 100755 --- a/tests/bin/test +++ b/tests/bin/test @@ -17,7 +17,7 @@ skipPHPVersions='php8' # Commands # dcexec="docker-compose exec -u `id -u`:`id -g`" -composerUpdate='composer update --prefer-dist --no-suggest --optimize-autoloader' +composerUpdate='composer update --prefer-dist --optimize-autoloader' doctrineTestSuite='run.php' # Parse arguments diff --git a/tests/models/Blog.php b/tests/models/Blog.php index 00acbb1b1..1dc3018f1 100644 --- a/tests/models/Blog.php +++ b/tests/models/Blog.php @@ -10,23 +10,3 @@ public function setUp() $this->actAs('Taggable'); } } -class Taggable extends Doctrine_Template -{ - public function setUp() - { - //$this->hasMany('[Component]TagTemplate as Tag'); - } -} -class TagTemplate extends Doctrine_Record -{ - public function setTableDefinition() - { - $this->hasColumn('name', 'string', 100); - $this->hasColumn('description', 'string'); - } - - public function setUp() - { - //$this->hasOne('[Component]', array('onDelete' => 'CASCADE')); - } -} diff --git a/tests/models/gnatEmail.php b/tests/models/GnatEmail.php similarity index 69% rename from tests/models/gnatEmail.php rename to tests/models/GnatEmail.php index 209ef6fd3..e07c6b8b6 100644 --- a/tests/models/gnatEmail.php +++ b/tests/models/GnatEmail.php @@ -1,10 +1,8 @@ hasColumn('address', 'string', 150); } - - } diff --git a/tests/models/gnatUser.php b/tests/models/GnatUser.php similarity index 58% rename from tests/models/gnatUser.php rename to tests/models/GnatUser.php index e6a66915b..f336231e3 100644 --- a/tests/models/gnatUser.php +++ b/tests/models/GnatUser.php @@ -1,19 +1,16 @@ -hasColumn('name', 'string', 150); $this->hasColumn('foreign_id', 'integer', 10, array ('unique' => true,)); } - + public function setUp() { parent::setUp(); - $this->hasOne('gnatEmail as Email', array('local'=> 'foreign_id', 'foreign'=>'id', 'onDelete'=>'CASCADE')); + $this->hasOne('GnatEmail as Email', array('local'=> 'foreign_id', 'foreign'=>'id', 'onDelete'=>'CASCADE')); } - -} +} diff --git a/tests/models/GnatUserTable.php b/tests/models/GnatUserTable.php new file mode 100644 index 000000000..f2c039b87 --- /dev/null +++ b/tests/models/GnatUserTable.php @@ -0,0 +1,3 @@ + Doctrine_Connection -// won't initialize grouptable when Doctrine_Connection->getTable('Group') is called -class GroupTable { } - class Group extends Entity { public function setUp() diff --git a/tests/models/GroupTable.php b/tests/models/GroupTable.php new file mode 100644 index 000000000..cc25211eb --- /dev/null +++ b/tests/models/GroupTable.php @@ -0,0 +1,5 @@ + Doctrine_Connection +// won't initialize grouptable when Doctrine_Connection->getTable('Group') is called +class GroupTable { } diff --git a/tests/models/MigrationPhonenumber.php b/tests/models/MigrationPhonenumber.php new file mode 100644 index 000000000..af55ef786 --- /dev/null +++ b/tests/models/MigrationPhonenumber.php @@ -0,0 +1,10 @@ +hasColumn('user_id', 'integer'); + $this->hasColumn('phonenumber', 'string', 255); + } +} diff --git a/tests/models/MigrationProfile.php b/tests/models/MigrationProfile.php new file mode 100644 index 000000000..8302b6751 --- /dev/null +++ b/tests/models/MigrationProfile.php @@ -0,0 +1,9 @@ +hasColumn('name', 'string', 255); + } +} diff --git a/tests/models/MigrationUser.php b/tests/models/MigrationUser.php new file mode 100644 index 000000000..7c366179f --- /dev/null +++ b/tests/models/MigrationUser.php @@ -0,0 +1,10 @@ +hasColumn('username', 'string', 255); + $this->hasColumn('password', 'string', 255); + } +} diff --git a/tests/models/RelationTest.php b/tests/models/RelationTest.php index 2932d7ca0..92f73cf8c 100644 --- a/tests/models/RelationTest.php +++ b/tests/models/RelationTest.php @@ -7,19 +7,3 @@ public function setTableDefinition() $this->hasColumn('parent_id', 'integer'); } } - -class RelationTestChild extends RelationTest -{ - public function setUp() - { - $this->hasOne('RelationTest as Parent', array( - 'local' => 'parent_id', - 'foreign' => 'id', - 'onDelete' => 'CASCADE', - )); - $this->hasMany('RelationTestChild as Children', array( - 'local' => 'id', - 'foreign' => 'parent_id', - )); - } -} diff --git a/tests/models/RelationTestChild.php b/tests/models/RelationTestChild.php new file mode 100644 index 000000000..7f1087e43 --- /dev/null +++ b/tests/models/RelationTestChild.php @@ -0,0 +1,19 @@ +hasOne('RelationTest as Parent', array( + 'local' => 'parent_id', + 'foreign' => 'id', + 'onDelete' => 'CASCADE', + )); + $this->hasMany('RelationTestChild as Children', array( + 'local' => 'id', + 'foreign' => 'parent_id', + )); + } +} diff --git a/tests/models/TagTemplate.php b/tests/models/TagTemplate.php new file mode 100644 index 000000000..9ecc7c9e3 --- /dev/null +++ b/tests/models/TagTemplate.php @@ -0,0 +1,14 @@ +hasColumn('name', 'string', 100); + $this->hasColumn('description', 'string'); + } + + public function setUp() + { + //$this->hasOne('[Component]', array('onDelete' => 'CASCADE')); + } +} diff --git a/tests/models/Taggable.php b/tests/models/Taggable.php new file mode 100644 index 000000000..98e6a6581 --- /dev/null +++ b/tests/models/Taggable.php @@ -0,0 +1,8 @@ +hasMany('[Component]TagTemplate as Tag'); + } +} diff --git a/tests/models/User.php b/tests/models/User.php index 9cd73295b..f093d0d08 100644 --- a/tests/models/User.php +++ b/tests/models/User.php @@ -2,10 +2,6 @@ require_once('Entity.php'); -// UserTable doesn't extend Doctrine_Table -> Doctrine_Connection -// won't initialize grouptable when Doctrine_Connection->getTable('User') is called -class UserTable extends Doctrine_Table { } - class User extends Entity { public function setUp() diff --git a/tests/models/UserTable.php b/tests/models/UserTable.php new file mode 100644 index 000000000..3f5e84710 --- /dev/null +++ b/tests/models/UserTable.php @@ -0,0 +1,5 @@ + Doctrine_Connection +// won't initialize grouptable when Doctrine_Connection->getTable('User') is called +class UserTable extends Doctrine_Table { } diff --git a/tests/models/VersioningTest.php b/tests/models/VersioningTest.php index 8219d1bcf..7cb60d492 100644 --- a/tests/models/VersioningTest.php +++ b/tests/models/VersioningTest.php @@ -11,32 +11,3 @@ public function setUp() $this->actAs('Versionable'); } } - -class VersioningTest2 extends Doctrine_Record -{ - public function setTableDefinition() - { - $this->hasColumn('name', 'string'); - $this->hasColumn('version', 'integer'); - } - public function setUp() - { - $this->actAs('Versionable', array('auditLog' => false)); - } -} - -class VersioningTest3 extends Doctrine_Record -{ - public function setTableDefinition() - { - $this->hasColumn('name', 'string'); - $this->hasColumn('version', 'integer'); - } - public function setUp() - { - - $this->actAs('Versionable', array('tableName' => 'tbl_prefix_comments_version', - 'className' => 'VersioningTestClass')); - - } -} \ No newline at end of file diff --git a/tests/models/VersioningTest2.php b/tests/models/VersioningTest2.php new file mode 100644 index 000000000..c48e9de31 --- /dev/null +++ b/tests/models/VersioningTest2.php @@ -0,0 +1,13 @@ +hasColumn('name', 'string'); + $this->hasColumn('version', 'integer'); + } + public function setUp() + { + $this->actAs('Versionable', array('auditLog' => false)); + } +} diff --git a/tests/models/VersioningTest3.php b/tests/models/VersioningTest3.php new file mode 100644 index 000000000..dd6a30403 --- /dev/null +++ b/tests/models/VersioningTest3.php @@ -0,0 +1,17 @@ +hasColumn('name', 'string'); + $this->hasColumn('version', 'integer'); + } + public function setUp() + { + $this->actAs('Versionable', array( + 'tableName' => 'tbl_prefix_comments_version', + 'className' => 'VersioningTestClass' + )); + } +}