Changeset 10805 for plugins/sfPropelFinderPlugin/test
- Timestamp:
- 08/12/08 14:21:31 (3 months ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
plugins/sfPropelFinderPlugin/test/unit/sfDoctrineFinderTest.php
r10780 r10805 73 73 Doctrine_Query::create()->delete()->from('DArticle')->execute(); 74 74 75 $t = new lime_test( 92, new lime_output_color());75 $t = new lime_test(103, new lime_output_color()); 76 76 77 77 $t->diag('find()'); … … 425 425 $articles = sfDoctrineFinder::from('DArticle')->where('Title', 'is not null', null)->find(); 426 426 $t->is(count($articles), 3, 'where() accepts a text comparator and is permissive on syntax'); 427 $articles = sfDoctrineFinder::from('DArticle')->where('Title', ' in', array('abc', 'def'))->find();427 $articles = sfDoctrineFinder::from('DArticle')->where('Title', 'in', array('abc', 'def'))->find(); 428 428 $t->is(count($articles), 2, 'where() accepts a "in" comparator'); 429 429 $articles = sfDoctrineFinder::from('DArticle')->where('Title', 'not in', array('abc', 'def'))->find(); 430 $t->is(count($articles), 1, 'where() accepts a "not in" comparator'); 430 431 try 431 432 { … … 606 607 $t->is( 607 608 $finder->getLatestQuery(), 608 $baseSelect . "(d.title = 'foo ' OR d.title = 'bar') AND d.title = 'foobar'",609 $baseSelect . "(d.title = 'foobar' AND (d.title = 'foo' OR d.title = 'bar'))", 609 610 'combine() clauses live well with the usual conditions' 610 611 ); … … 618 619 $t->is( 619 620 $finder->getLatestQuery(), 620 $baseSelect . "( d.title = 'foo' OR d.title = 'bar') AND d.title = 'foobar'",621 $baseSelect . "((d.title = 'foo' OR d.title = 'bar') AND d.title = 'foobar')", 621 622 'combine() clauses live well with the usual conditions and appear ordered as they were called' 622 623 ); … … 661 662 'combine() can combine more than two conditions' 662 663 ); 664 665 $t->diag('limit() and offset()'); 666 667 Doctrine_Query::create()->delete()->from('DArticle')->execute(); 668 $article1 = new DArticle(); 669 $article1->setTitle('abc'); 670 $article1->save(); 671 $article2 = new DArticle(); 672 $article2->setTitle('def'); 673 $article2->save(); 674 $article3 = new DArticle(); 675 $article3->setTitle('bbc'); 676 $article3->save(); 677 678 $articles = sfDoctrineFinder::from('DArticle')->limit(1)->find(); 679 $t->is(count($articles), 1, 'limit() adds a limit to the SQL clause'); 680 $article = $articles[0]; 681 $t->is($article->getTitle(), 'abc', 'limit() adds a limit to the SQL clause'); 682 $articles = sfDoctrineFinder::from('DArticle')->limit(2)->find(); 683 $t->is(count($articles), 2, 'limit() adds a limit to the SQL clause'); 684 $article = $articles[0]; 685 $t->is($article->getTitle(), 'abc', 'limit() adds a limit to the SQL clause'); 686 $article = $articles[1]; 687 $t->is($article->getTitle(), 'def', 'limit() adds a limit to the SQL clause'); 688 689 $articles = sfDoctrineFinder::from('DArticle')->offset(1)->find(); 690 $t->is(count($articles), 2, 'offset() adds an offset to the SQL clause'); 691 $article = $articles[0]; 692 $t->is($article->getTitle(), 'def', 'offset() adds an offset to the SQL clause'); 693 $article = $articles[1]; 694 $t->is($article->getTitle(), 'bbc', 'offset() adds an offset to the SQL clause'); 695 696 $articles = sfDoctrineFinder::from('DArticle')->offset(1)->limit(1)->find(); 697 $t->is(count($articles), 1, 'limit() and offset() can be combined'); 698 $article = $articles[0]; 699 $t->is($article->getTitle(), 'def', 'limit() and offset() can be combined'); plugins/sfPropelFinderPlugin/test/unit/sfPropelFinderTest.php
r10785 r10805 64 64 ArticlePeer::doDeleteAll(); 65 65 66 $t = new lime_test(1 22, new lime_output_color());66 $t = new lime_test(133, new lime_output_color()); 67 67 68 68 $t->diag('find()'); … … 409 409 $articles = sfPropelFinder::from('Article')->where('Title', 'is not null', null)->find(); 410 410 $t->is(count($articles), 3, 'where() accepts a text comparator and is permissive on syntax'); 411 $articles = sfPropelFinder::from('Article')->where('Title', ' in', array('abc', 'def'))->find();411 $articles = sfPropelFinder::from('Article')->where('Title', 'in', array('abc', 'def'))->find(); 412 412 $t->is(count($articles), 2, 'where() accepts a "in" comparator'); 413 $articles = sfPropelFinder::from('Article')->where('Title', 'not in', array('abc', 'def'))->find(); 414 $t->is(count($articles), 1, 'where() accepts a "not in" comparator'); 413 415 try 414 416 { … … 640 642 ); 641 643 644 $t->diag('limit() and offset()'); 645 646 ArticlePeer::doDeleteAll(); 647 $article1 = new Article(); 648 $article1->setTitle('abc'); 649 $article1->save(); 650 $article2 = new Article(); 651 $article2->setTitle('def'); 652 $article2->save(); 653 $article3 = new Article(); 654 $article3->setTitle('bbc'); 655 $article3->save(); 656 657 $articles = sfPropelFinder::from('Article')->limit(1)->find(); 658 $t->is(count($articles), 1, 'limit() adds a limit to the SQL clause'); 659 $article = $articles[0]; 660 $t->is($article->getTitle(), 'abc', 'limit() adds a limit to the SQL clause'); 661 $articles = sfPropelFinder::from('Article')->limit(2)->find(); 662 $t->is(count($articles), 2, 'limit() adds a limit to the SQL clause'); 663 $article = $articles[0]; 664 $t->is($article->getTitle(), 'abc', 'limit() adds a limit to the SQL clause'); 665 $article = $articles[1]; 666 $t->is($article->getTitle(), 'def', 'limit() adds a limit to the SQL clause'); 667 668 $articles = sfPropelFinder::from('Article')->offset(1)->find(); 669 $t->is(count($articles), 2, 'offset() adds an offset to the SQL clause'); 670 $article = $articles[0]; 671 $t->is($article->getTitle(), 'def', 'offset() adds an offset to the SQL clause'); 672 $article = $articles[1]; 673 $t->is($article->getTitle(), 'bbc', 'offset() adds an offset to the SQL clause'); 674 675 $articles = sfPropelFinder::from('Article')->offset(1)->limit(1)->find(); 676 $t->is(count($articles), 1, 'limit() and offset() can be combined'); 677 $article = $articles[0]; 678 $t->is($article->getTitle(), 'def', 'limit() and offset() can be combined'); 642 679 643 680 $t->diag('relatedTo()');