Permalink
Browse files

Reduce duplication in code.

This will result in all tests being skipped when any of the required
models pre-exists.
  • Loading branch information...
markstory committed Jan 16, 2013
1 parent 5a6a45d commit 95ed471c41f61555b2b7f642422bfef8a279cfd4
Showing with 4 additions and 23 deletions.
  1. +4 −23 lib/Cake/Test/Case/Console/Command/Task/ControllerTaskTest.php
@@ -90,6 +90,10 @@ public function setUp() {
array($out, $out, $in)
);
$this->Task->Test = $this->getMock('TestTask', array(), array($out, $out, $in));
if (!defined('ARTICLE_MODEL_CREATED')) {
$this->markTestSkipped('Could not run as an Article, Tag or Comment model was already loaded.');
}
}
/**
@@ -340,7 +344,6 @@ public function testBakeWithPlugin() {
* @return void
*/
public function testBakeActionsUsingSessions() {
$this->skipIf(!defined('ARTICLE_MODEL_CREATED'), 'Testing bakeActions requires Article, Comment & Tag Model to be undefined.');
$result = $this->Task->bakeActions('BakeArticles', null, true);
@@ -379,7 +382,6 @@ public function testBakeActionsUsingSessions() {
* @return void
*/
public function testBakeActionsWithNoSessions() {
$this->skipIf(!defined('ARTICLE_MODEL_CREATED'), 'Testing bakeActions requires Article, Tag, Comment Models to be undefined.');
$result = $this->Task->bakeActions('BakeArticles', null, false);
@@ -511,9 +513,6 @@ public function testExecuteIntoAll() {
if ($count != count($this->fixtures)) {
$this->markTestSkipped('Additional tables detected.');
}
if (!defined('ARTICLE_MODEL_CREATED')) {
$this->markTestSkipped('Execute into all could not be run as an Article, Tag or Comment model was already loaded.');
}
$this->Task->connection = 'test';
$this->Task->path = '/my/path/';
@@ -541,9 +540,6 @@ public function testExecuteIntoAllAdmin() {
if ($count != count($this->fixtures)) {
$this->markTestSkipped('Additional tables detected.');
}
if (!defined('ARTICLE_MODEL_CREATED')) {
$this->markTestSkipped('Execute into all could not be run as an Article, Tag or Comment model was already loaded.');
}
$this->Task->connection = 'test';
$this->Task->path = '/my/path/';
@@ -573,9 +569,6 @@ public function testExecuteIntoAllAdmin() {
* @return void
*/
public function testExecuteWithController() {
if (!defined('ARTICLE_MODEL_CREATED')) {
$this->markTestSkipped('Execute with scaffold param requires no Article, Tag or Comment model to be defined');
}
$this->Task->connection = 'test';
$this->Task->path = '/my/path/';
$this->Task->args = array('BakeArticles');
@@ -607,9 +600,6 @@ public static function nameVariations() {
* @return void
*/
public function testExecuteWithControllerNameVariations($name) {
if (!defined('ARTICLE_MODEL_CREATED')) {
$this->markTestSkipped('Execute with scaffold param requires no Article, Tag or Comment model to be defined.');
}
$this->Task->connection = 'test';
$this->Task->path = '/my/path/';
$this->Task->args = array($name);
@@ -627,9 +617,6 @@ public function testExecuteWithControllerNameVariations($name) {
* @return void
*/
public function testExecuteWithPublicParam() {
if (!defined('ARTICLE_MODEL_CREATED')) {
$this->markTestSkipped('Execute with public param requires no Article, Tag or Comment model to be defined.');
}
$this->Task->connection = 'test';
$this->Task->path = '/my/path/';
$this->Task->args = array('BakeArticles');
@@ -649,9 +636,6 @@ public function testExecuteWithPublicParam() {
* @return void
*/
public function testExecuteWithControllerAndBoth() {
if (!defined('ARTICLE_MODEL_CREATED')) {
$this->markTestSkipped('Execute with controller and both requires no Article, Tag or Comment model to be defined.');
}
$this->Task->Project->expects($this->any())->method('getPrefix')->will($this->returnValue('admin_'));
$this->Task->connection = 'test';
$this->Task->path = '/my/path/';
@@ -671,9 +655,6 @@ public function testExecuteWithControllerAndBoth() {
* @return void
*/
public function testExecuteWithControllerAndAdmin() {
if (!defined('ARTICLE_MODEL_CREATED')) {
$this->markTestSkipped('Execute with controller and admin requires no Article, Tag or Comment model to be defined.');
}
$this->Task->Project->expects($this->any())->method('getPrefix')->will($this->returnValue('admin_'));
$this->Task->connection = 'test';
$this->Task->path = '/my/path/';

0 comments on commit 95ed471

Please sign in to comment.