Changeset 4866 for trunk/tests/Orm
- Timestamp:
- 08/31/08 19:27:16 (4 months ago)
- Location:
- trunk/tests/Orm
- Files:
-
- 1 added
- 2 modified
-
AllTests.php (modified) (2 diffs)
-
Associations/AllTests.php (added)
-
Query/LanguageRecognitionTest.php (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/Orm/AllTests.php
r4776 r4866 12 12 require_once 'Orm/Ticket/AllTests.php'; 13 13 require_once 'Orm/Entity/AllTests.php'; 14 require_once 'Orm/Associations/AllTests.php'; 14 15 15 16 // Tests … … 40 41 $suite->addTest(Orm_Entity_AllTests::suite()); 41 42 $suite->addTest(Orm_Ticket_AllTests::suite()); 43 $suite->addTest(Orm_Associations_AllTests::suite()); 42 44 43 45 return $suite; -
trunk/tests/Orm/Query/LanguageRecognitionTest.php
r4523 r4866 39 39 class Orm_Query_LanguageRecognitionTest extends Doctrine_OrmTestCase 40 40 { 41 public function assertValidDql($dql )41 public function assertValidDql($dql, $debug = false) 42 42 { 43 43 try { … … 46 46 $parserResult = $query->parse(); 47 47 } catch (Doctrine_Exception $e) { 48 if ($debug) { 49 echo $e->getTraceAsString() . PHP_EOL; 50 } 48 51 $this->fail($e->getMessage()); 49 52 } 50 53 } 51 54 52 public function assertInvalidDql($dql )55 public function assertInvalidDql($dql, $debug = false) 53 56 { 54 57 try { … … 60 63 $this->fail('No syntax errors were detected, when syntax errors were expected'); 61 64 } catch (Doctrine_Exception $e) { 65 //echo $e->getMessage() . PHP_EOL; 66 if ($debug) { 67 echo $e->getMessage() . PHP_EOL; 68 echo $e->getTraceAsString() . PHP_EOL; 69 } 62 70 // It was expected! 63 71 } … … 352 360 $this->assertValidDql("SELECT * FROM CmsUser u WHERE u.name NOT BETWEEN 'jepso' AND 'zYne'"); 353 361 } 354 /* 355 public function testAllExpression()362 363 /* public function testAllExpressionWithCorrelatedSubquery() 356 364 { 357 365 // We need existant classes here, otherwise semantical will always fail 358 $this->assertValidDql('SELECT * FROM Employee e WHERE e.salary > ALL (SELECT m.salary FROM Manager m WHERE m.department = e.department)');359 } 360 361 public function testAnyExpression ()366 $this->assertValidDql('SELECT * FROM CompanyEmployee e WHERE e.salary > ALL (SELECT m.salary FROM CompanyManager m WHERE m.department = e.department)', true); 367 } 368 369 public function testAnyExpressionWithCorrelatedSubquery() 362 370 { 363 371 // We need existant classes here, otherwise semantical will always fail … … 365 373 } 366 374 367 public function testSomeExpression ()375 public function testSomeExpressionWithCorrelatedSubquery() 368 376 { 369 377 // We need existant classes here, otherwise semantical will always fail … … 386 394 } 387 395 396 /** 397 * TODO: Hydration can't deal with this currently but it should be allowed. 398 * Also, generated SQL looks like: "... FROM cms_user, cms_article ..." which 399 * may not work on all dbms. 400 * 401 * The main use case for this generalized style of join is when a join condition 402 * does not involve a foreign key relationship that is mapped to an entity relationship. 403 */ 404 public function testImplicitJoinWithCartesianProductAndConditionInWhere() 405 { 406 $this->assertValidDql("SELECT u.*, a.* FROM CmsUser u, CmsArticle a WHERE u.name = a.topic"); 407 } 408 409 public function testImplicitJoinInWhereOnSingleValuedAssociationPathExpression() 410 { 411 // This should be allowed because avatar is a single-value association. 412 // SQL: SELECT ... FROM forum_user fu INNER JOIN forum_avatar fa ON fu.avatar_id = fa.id WHERE fa.id = ? 413 $this->assertValidDql("SELECT u.* FROM ForumUser u WHERE u.avatar.id = ?"); 414 } 415 416 public function testImplicitJoinInWhereOnCollectionValuedPathExpression() 417 { 418 // This should be forbidden, because articles is a collection 419 $this->assertInvalidDql("SELECT u.* FROM CmsUser u WHERE u.articles.title = ?"); 420 } 388 421 389 422 public function testInvalidSyntaxIsRejected() 390 423 { 391 424 $this->assertInvalidDql("FOOBAR CmsUser"); 392 393 425 $this->assertInvalidDql("DELETE FROM CmsUser.articles"); 394 395 426 $this->assertInvalidDql("DELETE FROM CmsUser cu WHERE cu.articles.id > ?"); 427 $this->assertInvalidDql("SELECT user FROM CmsUser user"); 428 429 // Error message here is: Relation 'comments' does not exist in component 'CmsUser' 430 // This means it is intepreted as: 431 // SELECT u.* FROM CmsUser u JOIN u.articles JOIN u.comments 432 // This seems wrong. "JOIN u.articles.comments" should not be allowed. 433 $this->assertInvalidDql("SELECT u.* FROM CmsUser u JOIN u.articles.comments"); 434 435 // Currently UNDEFINED OFFSET error 436 $this->assertInvalidDql("SELECT * FROM CmsUser.articles.comments"); 396 437 } 397 438