Permalink
Browse files

Modify module generator test suit for non-matching module/url/route n…

…ames
  • Loading branch information...
1 parent ce6aa33 commit 228eb65e9c1d6fa834311e853789761b0f0f8873 @e1himself e1himself committed Feb 17, 2013
@@ -0,0 +1,24 @@
+<?php
+
+/*
+ * This file is part of the symfony package.
+ * (c) Fabien Potencier <fabien.potencier@symfony-project.com>
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+$app = 'crud';
+$fixtures = 'fixtures/fixtures.yml';
+if (!include(dirname(__FILE__).'/../../bootstrap/functional.php'))
+{
+ return;
+}
+
+require_once(dirname(__FILE__).'/crudBrowser.class.php');
+
+$b = new CrudBrowser();
+$b->browse(array('with-show', 'route-prefix=acme_article'), array(
+ 'urlPrefix' => 'articles',
+ 'moduleName' => 'article_backend',
+));
@@ -11,23 +11,33 @@
class CrudBrowser extends sfTestBrowser
{
protected
+ $model = 'Article',
$urlPrefix = 'article',
+ $moduleName = 'article',
$singularName = 'Article',
$pluralName = 'Articles',
$projectDir = '';
- public function setup($options)
+ public function setup($options, $parameters = array())
{
$this->projectDir = dirname(__FILE__).'/../fixtures';
$this->cleanup();
+ foreach (array('model', 'urlPrefix', 'moduleName', 'singularName', 'pluralName', 'projectDir') as $param)
+ {
+ if (isset($parameters[$param]))
+ {
+ $this->$param = $parameters[$param];
+ }
+ }
+
chdir($this->projectDir);
$task = new sfPropelGenerateModuleTask(new sfEventDispatcher(), new sfFormatter());
$options[] = 'env=test';
$options[] = 'singular='.$this->singularName;
$options[] = 'plural='.$this->pluralName;
$options[] = '--non-verbose-templates';
- $task->run(array('crud', 'article', 'Article'), $options);
+ $task->run(array('crud', $this->moduleName, $this->model), $options);
require_once($this->projectDir.'/config/ProjectConfiguration.class.php');
sfContext::createInstance(ProjectConfiguration::getApplicationConfiguration('crud', 'test', true, $this->projectDir));
@@ -42,16 +52,16 @@ public function teardown()
return $this;
}
- public function browse($options)
+ public function browse($options, $parameters = array())
{
- $options = $this->setup($options);
+ $options = $this->setup($options, $parameters);
// list page
$this->
info('list page')->
get('/'.$this->urlPrefix)->
with('request')->begin()->
- isParameter('module', $this->urlPrefix)->
+ isParameter('module', $this->moduleName)->
isParameter('action', 'index')->
end()->
with('response')->begin()->
@@ -89,7 +99,7 @@ public function browse($options)
info('create page')->
click('New')->
with('request')->begin()->
- isParameter('module', $this->urlPrefix)->
+ isParameter('module', $this->moduleName)->
isParameter('action', 'new')->
isParameter('id', null)->
end()->
@@ -129,7 +139,7 @@ public function browse($options)
info('go back to the list')->
click('Back to list')->
with('request')->begin()->
- isParameter('module', $this->urlPrefix)->
+ isParameter('module', $this->moduleName)->
isParameter('action', 'index')->
end()->
with('response')->isStatusCode(200)
@@ -148,7 +158,7 @@ public function browse($options)
$this->
with('request')->begin()->
- isParameter('module', $this->urlPrefix)->
+ isParameter('module', $this->moduleName)->
isParameter('action', 'edit')->
isParameter('id', 3)->
end()->
@@ -189,7 +199,7 @@ public function browse($options)
info('save / validation')->
click('Save', array('article' => $values))->
with('request')->begin()->
- isParameter('module', $this->urlPrefix)->
+ isParameter('module', $this->moduleName)->
isParameter('action', 'update')->
end()->
checkFormValues(array_merge($values, array(
@@ -222,7 +232,7 @@ public function browse($options)
info('go back to the list')->
click('Back to list')->
with('request')->begin()->
- isParameter('module', $this->urlPrefix)->
+ isParameter('module', $this->moduleName)->
isParameter('action', 'index')->
end()->
with('response')->isStatusCode(200)
@@ -234,15 +244,15 @@ public function browse($options)
get(sprintf('/%s/3/edit', $this->urlPrefix))->
click('Delete', array(), array('method' => 'delete', '_with_csrf' => true))->
with('request')->begin()->
- isParameter('module', $this->urlPrefix)->
+ isParameter('module', $this->moduleName)->
isParameter('action', 'delete')->
end()->
with('response')->begin()->
isRedirected()->
followRedirect()->
end()->
with('request')->begin()->
- isParameter('module', $this->urlPrefix)->
+ isParameter('module', $this->moduleName)->
isParameter('action', 'index')->
end()->
with('response')->isStatusCode(200)->
@@ -258,7 +268,7 @@ public function browse($options)
info('show page')->
get(sprintf('/%s/2', $this->urlPrefix))->
with('request')->begin()->
- isParameter('module', $this->urlPrefix)->
+ isParameter('module', $this->moduleName)->
isParameter('action', 'show')->
isParameter('id', 2)->
end()->
@@ -293,7 +303,7 @@ public function saveValues($options, $values, $id, $creation)
$this->
click('Save', array('article' => $values))->
with('request')->begin()->
- isParameter('module', $this->urlPrefix)->
+ isParameter('module', $this->moduleName)->
isParameter('action', $creation ? 'create' : 'update')->
end()->
with('response')->begin()->
@@ -304,7 +314,7 @@ public function saveValues($options, $values, $id, $creation)
isStatusCode(200)->
end()->
with('request')->begin()->
- isParameter('module', $this->urlPrefix)->
+ isParameter('module', $this->moduleName)->
isParameter('action', 'edit')->
isParameter('id', $id)->
end()->
@@ -1,3 +1,8 @@
+acme_article:
+ class: sfPropelRouteCollection
+ type: collection
+ options: { model: Article, module: article_backend, prefix_path: articles }
+
article:
class: sfPropelRouteCollection
type: collection

0 comments on commit 228eb65

Please sign in to comment.