Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding files to be compared against bake generated files, fixing bake…
… templates in the meantime. Writing assertContains() or assertRegExp for generated code is a pain and making the test cover most part of it is very difficult. Things like: ``` } else { } ``` Are very easy to happen (which was the case) and was not being covered by the test.
- Loading branch information
Showing
8 changed files
with
265 additions
and
85 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
91 changes: 91 additions & 0 deletions
91
lib/Cake/Test/bake_compare/Controller/ActionsUsingSessions.ctp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
|
||
/** | ||
* index method | ||
* | ||
* @return void | ||
*/ | ||
public function index() { | ||
$this->BakeArticle->recursive = 0; | ||
$this->set('bakeArticles', $this->Paginator->paginate()); | ||
} | ||
|
||
/** | ||
* view method | ||
* | ||
* @throws NotFoundException | ||
* @param string $id | ||
* @return void | ||
*/ | ||
public function view($id = null) { | ||
if (!$this->BakeArticle->exists($id)) { | ||
throw new NotFoundException(__('Invalid bake article')); | ||
} | ||
$options = array('conditions' => array('BakeArticle.' . $this->BakeArticle->primaryKey => $id)); | ||
$this->set('bakeArticle', $this->BakeArticle->find('first', $options)); | ||
} | ||
|
||
/** | ||
* add method | ||
* | ||
* @return void | ||
*/ | ||
public function add() { | ||
if ($this->request->is('post')) { | ||
$this->BakeArticle->create(); | ||
if ($this->BakeArticle->save($this->request->data)) { | ||
$this->Session->setFlash(__('The bake article has been saved.')); | ||
return $this->redirect(array('action' => 'index')); | ||
} else { | ||
$this->Session->setFlash(__('The bake article could not be saved. Please, try again.')); | ||
} | ||
} | ||
$bakeTags = $this->BakeArticle->BakeTag->find('list'); | ||
$this->set(compact('bakeTags')); | ||
} | ||
|
||
/** | ||
* edit method | ||
* | ||
* @throws NotFoundException | ||
* @param string $id | ||
* @return void | ||
*/ | ||
public function edit($id = null) { | ||
if (!$this->BakeArticle->exists($id)) { | ||
throw new NotFoundException(__('Invalid bake article')); | ||
} | ||
if ($this->request->is('post') || $this->request->is('put')) { | ||
if ($this->BakeArticle->save($this->request->data)) { | ||
$this->Session->setFlash(__('The bake article has been saved.')); | ||
return $this->redirect(array('action' => 'index')); | ||
} else { | ||
$this->Session->setFlash(__('The bake article could not be saved. Please, try again.')); | ||
} | ||
} else { | ||
$options = array('conditions' => array('BakeArticle.' . $this->BakeArticle->primaryKey => $id)); | ||
$this->request->data = $this->BakeArticle->find('first', $options); | ||
} | ||
$bakeTags = $this->BakeArticle->BakeTag->find('list'); | ||
$this->set(compact('bakeTags')); | ||
} | ||
|
||
/** | ||
* delete method | ||
* | ||
* @throws NotFoundException | ||
* @param string $id | ||
* @return void | ||
*/ | ||
public function delete($id = null) { | ||
$this->BakeArticle->id = $id; | ||
if (!$this->BakeArticle->exists()) { | ||
throw new NotFoundException(__('Invalid bake article')); | ||
} | ||
$this->request->onlyAllow('post', 'delete'); | ||
if ($this->BakeArticle->delete()) { | ||
$this->Session->setFlash(__('The bake article has been deleted.')); | ||
} else { | ||
$this->Session->setFlash(__('The bake article could not be deleted. Please, try again.')); | ||
} | ||
return $this->redirect(array('action' => 'index')); | ||
} |
84 changes: 84 additions & 0 deletions
84
lib/Cake/Test/bake_compare/Controller/ActionsWithNoSessions.ctp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
|
||
/** | ||
* index method | ||
* | ||
* @return void | ||
*/ | ||
public function index() { | ||
$this->BakeArticle->recursive = 0; | ||
$this->set('bakeArticles', $this->Paginator->paginate()); | ||
} | ||
|
||
/** | ||
* view method | ||
* | ||
* @throws NotFoundException | ||
* @param string $id | ||
* @return void | ||
*/ | ||
public function view($id = null) { | ||
if (!$this->BakeArticle->exists($id)) { | ||
throw new NotFoundException(__('Invalid bake article')); | ||
} | ||
$options = array('conditions' => array('BakeArticle.' . $this->BakeArticle->primaryKey => $id)); | ||
$this->set('bakeArticle', $this->BakeArticle->find('first', $options)); | ||
} | ||
|
||
/** | ||
* add method | ||
* | ||
* @return void | ||
*/ | ||
public function add() { | ||
if ($this->request->is('post')) { | ||
$this->BakeArticle->create(); | ||
if ($this->BakeArticle->save($this->request->data)) { | ||
return $this->flash(__('The bake article has been saved.'), array('action' => 'index')); | ||
} | ||
} | ||
$bakeTags = $this->BakeArticle->BakeTag->find('list'); | ||
$this->set(compact('bakeTags')); | ||
} | ||
|
||
/** | ||
* edit method | ||
* | ||
* @throws NotFoundException | ||
* @param string $id | ||
* @return void | ||
*/ | ||
public function edit($id = null) { | ||
if (!$this->BakeArticle->exists($id)) { | ||
throw new NotFoundException(__('Invalid bake article')); | ||
} | ||
if ($this->request->is('post') || $this->request->is('put')) { | ||
if ($this->BakeArticle->save($this->request->data)) { | ||
return $this->flash(__('The bake article has been saved.'), array('action' => 'index')); | ||
} | ||
} else { | ||
$options = array('conditions' => array('BakeArticle.' . $this->BakeArticle->primaryKey => $id)); | ||
$this->request->data = $this->BakeArticle->find('first', $options); | ||
} | ||
$bakeTags = $this->BakeArticle->BakeTag->find('list'); | ||
$this->set(compact('bakeTags')); | ||
} | ||
|
||
/** | ||
* delete method | ||
* | ||
* @throws NotFoundException | ||
* @param string $id | ||
* @return void | ||
*/ | ||
public function delete($id = null) { | ||
$this->BakeArticle->id = $id; | ||
if (!$this->BakeArticle->exists()) { | ||
throw new NotFoundException(__('Invalid bake article')); | ||
} | ||
$this->request->onlyAllow('post', 'delete'); | ||
if ($this->BakeArticle->delete()) { | ||
return $this->flash(__('The bake article has been deleted.'), array('action' => 'index')); | ||
} else { | ||
return $this->flash(__('The bake article could not be deleted. Please, try again.'), array('action' => 'index')); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<?php | ||
App::uses('AppController', 'Controller'); | ||
/** | ||
* Articles Controller | ||
* | ||
* @property Article $Article | ||
* @property AclComponent $Acl | ||
* @property AuthComponent $Auth | ||
* @property PaginatorComponent $Paginator | ||
*/ | ||
class ArticlesController extends AppController { | ||
|
||
/** | ||
* Helpers | ||
* | ||
* @var array | ||
*/ | ||
public $helpers = array('Js', 'Time'); | ||
|
||
/** | ||
* Components | ||
* | ||
* @var array | ||
*/ | ||
public $components = array('Acl', 'Auth', 'Paginator'); | ||
|
||
} |
Oops, something went wrong.