Development

Changeset 19842

You must first sign up to be able to contribute.

Changeset 19842

Show
Ignore:
Timestamp:
07/03/09 14:23:36 (9 months ago)
Author:
nicolas
Message:

[sfDoctrineEditableComponentPlugin] fixed functional test configuration

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • plugins/sfDoctrineEditableComponentPlugin/trunk/config/routing.yml

    r19821 r19842  
    22  url:   /editable_component_service 
    33  param: { module: sfEditableComponent, action: update } 
     4 
     5editable_component_auth_test_service: 
     6  url:   /editable_component_auth_test_service 
     7  param: { module: sfEditableComponentTestUtility, action: auth } 
  • plugins/sfDoctrineEditableComponentPlugin/trunk/config/sfDoctrineEditableComponentPluginConfiguration.class.php

    r19832 r19842  
    1414  public function configure() 
    1515  { 
    16     $this->dispatcher->connect('context.load_factories', array($this, 'listendForContextLoadFactories')); 
     16    $this->dispatcher->connect('context.load_factories', array($this, 'listenForContextLoadFactories')); 
    1717  } 
    1818   
    19   public function listendForContextLoadFactories() 
     19  public function listenForContextLoadFactories() 
    2020  { 
    21     sfConfig::set('sf_enabled_modules', array_merge(sfConfig::get('sf_enabled_modules', array()), array('sfEditableComponent'))); 
     21    $pluginModules = array('sfEditableComponent'); 
     22     
     23    // Enables the auth testing service utility only in 'test' env 
     24    if ('test' === sfConfig::get('sf_environment')) 
     25    { 
     26      $pluginModules[] = 'sfEditableComponentTestUtility'; 
     27    } 
     28     
     29    sfConfig::set('sf_enabled_modules', array_merge(sfConfig::get('sf_enabled_modules', array()), $pluginModules)); 
    2230  } 
    2331} 
  • plugins/sfDoctrineEditableComponentPlugin/trunk/lib/model/doctrine/PluginsfEditableComponentTable.class.php

    r19832 r19842  
    2121  static function updateComponent($name, $content, $type = null, $namespace = null) 
    2222  { 
    23     $component = Doctrine::getTable('sfEditableComponent')->getEditableComponent($name, $type, $namespace); 
     23    $component = Doctrine::getTable('sfEditableComponent')->getComponent($name, $type, $namespace); 
    2424     
    2525    // FIXME: filter html content 
     
    3939   * @return sfEditableComponent 
    4040   */ 
    41   static public function getEditableComponent($name, $type = null, $namespace = null, $createAndSave = true) 
     41  static public function getComponent($name, $type = null, $namespace = null, $createAndSave = true) 
    4242  { 
    4343    if (is_null($type)) 
  • plugins/sfDoctrineEditableComponentPlugin/trunk/modules/sfEditableComponent/actions/components.class.php

    r19821 r19842  
    1515  public function executeShow() 
    1616  { 
    17     $this->component = sfEditableComponentTable::getEditableComponent($this->name, $this->type, $this->namespace); 
     17    $this->component = sfEditableComponentTable::getComponent($this->name, $this->type, $this->namespace); 
    1818  } 
    1919} 
  • plugins/sfDoctrineEditableComponentPlugin/trunk/test/functional/sfEditableComponentModuleTest.php

    r19832 r19842  
    11<?php 
    2  
     2$app = 'backend'; 
    33require_once dirname(__FILE__).'/../bootstrap.php'; 
    44 
     5$adminCredential = sfConfig::get('app_sfDoctrineEditableComponentPlugin_admin_credential', 'editable_content_admin'); 
     6 
    57$browser = new sfTestFunctional(new sfBrowser()); 
     8$browser->setTester('doctrine', 'sfTesterDoctrine'); 
     9 
     10Doctrine::getTable('sfEditableComponent')->createQuery('e')->delete()->execute(); 
     11 
     12# Init session 
     13$browser->info(sprintf('Testing from app "%s"', $app))->get('/'); 
     14 
     15if (class_exists('sfGuardSecurityUser', true) && $browser->getUser() instanceof sfGuardSecurityUser) 
     16{ 
     17  $browser->test()->comment(sprintf('This plugin cannot be tested using the "%s" app configuration', $app)); 
     18  $browser->test()->comment('because it uses the sfGuardSecurityUser as the user class'); 
     19  $browser->test()->comment('Please try to use another app'); 
     20  $browser->shutdown(); 
     21  exit(0); 
     22} 
    623 
    724$browser-> 
    8   info(sprintf('Testing from app "%s"', $app))-> 
    925  info('Testing service in unauthenticated mode')-> 
     26   
     27    get('/editable_component_service')-> 
     28    with('response')->begin()-> 
     29      isStatusCode(403)-> 
     30    end()-> 
     31    with('doctrine')->begin()-> 
     32      check('sfEditableComponent', array(), 0)-> 
     33    end()-> 
    1034 
    11   get('/')-> 
    12   with('user')->begin()-> 
    13     hasCredential(sfConfig::get('app_sfDoctrineEditableComponentPlugin_admin_credential', 'editable_content_admin'), false)-> 
    14   end()-> 
     35    post('/editable_component_service')-> 
     36    with('response')->begin()-> 
     37      isStatusCode(403)-> 
     38    end()-> 
     39    with('doctrine')->begin()-> 
     40      check('sfEditableComponent', array(), 0)-> 
     41    end()-> 
    1542   
    16   get('/editable_component_service')-> 
    17   with('response')->begin()-> 
    18     isStatusCode(403)-> 
    19   end()-> 
     43    post('/editable_component_service', array('id' => 'foo'))-> 
     44    with('response')->begin()-> 
     45      isStatusCode(403)-> 
     46    end()-> 
     47    with('doctrine')->begin()-> 
     48      check('sfEditableComponent', array(), 0)-> 
     49    end()-> 
     50   
     51    post('/editable_component_service', array('id' => 'foo', 'value' => 'bar'))-> 
     52    with('response')->begin()-> 
     53      isStatusCode(403)-> 
     54    end()-> 
     55    with('doctrine')->begin()-> 
     56      check('sfEditableComponent', array(), 0)-> 
     57    end()-> 
     58   
     59  info('Testing service in authenticated mode')-> 
     60   
     61    get('/editable_component_auth_test_service?authenticate&credential='.$adminCredential)-> 
     62    with('user')->hasCredential($adminCredential)-> 
     63   
     64    get('/editable_component_service')-> 
     65    with('response')->begin()-> 
     66      isStatusCode(404)-> 
     67    end()-> 
     68    with('doctrine')->begin()-> 
     69      check('sfEditableComponent', array(), 0)-> 
     70    end()-> 
    2071 
    21   post('/editable_component_service')-> 
    22   with('response')->begin()-> 
    23     isStatusCode(403)-> 
    24   end()-> 
     72    post('/editable_component_service')-> 
     73    with('response')->begin()-> 
     74      isStatusCode(404)-> 
     75    end()-> 
     76    with('doctrine')->begin()-> 
     77      check('sfEditableComponent', array(), 0)-> 
     78    end()-> 
    2579   
    26   post('/editable_component_service', array('id' => 'foo'))-> 
    27   with('response')->begin()-> 
    28     isStatusCode(403)-> 
    29   end()-> 
     80    post('/editable_component_service', array('id' => 'foo'))-> 
     81    with('response')->begin()-> 
     82      isStatusCode(404)-> 
     83    end()-> 
     84    with('doctrine')->begin()-> 
     85      check('sfEditableComponent', array(), 0)-> 
     86    end()-> 
    3087   
    31   post('/editable_component_service', array('id' => 'foo', 'value' => 'bar'))-> 
    32   with('response')->begin()-> 
    33     isStatusCode(403)-> 
    34   end()-> 
    35    
    36   info('Testing service in authenticated mode'); 
    37  
    38 $browser->getUser()->addCredential(sfConfig::get('app_sfDoctrineEditableComponentPlugin_admin_credential', 'editable_content_admin')); 
    39  
    40 $browser-> 
    41   with('user')->begin()-> 
    42     hasCredential(sfConfig::get('app_sfDoctrineEditableComponentPlugin_admin_credential', 'editable_content_admin'))-> 
    43   end()-> 
    44    
    45   get('/editable_component_service')-> 
    46   with('response')->begin()-> 
    47     isStatusCode(404)-> 
    48   end()-> 
    49  
    50   post('/editable_component_service')-> 
    51   with('response')->begin()-> 
    52     isStatusCode(404)-> 
    53   end()-> 
    54    
    55   post('/editable_component_service', array('id' => 'foo'))-> 
    56   with('response')->begin()-> 
    57     isStatusCode(404)-> 
    58   end()-> 
    59    
    60   post('/editable_component_service', array('id' => 'foo', 'value' => 'bar'))-> 
    61   with('response')->begin()-> 
    62     isStatusCode(200)-> 
    63   end()-> 
     88    post('/editable_component_service', array('id' => 'foo', 'value' => 'bar'))-> 
     89    with('response')->begin()-> 
     90      isStatusCode(200)-> 
     91      contains('bar')-> 
     92    end()-> 
     93    with('doctrine')->begin()-> 
     94      check('sfEditableComponent', array('name' => 'foo', 'namespace' => 'default', 'type' => 'html'), 1)-> 
     95    end()-> 
     96     
     97    post('/editable_component_service', array('id' => 'foo', 'value' => 'baz'))-> 
     98    with('response')->begin()-> 
     99      isStatusCode(200)-> 
     100      contains('baz')-> 
     101    end()-> 
     102    with('doctrine')->begin()-> 
     103      check('sfEditableComponent', array('name' => 'foo', 'namespace' => 'default', 'type' => 'html', 'content' => 'bar'), 0)-> 
     104      check('sfEditableComponent', array('name' => 'foo', 'namespace' => 'default', 'type' => 'html'), 1)-> 
     105    end()-> 
    64106   
    65107  shutdown() 
  • plugins/sfDoctrineEditableComponentPlugin/trunk/test/unit/model/doctrine/PluginsfEditableComponentTableTest.php

    r19832 r19842  
    66 
    77// removes old test records 
    8 PluginsfEditableComponentTable::getEditableComponent('bar', 'html', 'foo')->delete(); 
    9 PluginsfEditableComponentTable::getEditableComponent('bar2', 'html', 'foo')->delete(); 
     8Doctrine::getTable('sfEditableComponent')->createQuery('e')->delete()->execute(); 
    109 
    11 // getEditableComponent() 
    12 $t->diag('getEditableComponent()'); 
    13 $c = PluginsfEditableComponentTable::getEditableComponent('bar', 'html', 'foo'); 
    14 $t->isa_ok($c, 'sfEditableComponent', 'getEditableComponent() returns a sfEditableComponent when createAndSave=true'); 
    15 $t->is($c->getName(), 'bar', 'getEditableComponent() saves the name when createAndSave=true'); 
    16 $t->is($c->getNamespace(), 'foo', 'getEditableComponent() saves the namespace when createAndSave=true'); 
    17 $t->is($c->getType(), 'html', 'getEditableComponent() saves the type when createAndSave=true'); 
    18 $t->is($c->exists(), true, 'getEditableComponent() saved the object when createAndSave=true'); 
     10// getComponent() 
     11$t->diag('getComponent()'); 
     12$c = PluginsfEditableComponentTable::getComponent('bar', 'html', 'foo'); 
     13$t->isa_ok($c, 'sfEditableComponent', 'getComponent() returns a sfEditableComponent when createAndSave=true'); 
     14$t->is($c->getName(), 'bar', 'getComponent() saves the name when createAndSave=true'); 
     15$t->is($c->getNamespace(), 'foo', 'getComponent() saves the namespace when createAndSave=true'); 
     16$t->is($c->getType(), 'html', 'getComponent() saves the type when createAndSave=true'); 
     17$t->is($c->exists(), true, 'getComponent() saved the object when createAndSave=true'); 
    1918 
    20 $c2 = PluginsfEditableComponentTable::getEditableComponent('bar', 'html', 'foo'); 
    21 $t->is($c2->getId(), $c->getId(), 'getEditableComponent() do not create duplicate components'); 
     19$c2 = PluginsfEditableComponentTable::getComponent('bar', 'html', 'foo'); 
     20$t->is($c2->getId(), $c->getId(), 'getComponent() do not create duplicate components'); 
    2221 
    23 $c = PluginsfEditableComponentTable::getEditableComponent('bar2', 'html', 'foo', false); 
    24 $t->isa_ok($c, 'sfEditableComponent', 'getEditableComponent() returns a sfEditableComponent when createAndSave=false'); 
    25 $t->is($c->getName(), 'bar2', 'getEditableComponent() saves the name when createAndSave=false'); 
    26 $t->is($c->getNamespace(), 'foo', 'getEditableComponent() saves the namespace when createAndSave=false'); 
    27 $t->is($c->getType(), 'html', 'getEditableComponent() saves the type when createAndSave=false'); 
    28 $t->is($c->exists(), false, 'getEditableComponent() did not save the object when createAndSave=false'); 
     22$c = PluginsfEditableComponentTable::getComponent('bar2', 'html', 'foo', false); 
     23$t->isa_ok($c, 'sfEditableComponent', 'getComponent() returns a sfEditableComponent when createAndSave=false'); 
     24$t->is($c->getName(), 'bar2', 'getComponent() saves the name when createAndSave=false'); 
     25$t->is($c->getNamespace(), 'foo', 'getComponent() saves the namespace when createAndSave=false'); 
     26$t->is($c->getType(), 'html', 'getComponent() saves the type when createAndSave=false'); 
     27$t->is($c->exists(), false, 'getComponent() did not save the object when createAndSave=false'); 
    2928 
    3029// updateComponent() 
    3130$t->diag('updateComponent()'); 
    3231PluginsfEditableComponentTable::updateComponent('bar2', 'my beautiful content', 'html', 'foo'); 
    33 $c = PluginsfEditableComponentTable::getEditableComponent('bar2', 'html', 'foo', false); 
     32$c = PluginsfEditableComponentTable::getComponent('bar2', 'html', 'foo', false); 
    3433$t->is($c->getContent(), 'my beautiful content', 'updateComponent() updates component content'); 

The Sensio Labs Network

Since 1998, Sensio Labs has been promoting the Open-Source software movement by providing quality web application development, training, consulting.
Sensio Labs also supports several large Open-Source projects.