Esempio n. 1
0
 public function getContext($forceReload = false)
 {
     parent::getContext($forceReload);
     sfPropel::initialize($this->context->getEventDispatcher());
     return $this->context;
 }
 * For the full copyright and license information, please view the LICENSE.yahoo
 * file that was distributed with this source code.
 */
$sf_symfony_lib_dir = '/Users/dustin/projects/symfony/branch/1.1/lib';
$sf_root_dir = realpath(dirname(__FILE__) . '/../fixtures/project');
require_once $sf_root_dir . '/config/ProjectConfiguration.class.php';
$configuration = sfProjectConfiguration::getApplicationConfiguration('dimensions', 'test', true, $sf_root_dir);
sfContext::createInstance($configuration);
$sf_symfony_lib_dir = sfConfig::get('sf_symfony_lib_dir');
// remove all cache
sfToolkit::clearDirectory(sfConfig::get('sf_app_cache_dir'));
// load lime
require_once $configuration->getSymfonyLibDir() . '/vendor/lime/lime.php';
$b = new sfTestBrowser();
$t = $b->test();
$c = $b->getContext()->getConfiguration();
$t->diag('checking default configuration dimensions');
$b->get('/test2')->isStatusCode(200)->checkResponseElement('title', '/symfony project/')->checkResponseElement('body', '/generic view/')->checkResponseElement('body', '/generic action/');
$t->is($c->getConfigPaths('config/app.yml'), array($sf_root_dir . '/apps/dimensions/config/app.yml', $sf_root_dir . '/apps/dimensions/config/sp1/app.yml'), '->getConfigPaths() returns correct module level configuration files given name');
$t->is($c->getTemplatePath('test', 'indexSuccess.php'), $sf_root_dir . '/apps/dimensions/modules/test/templates/indexSuccess.php', '->getTemplatePath() returns correct path to template given module name and template name');
$t->diag('checking backwards compatability by setting dimension null');
$c->setDimension(null);
$t->is($c->getTemplateDirs('test'), array($sf_root_dir . '/apps/dimensions/modules/test/templates', $sf_root_dir . '/plugins/ysfDimensionsTestPlugin/modules/test/templates', $sf_symfony_lib_dir . '/controller/test/templates', $sf_root_dir . '/cache/dimensions/test/modules/autoTest/templates'), '->getTemplateDirs() checking template path returns correct with out dimension');
$t->is($c->getConfigPaths('modules/test/config/view.yml'), array($sf_symfony_lib_dir . '/config/config/view.yml', $sf_root_dir . '/apps/dimensions/config/view.yml', $sf_root_dir . '/plugins/ysfDimensionsTestPlugin/modules/test/config/view.yml', $sf_root_dir . '/apps/dimensions/modules/test/config/view.yml'), '->getConfigPaths() checking template path returns correct with out dimension');
$b->get('/test2')->isStatusCode(200)->checkResponseElement('title', '/symfony project/')->checkResponseElement('body', '/generic view/')->checkResponseElement('body', '/generic action/');
// setup 1st test dimension
$c->setDimension(array('culture' => 'fr', 'skin' => 'corp', 'host' => 'sp1'));
$t->diag('checking all project level configuration methods return correct paths with dimensions');
// ysfProjectConfiguration
// model
$t->is($c->getModelDirs(), array($sf_root_dir . '/lib/model/fr', $sf_root_dir . '/lib/model', $sf_root_dir . '/plugins/ysfDimensionsTestPlugin/lib/model/fr', $sf_root_dir . '/plugins/ysfDimensionsTestPlugin/lib/model'), '->getModelDirs() return correct directory cascade with dimensions');
  with('request')->begin()->
    isParameter('module', 'invoice')->
    isParameter('action', 'index')->
  end()->

  with('response')->begin()->
    isStatusCode(200)->
    checkElement('body', '!/This is a temporary page/')->
  end()
;
*/
$b = new sfTestBrowser();
$b->initialize();
$b->get('/customer/new')->setField('customer[name]', 'dummy')->click('Save')->with('response')->begin()->isRedirected()->followRedirect()->end()->with('request')->begin()->isParameter('name', 'dummy')->isParameter('module', 'customer')->isParameter('action', 'edit')->end();
$request = $b->getRequest();
$context = $b->getContext();
$response = $b->getResponse();
foreach ($request as $key => $value) {
    echo $key . "=>" . $value;
}
/*
//--------------------calling pages--------------------
// Create a new test browser
$b = new sfTestBrowser();
$b->initialize();
 
$b->get('/foobar/show/id/1');                   // GET request
$b->post('/foobar/show', array('id' => 1));     // POST request
 
// The get() and post() methods are shortcuts to the call() method
$b->call('/foobar/show/id/1', 'get');