diff --git a/tests/Doctrine/Tests/ORM/Query/DeleteSqlGenerationTest.php b/tests/Doctrine/Tests/ORM/Query/DeleteSqlGenerationTest.php index 0a79fd20b..8d1597629 100644 --- a/tests/Doctrine/Tests/ORM/Query/DeleteSqlGenerationTest.php +++ b/tests/Doctrine/Tests/ORM/Query/DeleteSqlGenerationTest.php @@ -56,19 +56,23 @@ class DeleteSqlGenerationTest extends \Doctrine\Tests\OrmTestCase } } - public function testWithoutWhere() + public function testSupportsDeleteWithoutWhereAndFrom() { $this->assertSqlGeneration( 'DELETE Doctrine\Tests\Models\CMS\CmsUser u', 'DELETE FROM cms_users' ); + } + + public function testSupportsDeleteWithoutWhere() + { $this->assertSqlGeneration( 'DELETE FROM Doctrine\Tests\Models\CMS\CmsUser u', 'DELETE FROM cms_users' ); } - public function testWithWhere() + public function testSupportsWhereClause() { $this->assertSqlGeneration( 'DELETE Doctrine\Tests\Models\CMS\CmsUser u WHERE u.id = ?1', @@ -76,13 +80,16 @@ class DeleteSqlGenerationTest extends \Doctrine\Tests\OrmTestCase ); } - public function testWithConditionalExpressions() + public function testSupportsWhereOrExpressions() { $this->assertSqlGeneration( 'DELETE Doctrine\Tests\Models\CMS\CmsUser u WHERE u.username = ?1 OR u.name = ?2', 'DELETE FROM cms_users WHERE username = ? OR name = ?' ); + } + public function testSupportsWhereNestedConditionalExpressions() + { $this->assertSqlGeneration( 'DELETE Doctrine\Tests\Models\CMS\CmsUser u WHERE u.id = ?1 OR ( u.username = ?2 OR u.name = ?3)', 'DELETE FROM cms_users WHERE id = ? OR (username = ? OR name = ?)' @@ -94,7 +101,7 @@ class DeleteSqlGenerationTest extends \Doctrine\Tests\OrmTestCase //); } - public function testParserIsCaseAgnostic() + public function testIsCaseAgnostic() { $this->assertSqlGeneration( "delete from Doctrine\Tests\Models\CMS\CmsUser u where u.username = ?1", @@ -102,7 +109,7 @@ class DeleteSqlGenerationTest extends \Doctrine\Tests\OrmTestCase ); } - public function testWithConditionalTerms() + public function testSupportsAndCondition() { $this->assertSqlGeneration( "DELETE Doctrine\Tests\Models\CMS\CmsUser u WHERE u.username = ?1 AND u.name = ?2", @@ -110,125 +117,160 @@ class DeleteSqlGenerationTest extends \Doctrine\Tests\OrmTestCase ); } - public function testWithConditionalFactors() + public function testSupportsWhereNot() { $this->assertSqlGeneration( "DELETE Doctrine\Tests\Models\CMS\CmsUser u WHERE NOT u.id != ?1", "DELETE FROM cms_users WHERE NOT id <> ?" ); + } + public function testSupportsWhereNotWithParentheses() + { $this->assertSqlGeneration( "DELETE Doctrine\Tests\Models\CMS\CmsUser u WHERE NOT ( u.id != ?1 )", "DELETE FROM cms_users WHERE NOT (id <> ?)" ); + } + public function testSupportsWhereNotWithAndExpression() + { $this->assertSqlGeneration( "DELETE Doctrine\Tests\Models\CMS\CmsUser u WHERE NOT ( u.id != ?1 AND u.username = ?2 )", "DELETE FROM cms_users WHERE NOT (id <> ? AND username = ?)" ); } - // ConditionalPrimary was already tested (see testDeleteWithWhere() and testDeleteWithConditionalFactors()) + // ConditionalPrimary was already tested (see testSupportsWhereClause() and testSupportsWhereNot()) - public function testWithExprAndComparison() + public function testSupportsGreaterThanComparisonClause() { // id = ? was already tested (see testDeleteWithWhere()) $this->assertSqlGeneration( "DELETE Doctrine\Tests\Models\CMS\CmsUser u WHERE u.id > ?1", "DELETE FROM cms_users WHERE id > ?" ); + } + public function testSupportsGreaterThanOrEqualToComparisonClause() + { $this->assertSqlGeneration( "DELETE Doctrine\Tests\Models\CMS\CmsUser u WHERE u.id >= ?1", "DELETE FROM cms_users WHERE id >= ?" ); + } + public function testSupportsLessThanComparisonClause() + { $this->assertSqlGeneration( "DELETE Doctrine\Tests\Models\CMS\CmsUser u WHERE u.id < ?1", "DELETE FROM cms_users WHERE id < ?" ); + } + public function testSupportsLessThanOrEqualToComparisonClause() + { $this->assertSqlGeneration( "DELETE Doctrine\Tests\Models\CMS\CmsUser u WHERE u.id <= ?1", "DELETE FROM cms_users WHERE id <= ?" ); + } + public function testSupportsNotEqualToComparisonClause() + { $this->assertSqlGeneration( "DELETE Doctrine\Tests\Models\CMS\CmsUser u WHERE u.id <> ?1", "DELETE FROM cms_users WHERE id <> ?" ); + } + public function testSupportsNotEqualToComparisonClauseExpressedWithExclamationMark() + { $this->assertSqlGeneration( "DELETE Doctrine\Tests\Models\CMS\CmsUser u WHERE u.id != ?1", "DELETE FROM cms_users WHERE id <> ?" ); } - public function testWithExprAndBetween() + public function testSupportsNotBetweenClause() { $this->assertSqlGeneration( "DELETE Doctrine\Tests\Models\CMS\CmsUser u WHERE u.id NOT BETWEEN ?1 AND ?2", "DELETE FROM cms_users WHERE id NOT BETWEEN ? AND ?" ); + } + public function testSupportsBetweenClauseUsedWithAndClause() + { $this->assertSqlGeneration( "DELETE Doctrine\Tests\Models\CMS\CmsUser u WHERE u.id BETWEEN ?1 AND ?2 AND u.username != ?3", "DELETE FROM cms_users WHERE id BETWEEN ? AND ? AND username <> ?" ); } - public function testWithExprAndLike() + public function testSupportsNotLikeClause() { // "WHERE" Expression LikeExpression $this->assertSqlGeneration( 'DELETE Doctrine\Tests\Models\CMS\CmsUser u WHERE u.username NOT LIKE ?1', 'DELETE FROM cms_users WHERE username NOT LIKE ?' ); + } + public function testSupportsLikeClauseWithEscapeExpression() + { $this->assertSqlGeneration( "DELETE Doctrine\Tests\Models\CMS\CmsUser u WHERE u.username LIKE ?1 ESCAPE '\\'", "DELETE FROM cms_users WHERE username LIKE ? ESCAPE '\\'" ); } - public function testWithExprAndNull() + public function testSupportsIsNullClause() { // "WHERE" Expression NullComparisonExpression $this->assertSqlGeneration( 'DELETE Doctrine\Tests\Models\CMS\CmsUser u WHERE u.name IS NULL', 'DELETE FROM cms_users WHERE name IS NULL' ); + } + public function testSupportsIsNotNullClause() + { $this->assertSqlGeneration( 'DELETE Doctrine\Tests\Models\CMS\CmsUser u WHERE u.name IS NOT NULL', 'DELETE FROM cms_users WHERE name IS NOT NULL' ); } - public function testWithPrimaryAsAtom() + public function testSupportsAtomExpressionAsClause() { $this->assertSqlGeneration( 'DELETE Doctrine\Tests\Models\CMS\CmsUser u WHERE 1 = 1', 'DELETE FROM cms_users WHERE 1 = 1' ); + } + public function testSupportsParameterizedAtomExpression() + { $this->assertSqlGeneration( 'DELETE Doctrine\Tests\Models\CMS\CmsUser u WHERE ?1 = 1', 'DELETE FROM cms_users WHERE ? = 1' ); } - public function testWithExprAndIn() + public function testSupportsInClause() { $this->assertSqlGeneration( 'DELETE Doctrine\Tests\Models\CMS\CmsUser u WHERE u.id IN ( ?1, ?2, ?3, ?4 )', 'DELETE FROM cms_users WHERE id IN (?, ?, ?, ?)' ); + } + public function testSupportsNotInClause() + { $this->assertSqlGeneration( 'DELETE Doctrine\Tests\Models\CMS\CmsUser u WHERE u.id NOT IN ( ?1, ?2 )', 'DELETE FROM cms_users WHERE id NOT IN (?, ?)' ); } - } diff --git a/tests/Doctrine/Tests/ORM/Query/SelectSqlGenerationTest.php b/tests/Doctrine/Tests/ORM/Query/SelectSqlGenerationTest.php index 1d53b1992..3b8616d65 100644 --- a/tests/Doctrine/Tests/ORM/Query/SelectSqlGenerationTest.php +++ b/tests/Doctrine/Tests/ORM/Query/SelectSqlGenerationTest.php @@ -26,20 +26,23 @@ class SelectSqlGenerationTest extends \Doctrine\Tests\OrmTestCase } } - public function testPlainFromClauseWithoutAlias() + public function testSupportsSelectForAllFields() { $this->assertSqlGeneration( 'SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u', 'SELECT c0_.id AS id0, c0_.status AS status1, c0_.username AS username2, c0_.name AS name3 FROM cms_users c0_' ); + } + public function testSupportsSelectForOneField() + { $this->assertSqlGeneration( 'SELECT u.id FROM Doctrine\Tests\Models\CMS\CmsUser u', 'SELECT c0_.id AS id0 FROM cms_users c0_' ); } - public function testSelectSingleComponentWithMultipleColumns() + public function testSupportsSelectForMultipleColumnsOfASingleComponent() { $this->assertSqlGeneration( 'SELECT u.username, u.name FROM Doctrine\Tests\Models\CMS\CmsUser u', @@ -47,7 +50,7 @@ class SelectSqlGenerationTest extends \Doctrine\Tests\OrmTestCase ); } - public function testSelectWithCollectionAssociationJoin() + public function testSupportsSelectWithCollectionAssociationJoin() { $this->assertSqlGeneration( 'SELECT u, p FROM Doctrine\Tests\Models\CMS\CmsUser u JOIN u.phonenumbers p', @@ -55,7 +58,7 @@ class SelectSqlGenerationTest extends \Doctrine\Tests\OrmTestCase ); } - public function testSelectWithSingleValuedAssociationJoin() + public function testSupportsSelectWithSingleValuedAssociationJoin() { $this->assertSqlGeneration( 'SELECT u, a FROM Doctrine\Tests\Models\Forum\ForumUser u JOIN u.avatar a', @@ -63,7 +66,7 @@ class SelectSqlGenerationTest extends \Doctrine\Tests\OrmTestCase ); } - public function testSelectDistinctIsSupported() + public function testSupportsSelectDistinct() { $this->assertSqlGeneration( 'SELECT DISTINCT u.name FROM Doctrine\Tests\Models\CMS\CmsUser u', @@ -71,7 +74,7 @@ class SelectSqlGenerationTest extends \Doctrine\Tests\OrmTestCase ); } - public function testAggregateFunctionInSelect() + public function testSupportsAggregateFunctionInSelectedFields() { $this->assertSqlGeneration( 'SELECT COUNT(u.id) FROM Doctrine\Tests\Models\CMS\CmsUser u GROUP BY u.id', @@ -79,7 +82,7 @@ class SelectSqlGenerationTest extends \Doctrine\Tests\OrmTestCase ); } - public function testWhereClauseInSelectWithPositionalParameter() + public function testSupportsWhereClauseWithPositionalParameter() { $this->assertSqlGeneration( 'select u from Doctrine\Tests\Models\Forum\ForumUser u where u.id = ?1', @@ -87,7 +90,7 @@ class SelectSqlGenerationTest extends \Doctrine\Tests\OrmTestCase ); } - public function testWhereClauseInSelectWithNamedParameter() + public function testSupportsWhereClauseWithNamedParameter() { $this->assertSqlGeneration( 'select u from Doctrine\Tests\Models\Forum\ForumUser u where u.username = :name', @@ -95,7 +98,7 @@ class SelectSqlGenerationTest extends \Doctrine\Tests\OrmTestCase ); } - public function testWhereANDClauseInSelectWithNamedParameter() + public function testSupportsWhereAndClauseWithNamedParameters() { $this->assertSqlGeneration( 'select u from Doctrine\Tests\Models\Forum\ForumUser u where u.username = :name and u.username = :name2', @@ -103,7 +106,7 @@ class SelectSqlGenerationTest extends \Doctrine\Tests\OrmTestCase ); } - public function testCombinedWhereClauseInSelectWithNamedParameter() + public function testSupportsCombinedWhereClauseWithNamedParameter() { $this->assertSqlGeneration( 'select u from Doctrine\Tests\Models\Forum\ForumUser u where (u.username = :name OR u.username = :name2) AND u.id = :id', @@ -111,7 +114,7 @@ class SelectSqlGenerationTest extends \Doctrine\Tests\OrmTestCase ); } - public function testAggregateFunctionWithDistinctInSelect() + public function testSupportsAggregateFunctionInASelectDistinct() { $this->assertSqlGeneration( 'SELECT COUNT(DISTINCT u.name) FROM Doctrine\Tests\Models\CMS\CmsUser u', @@ -120,7 +123,7 @@ class SelectSqlGenerationTest extends \Doctrine\Tests\OrmTestCase } // Ticket #668 - public function testKeywordUsageInStringParam() + public function testSupportsASqlKeywordInAStringLiteralParam() { $this->assertSqlGeneration( "SELECT u.name FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.name LIKE '%foo OR bar%'", @@ -128,7 +131,7 @@ class SelectSqlGenerationTest extends \Doctrine\Tests\OrmTestCase ); } - public function testArithmeticExpressionsSupportedInWherePart() + public function testSupportsArithmeticExpressionsInWherePart() { $this->assertSqlGeneration( 'SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE ((u.id + 5000) * u.id + 3) < 10000000', @@ -136,7 +139,7 @@ class SelectSqlGenerationTest extends \Doctrine\Tests\OrmTestCase ); } - public function testPlainJoinWithoutClause() + public function testSupportsPlainJoinWithoutClause() { $this->assertSqlGeneration( 'SELECT u.id, a.id from Doctrine\Tests\Models\CMS\CmsUser u LEFT JOIN u.articles a', @@ -148,7 +151,7 @@ class SelectSqlGenerationTest extends \Doctrine\Tests\OrmTestCase ); } - public function testDeepJoin() + public function testSupportsMultipleJoins() { $this->assertSqlGeneration( 'SELECT u.id, a.id, p, c.id from Doctrine\Tests\Models\CMS\CmsUser u JOIN u.articles a JOIN u.phonenumbers p JOIN a.comments c', @@ -156,7 +159,7 @@ class SelectSqlGenerationTest extends \Doctrine\Tests\OrmTestCase ); } - public function testTrimFunction() + public function testSupportsTrimFunction() { $this->assertSqlGeneration( "SELECT u.name FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE TRIM(TRAILING ' ' FROM u.name) = 'someone'", @@ -165,7 +168,7 @@ class SelectSqlGenerationTest extends \Doctrine\Tests\OrmTestCase } // Ticket 894 - public function testBetweenDeclarationWithInputParameter() + public function testSupportsBetweenClauseWithPositionalParameters() { $this->assertSqlGeneration( "SELECT u.name FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.id BETWEEN ?1 AND ?2", @@ -173,7 +176,7 @@ class SelectSqlGenerationTest extends \Doctrine\Tests\OrmTestCase ); } - public function testFunctionalExpressionsSupportedInWherePart() + public function testSupportsFunctionalExpressionsInWherePart() { $this->assertSqlGeneration( "SELECT u.name FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE TRIM(u.name) = 'someone'", @@ -184,7 +187,7 @@ class SelectSqlGenerationTest extends \Doctrine\Tests\OrmTestCase } // Ticket #973 - public function testSingleInValueWithoutSpace() + public function testSupportsSingleValuedInExpressionWithoutSpacesInWherePart() { $this->assertSqlGeneration( "SELECT u.name FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.id IN(46)", @@ -192,7 +195,7 @@ class SelectSqlGenerationTest extends \Doctrine\Tests\OrmTestCase ); } - public function testInExpressionSupportedInWherePart() + public function testSupportsMultipleValuedInExpressionInWherePart() { $this->assertSqlGeneration( 'SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.id IN (1, 2)', @@ -200,7 +203,7 @@ class SelectSqlGenerationTest extends \Doctrine\Tests\OrmTestCase ); } - public function testNotInExpressionSupportedInWherePart() + public function testSupportsNotInExpressionInWherePart() { $this->assertSqlGeneration( 'SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.id NOT IN (1)', @@ -208,7 +211,7 @@ class SelectSqlGenerationTest extends \Doctrine\Tests\OrmTestCase ); } - public function testConcatFunction() + public function testSupportsConcatFunctionForMysqlAndPostgresql() { $connMock = $this->_em->getConnection(); $orgPlatform = $connMock->getDatabasePlatform(); @@ -236,7 +239,7 @@ class SelectSqlGenerationTest extends \Doctrine\Tests\OrmTestCase $connMock->setDatabasePlatform($orgPlatform); } - public function testExistsExpressionInWhereWithCorrelatedSubquery() + public function testSupportsExistsExpressionInWherePartWithCorrelatedSubquery() { $this->assertSqlGeneration( 'SELECT u.id FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE EXISTS (SELECT p.phonenumber FROM Doctrine\Tests\Models\CMS\CmsPhonenumber p WHERE p.phonenumber = u.id)', @@ -244,7 +247,7 @@ class SelectSqlGenerationTest extends \Doctrine\Tests\OrmTestCase ); } - public function testMemberOfExpression() + public function testSupportsMemberOfExpression() { // "Get all users who have $phone as a phonenumber." (*cough* doesnt really make sense...) $q1 = $this->_em->createQuery('SELECT u.id FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE :param MEMBER OF u.phonenumbers'); @@ -281,19 +284,19 @@ class SelectSqlGenerationTest extends \Doctrine\Tests\OrmTestCase ); } - public function testCurrentDateFunction() + public function testSupportsCurrentDateFunction() { $q = $this->_em->createQuery('SELECT d.id FROM Doctrine\Tests\Models\Generic\DateTimeModel d WHERE d.datetime > current_date()'); $this->assertEquals('SELECT d0_.id AS id0 FROM date_time_model d0_ WHERE d0_.datetime > CURRENT_DATE', $q->getSql()); } - public function testCurrentTimeFunction() + public function testSupportsCurrentTimeFunction() { $q = $this->_em->createQuery('SELECT d.id FROM Doctrine\Tests\Models\Generic\DateTimeModel d WHERE d.time > current_time()'); $this->assertEquals('SELECT d0_.id AS id0 FROM date_time_model d0_ WHERE d0_.time > CURRENT_TIME', $q->getSql()); } - public function testCurrentTimestampFunction() + public function testSupportsCurrentTimestampFunction() { $q = $this->_em->createQuery('SELECT d.id FROM Doctrine\Tests\Models\Generic\DateTimeModel d WHERE d.datetime > current_timestamp()'); $this->assertEquals('SELECT d0_.id AS id0 FROM date_time_model d0_ WHERE d0_.datetime > CURRENT_TIMESTAMP', $q->getSql()); @@ -317,4 +320,4 @@ class SelectSqlGenerationTest extends \Doctrine\Tests\OrmTestCase ); }*/ -} \ No newline at end of file +} diff --git a/tests/Doctrine/Tests/ORM/Query/UpdateSqlGenerationTest.php b/tests/Doctrine/Tests/ORM/Query/UpdateSqlGenerationTest.php index bb5f155bf..20d7704a0 100644 --- a/tests/Doctrine/Tests/ORM/Query/UpdateSqlGenerationTest.php +++ b/tests/Doctrine/Tests/ORM/Query/UpdateSqlGenerationTest.php @@ -56,16 +56,19 @@ class UpdateSqlGenerationTest extends \Doctrine\Tests\OrmTestCase } } - public function testWithoutWhere() + public function testSupportsQueriesWithoutWhere() { $this->assertSqlGeneration( 'UPDATE Doctrine\Tests\Models\CMS\CmsUser u SET u.name = ?1', 'UPDATE cms_users SET name = ?' ); + } + + public function testSupportsMultipleFieldsWithoutWhere() + { $this->assertSqlGeneration( 'UPDATE Doctrine\Tests\Models\CMS\CmsUser u SET u.name = ?1, u.username = ?2', 'UPDATE cms_users SET name = ?, username = ?' ); } - }