Development

Changeset 10805 for plugins/sfPropelFinderPlugin/test

You must first sign up to be able to contribute.

Show
Ignore:
Timestamp:
08/12/08 14:21:31 (3 months ago)
Author:
francois
Message:

sfPropelFinderPlugin Minor fixes:

  • Implemented limit() and offset() in both sfPropelFinder and sfDoctrineFinder
  • Implemented not in comparison in sfDoctrineFinder::where()
  • Added finder_methods parameter in generator.yml
Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • plugins/sfPropelFinderPlugin/test/unit/sfDoctrineFinderTest.php

    r10780 r10805  
    7373Doctrine_Query::create()->delete()->from('DArticle')->execute(); 
    7474 
    75 $t = new lime_test(92, new lime_output_color()); 
     75$t = new lime_test(103, new lime_output_color()); 
    7676 
    7777$t->diag('find()'); 
     
    425425$articles = sfDoctrineFinder::from('DArticle')->where('Title', 'is not null', null)->find(); 
    426426$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(); 
    428428$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'); 
    430431try 
    431432{ 
     
    606607$t->is( 
    607608  $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'))", 
    609610  'combine() clauses live well with the usual conditions' 
    610611); 
     
    618619$t->is( 
    619620  $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')", 
    621622  'combine() clauses live well with the usual conditions and appear ordered as they were called' 
    622623); 
     
    661662  'combine() can combine more than two conditions' 
    662663); 
     664 
     665$t->diag('limit() and offset()'); 
     666 
     667Doctrine_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  
    6464ArticlePeer::doDeleteAll(); 
    6565 
    66 $t = new lime_test(122, new lime_output_color()); 
     66$t = new lime_test(133, new lime_output_color()); 
    6767 
    6868$t->diag('find()'); 
     
    409409$articles = sfPropelFinder::from('Article')->where('Title', 'is not null', null)->find(); 
    410410$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(); 
    412412$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'); 
    413415try 
    414416{ 
     
    640642); 
    641643 
     644$t->diag('limit() and offset()'); 
     645 
     646ArticlePeer::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'); 
    642679 
    643680$t->diag('relatedTo()');