Skip to content

Commit

Permalink
Fix most coding standards in Test/Case/View
Browse files Browse the repository at this point in the history
  • Loading branch information
markstory committed Mar 16, 2012
1 parent 6a55749 commit f5804cb
Show file tree
Hide file tree
Showing 19 changed files with 186 additions and 193 deletions.
5 changes: 2 additions & 3 deletions lib/Cake/Test/Case/View/Helper/CacheHelperTest.php
Expand Up @@ -49,6 +49,7 @@ public function cache_parsing() {
$this->set('batman', 'bruce wayne');
$this->set('spiderman', 'peter parker');
}

}

/**
Expand Down Expand Up @@ -84,7 +85,7 @@ public function setUp() {
Configure::write('Cache.check', true);
Configure::write('Cache.disable', false);
App::build(array(
'View' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'View'. DS)
'View' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'View' . DS)
), App::RESET);
}

Expand Down Expand Up @@ -380,7 +381,6 @@ public function testCacheActionArray() {
$this->assertTrue(file_exists($filename));
@unlink($filename);


$this->Controller->cache_parsing();
$this->Controller->cacheAction = array(
'cache_parsing' => 21600
Expand All @@ -398,7 +398,6 @@ public function testCacheActionArray() {
$this->assertTrue(file_exists($filename));
@unlink($filename);


$this->Controller->cache_parsing();
$this->Controller->request->addParams(array(
'controller' => 'cache_test',
Expand Down
31 changes: 17 additions & 14 deletions lib/Cake/Test/Case/View/Helper/FormHelperTest.php
Expand Up @@ -182,6 +182,7 @@ class ContactTagsContact extends CakeTestModel {
public function setSchema($schema) {
$this->_schema = $schema;
}

}

/**
Expand Down Expand Up @@ -217,6 +218,7 @@ public function schema($field = false) {
unset($this->_schema['id']);
return $this->_schema;
}

}

/**
Expand Down Expand Up @@ -369,6 +371,7 @@ public function beforeValidate($options = array()) {
$this->invalidate('openid_not_registered');
return true;
}

}

/**
Expand Down Expand Up @@ -432,6 +435,7 @@ public function beforeValidate($options = array()) {
$this->invalidate('email');
return false;
}

}

/**
Expand Down Expand Up @@ -505,6 +509,7 @@ public function beforeValidate($options = array()) {
$this->invalidate('city');
return false;
}

}

/**
Expand Down Expand Up @@ -568,6 +573,7 @@ public function beforeValidate($options = array()) {
$this->invalidate('description');
return false;
}

}

/**
Expand Down Expand Up @@ -675,8 +681,6 @@ public function tearDown() {
Configure::write('Security.salt', $this->oldSalt);
}



/**
* testFormCreateWithSecurity method
*
Expand Down Expand Up @@ -975,7 +979,6 @@ public function testSecurityButtonNestedNamed() {
$this->assertEquals(array('Address.button'), $result);
}


/**
* Test that submit inputs created with foo[bar] name attributes are unlocked correctly.
*
Expand Down Expand Up @@ -1469,7 +1472,7 @@ public function testUnlockFieldRemovingFromFields() {
*/
public function testTagIsInvalid() {
$Contact = ClassRegistry::getObject('Contact');
$Contact->validationErrors[0]['email'] = array('Please provide an email');
$Contact->validationErrors[0]['email'] = array('Please provide an email');

$this->Form->setEntity('Contact.0.email');
$result = $this->Form->tagIsInvalid();
Expand All @@ -1496,7 +1499,7 @@ public function testTagIsInvalid() {
*/
public function testPasswordValidation() {
$Contact = ClassRegistry::getObject('Contact');
$Contact->validationErrors['password'] = array('Please provide a password');
$Contact->validationErrors['password'] = array('Please provide a password');

$result = $this->Form->input('Contact.password');
$expected = array(
Expand Down Expand Up @@ -2389,7 +2392,6 @@ public function testInputSelectType() {
);
$this->assertTags($result, $expected);


$this->View->viewVars['users'] = array('value' => 'good', 'other' => 'bad');
$this->Form->request->data = array('Model' => array('user_id' => 'value'));

Expand Down Expand Up @@ -5271,7 +5273,6 @@ public function testDateTimeLabelIdMatchesFirstInput() {
$this->assertContains('label for="ModelDateYear"', $result);
}


/**
* testMonth method
*
Expand Down Expand Up @@ -5613,7 +5614,7 @@ public function testHour() {
$result = $this->Form->hour('Model.field', true, array('value' => 'now'));
$thisHour = date('H');
$optValue = date('G');
$this->assertRegExp('/<option value="' . $thisHour . '" selected="selected">'. $optValue .'<\/option>/', $result);
$this->assertRegExp('/<option value="' . $thisHour . '" selected="selected">' . $optValue . '<\/option>/', $result);
}

/**
Expand Down Expand Up @@ -5943,7 +5944,7 @@ public function testButton() {

$result = $this->Form->button('No type', array('type' => false));
$this->assertTags($result, array('button' => array(), 'No type', '/button'));

$result = $this->Form->button('Upload Text', array('onClick' => "$('#postAddForm').ajaxSubmit({target: '#postTextUpload', url: '/posts/text'});return false;'", 'escape' => false));
$this->assertNotRegExp('/\&039/', $result);
}
Expand Down Expand Up @@ -6459,7 +6460,6 @@ public function testCreate() {
'/div'
);
$this->assertTags($result, $expected);

}

/**
Expand Down Expand Up @@ -6572,8 +6572,12 @@ public function testCreateCustomRoute() {
*/
public function testCreateWithInputDefaults() {
$this->Form->create('User', array(
'inputDefaults' => array('div' => false, 'label' => false, 'error' => array('attributes'=>array('wrap' => 'small', 'class' => 'error')))
));
'inputDefaults' => array(
'div' => false,
'label' => false,
'error' => array('attributes' => array('wrap' => 'small', 'class' => 'error'))
)
));
$result = $this->Form->input('username');
$expected = array(
'input' => array('type' => 'text', 'name' => 'data[User][username]', 'id' => 'UserUsername')
Expand All @@ -6588,7 +6592,7 @@ public function testCreateWithInputDefaults() {
'/div'
);
$this->assertTags($result, $expected);

$User = ClassRegistry::getObject('User');
$User->validationErrors['username'] = array('empty');
$result = $this->Form->input('username', array('div' => true, 'label' => 'username', 'error' => array('empty' => __('Required'))));
Expand Down Expand Up @@ -7058,7 +7062,6 @@ public function testFormMagicInput() {
);
$this->assertTags($result, $expected);


extract($this->dateRegex);
$now = strtotime('now');

Expand Down
102 changes: 48 additions & 54 deletions lib/Cake/Test/Case/View/Helper/HtmlHelperTest.php
Expand Up @@ -52,6 +52,7 @@ class TheHtmlTestController extends Controller {
}

class TestHtmlHelper extends HtmlHelper {

/**
* expose a method as public
*
Expand Down Expand Up @@ -150,7 +151,7 @@ public function setUp() {
$this->Html->request->webroot = '';

App::build(array(
'Plugin' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'Plugin'. DS)
'Plugin' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'Plugin' . DS)
));

Configure::write('Asset.timestamp', false);
Expand Down Expand Up @@ -404,7 +405,7 @@ public function testImageTagWithTheme() {
$File = new File($testfile, true);

App::build(array(
'View' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'View'. DS)
'View' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'View' . DS)
));
Configure::write('Asset.timestamp', true);
Configure::write('debug', 1);
Expand Down Expand Up @@ -442,7 +443,7 @@ public function testImageTagWithTheme() {
*/
public function testThemeAssetsInMainWebrootPath() {
App::build(array(
'View' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'View'. DS)
'View' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'View' . DS)
));
$webRoot = Configure::read('App.www_root');
Configure::write('App.www_root', CAKE . 'Test' . DS . 'test_app' . DS . 'webroot' . DS);
Expand Down Expand Up @@ -800,10 +801,9 @@ public function testScript() {
'script' => array('type' => 'text/javascript', 'src' => 'js/jquery-1.3.2.js', 'defer' => 'defer', 'encoding' => 'utf-8')
);
$this->assertTags($result, $expected);

}

/**
/**
* test that plugin scripts added with uses() are only ever included once.
* test script tag generation with plugin syntax
*
Expand Down Expand Up @@ -933,7 +933,7 @@ public function testScriptInTheme() {
$File = new File($testfile, true);

App::build(array(
'View' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'View'. DS)
'View' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'View' . DS)
));

$this->Html->webroot = '/';
Expand Down Expand Up @@ -987,7 +987,6 @@ public function testScriptBlock() {
);
$this->assertTags($result, $expected);


$this->View->expects($this->at(0))
->method('append')
->with('script', $this->matchesRegularExpression('/window\.foo\s\=\s2;/'));
Expand Down Expand Up @@ -1031,7 +1030,6 @@ public function testScriptStartAndScriptEnd() {
);
$this->assertTags($result, $expected);


$result = $this->Html->scriptStart(array('safe' => false));
$this->assertNull($result);
echo 'this is some javascript';
Expand Down Expand Up @@ -1116,7 +1114,6 @@ public function testBreadcrumb() {
);
$this->assertTags($result, $expected);


$this->Html->addCrumb('Fourth', null);

$result = $this->Html->getCrumbs();
Expand Down Expand Up @@ -1502,14 +1499,11 @@ public function testMeta() {
$this->assertTags($result, array('meta' => array('name' => 'keywords', 'content' => 'these, are, some, meta, keywords')));
$this->assertRegExp('/\s+\/>$/', $result);


$result = $this->Html->meta('description', 'this is the meta description');
$this->assertTags($result, array('meta' => array('name' => 'description', 'content' => 'this is the meta description')));

$result = $this->Html->meta(array('name' => 'ROBOTS', 'content' => 'ALL'));
$this->assertTags($result, array('meta' => array('name' => 'ROBOTS', 'content' => 'ALL')));


}

/**
Expand Down Expand Up @@ -1788,46 +1782,46 @@ public function testCrumbList() {
/**
* Test getCrumbList startText
*/
public function testCrumbListFirstLink() {
$this->Html->addCrumb('First', '#first');
$this->Html->addCrumb('Second', '#second');

$result = $this->Html->getCrumbList(null, 'Home');
$this->assertTags(
$result,
array(
'<ul',
array('li' => array('class' => 'first')),
array('a' => array('href' => '/')), 'Home', '/a',
'/li',
'<li',
array('a' => array('href' => '#first')), 'First', '/a',
'/li',
array('li' => array('class' => 'last')),
array('a' => array('href' => '#second')), 'Second', '/a',
'/li',
'/ul'
)
);

$result = $this->Html->getCrumbList(null, array('url' => '/home', 'text' => '<img src="/home.png" />', 'escape' => false));
$this->assertTags(
$result,
array(
'<ul',
array('li' => array('class' => 'first')),
array('a' => array('href' => '/home')), 'img' => array('src' => '/home.png'), '/a',
'/li',
'<li',
array('a' => array('href' => '#first')), 'First', '/a',
'/li',
array('li' => array('class' => 'last')),
array('a' => array('href' => '#second')), 'Second', '/a',
'/li',
'/ul'
)
);
}
public function testCrumbListFirstLink() {
$this->Html->addCrumb('First', '#first');
$this->Html->addCrumb('Second', '#second');

$result = $this->Html->getCrumbList(null, 'Home');
$this->assertTags(
$result,
array(
'<ul',
array('li' => array('class' => 'first')),
array('a' => array('href' => '/')), 'Home', '/a',
'/li',
'<li',
array('a' => array('href' => '#first')), 'First', '/a',
'/li',
array('li' => array('class' => 'last')),
array('a' => array('href' => '#second')), 'Second', '/a',
'/li',
'/ul'
)
);

$result = $this->Html->getCrumbList(null, array('url' => '/home', 'text' => '<img src="/home.png" />', 'escape' => false));
$this->assertTags(
$result,
array(
'<ul',
array('li' => array('class' => 'first')),
array('a' => array('href' => '/home')), 'img' => array('src' => '/home.png'), '/a',
'/li',
'<li',
array('a' => array('href' => '#first')), 'First', '/a',
'/li',
array('li' => array('class' => 'last')),
array('a' => array('href' => '#second')), 'Second', '/a',
'/li',
'/ul'
)
);
}

/**
* testLoadConfig method
Expand All @@ -1836,7 +1830,7 @@ public function testCrumbListFirstLink() {
*/

public function testLoadConfig() {
$path = CAKE . 'Test' . DS . 'test_app' . DS . 'Config'. DS;
$path = CAKE . 'Test' . DS . 'test_app' . DS . 'Config' . DS;

$result = $this->Html->loadConfig('htmlhelper_tags', $path);
$expected = array(
Expand Down Expand Up @@ -1876,7 +1870,7 @@ public function testLoadConfigWrongFile() {
* @expectedException ConfigureException
*/
public function testLoadConfigWrongReader() {
$path = CAKE . 'Test' . DS . 'test_app' . DS . 'Config'. DS;
$path = CAKE . 'Test' . DS . 'test_app' . DS . 'Config' . DS;
$result = $this->Html->loadConfig(array('htmlhelper_tags', 'wrong_reader'), $path);
}

Expand Down
1 change: 1 addition & 0 deletions lib/Cake/Test/Case/View/Helper/JqueryEngineHelperTest.php
Expand Up @@ -22,6 +22,7 @@
App::uses('View', 'View');

class JqueryEngineHelperTest extends CakeTestCase {

/**
* setUp
*
Expand Down

0 comments on commit f5804cb

Please sign in to comment.