Fix most coding standards in Test/Case/View

This commit is contained in:
mark_story 2012-03-15 22:50:05 -04:00
parent 6a55749e27
commit f5804cb4ca
19 changed files with 184 additions and 191 deletions

View file

@ -49,6 +49,7 @@ class CacheTestController extends Controller {
$this->set('batman', 'bruce wayne');
$this->set('spiderman', 'peter parker');
}
}
/**
@ -84,7 +85,7 @@ class CacheHelperTest extends CakeTestCase {
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);
}
@ -380,7 +381,6 @@ class CacheHelperTest extends CakeTestCase {
$this->assertTrue(file_exists($filename));
@unlink($filename);
$this->Controller->cache_parsing();
$this->Controller->cacheAction = array(
'cache_parsing' => 21600
@ -398,7 +398,6 @@ class CacheHelperTest extends CakeTestCase {
$this->assertTrue(file_exists($filename));
@unlink($filename);
$this->Controller->cache_parsing();
$this->Controller->request->addParams(array(
'controller' => 'cache_test',

View file

@ -182,6 +182,7 @@ class ContactTagsContact extends CakeTestModel {
public function setSchema($schema) {
$this->_schema = $schema;
}
}
/**
@ -217,6 +218,7 @@ class ContactNonStandardPk extends Contact {
unset($this->_schema['id']);
return $this->_schema;
}
}
/**
@ -369,6 +371,7 @@ class OpenidUrl extends CakeTestModel {
$this->invalidate('openid_not_registered');
return true;
}
}
/**
@ -432,6 +435,7 @@ class ValidateUser extends CakeTestModel {
$this->invalidate('email');
return false;
}
}
/**
@ -505,6 +509,7 @@ class ValidateProfile extends CakeTestModel {
$this->invalidate('city');
return false;
}
}
/**
@ -568,6 +573,7 @@ class ValidateItem extends CakeTestModel {
$this->invalidate('description');
return false;
}
}
/**
@ -675,8 +681,6 @@ class FormHelperTest extends CakeTestCase {
Configure::write('Security.salt', $this->oldSalt);
}
/**
* testFormCreateWithSecurity method
*
@ -975,7 +979,6 @@ class FormHelperTest extends CakeTestCase {
$this->assertEquals(array('Address.button'), $result);
}
/**
* Test that submit inputs created with foo[bar] name attributes are unlocked correctly.
*
@ -1469,7 +1472,7 @@ class FormHelperTest extends CakeTestCase {
*/
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();
@ -1496,7 +1499,7 @@ class FormHelperTest extends CakeTestCase {
*/
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(
@ -2389,7 +2392,6 @@ class FormHelperTest extends CakeTestCase {
);
$this->assertTags($result, $expected);
$this->View->viewVars['users'] = array('value' => 'good', 'other' => 'bad');
$this->Form->request->data = array('Model' => array('user_id' => 'value'));
@ -5271,7 +5273,6 @@ class FormHelperTest extends CakeTestCase {
$this->assertContains('label for="ModelDateYear"', $result);
}
/**
* testMonth method
*
@ -5613,7 +5614,7 @@ class FormHelperTest extends CakeTestCase {
$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);
}
/**
@ -5943,7 +5944,7 @@ class FormHelperTest extends CakeTestCase {
$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);
}
@ -6459,7 +6460,6 @@ class FormHelperTest extends CakeTestCase {
'/div'
);
$this->assertTags($result, $expected);
}
/**
@ -6572,8 +6572,12 @@ class FormHelperTest extends CakeTestCase {
*/
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')
@ -6588,7 +6592,7 @@ class FormHelperTest extends CakeTestCase {
'/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'))));
@ -7058,7 +7062,6 @@ class FormHelperTest extends CakeTestCase {
);
$this->assertTags($result, $expected);
extract($this->dateRegex);
$now = strtotime('now');

View file

@ -52,6 +52,7 @@ class TheHtmlTestController extends Controller {
}
class TestHtmlHelper extends HtmlHelper {
/**
* expose a method as public
*
@ -150,7 +151,7 @@ class HtmlHelperTest extends CakeTestCase {
$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);
@ -404,7 +405,7 @@ class HtmlHelperTest extends CakeTestCase {
$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);
@ -442,7 +443,7 @@ class HtmlHelperTest extends CakeTestCase {
*/
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);
@ -800,10 +801,9 @@ class HtmlHelperTest extends CakeTestCase {
'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
*
@ -933,7 +933,7 @@ class HtmlHelperTest extends CakeTestCase {
$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 = '/';
@ -987,7 +987,6 @@ class HtmlHelperTest extends CakeTestCase {
);
$this->assertTags($result, $expected);
$this->View->expects($this->at(0))
->method('append')
->with('script', $this->matchesRegularExpression('/window\.foo\s\=\s2;/'));
@ -1031,7 +1030,6 @@ class HtmlHelperTest extends CakeTestCase {
);
$this->assertTags($result, $expected);
$result = $this->Html->scriptStart(array('safe' => false));
$this->assertNull($result);
echo 'this is some javascript';
@ -1116,7 +1114,6 @@ class HtmlHelperTest extends CakeTestCase {
);
$this->assertTags($result, $expected);
$this->Html->addCrumb('Fourth', null);
$result = $this->Html->getCrumbs();
@ -1502,14 +1499,11 @@ class HtmlHelperTest extends CakeTestCase {
$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')));
}
/**
@ -1788,46 +1782,46 @@ class HtmlHelperTest extends CakeTestCase {
/**
* Test getCrumbList startText
*/
public function testCrumbListFirstLink() {
$this->Html->addCrumb('First', '#first');
$this->Html->addCrumb('Second', '#second');
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, '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'
)
);
}
$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
@ -1836,7 +1830,7 @@ class HtmlHelperTest extends CakeTestCase {
*/
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(
@ -1876,7 +1870,7 @@ class HtmlHelperTest extends CakeTestCase {
* @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);
}

View file

@ -22,6 +22,7 @@ App::uses('JqueryEngineHelper', 'View/Helper');
App::uses('View', 'View');
class JqueryEngineHelperTest extends CakeTestCase {
/**
* setUp
*

View file

@ -26,12 +26,15 @@ App::uses('View', 'View');
App::uses('ClassRegistry', 'Utility');
class JsEncodingObject {
protected $_title = 'Old thing';
private $__noshow = 'Never ever';
}
class OptionEngineHelper extends JsBaseEngineHelper {
protected $_optionMap = array(
'request' => array(
'complete' => 'success',
@ -58,17 +61,39 @@ class OptionEngineHelper extends JsBaseEngineHelper {
return $this->_parseOptions($options, $safe);
}
public function get($selector) {}
public function event($type, $callback, $options = array()) {}
public function domReady($functionBody) {}
public function each($callback) {}
public function effect($name, $options = array()) {}
public function request($url, $options = array()) {}
public function drag($options = array()) {}
public function drop($options = array()) {}
public function sortable($options = array()) {}
public function slider($options = array()) {}
public function serializeForm($options = array()) {}
public function get($selector) {
}
public function event($type, $callback, $options = array()) {
}
public function domReady($functionBody) {
}
public function each($callback) {
}
public function effect($name, $options = array()) {
}
public function request($url, $options = array()) {
}
public function drag($options = array()) {
}
public function drop($options = array()) {
}
public function sortable($options = array()) {
}
public function slider($options = array()) {
}
public function serializeForm($options = array()) {
}
}
/**
@ -77,6 +102,7 @@ class OptionEngineHelper extends JsBaseEngineHelper {
* @package Cake.Test.Case.View.Helper
*/
class JsHelperTest extends CakeTestCase {
/**
* Regexp for CDATA start block
*
@ -91,7 +117,6 @@ class JsHelperTest extends CakeTestCase {
*/
public $cDataEnd = 'preg:/[^\]]*\]\]\>[\s\r\n]*/';
/**
* setUp method
*
@ -689,6 +714,7 @@ class JsHelperTest extends CakeTestCase {
$this->assertEquals($result[1], 'alert("hey you!");');
$this->assertEquals($result[2], 'confirm("Are you sure?");');
}
}
/**
@ -697,6 +723,7 @@ class JsHelperTest extends CakeTestCase {
* @package Cake.Test.Case.View.Helper
*/
class JsBaseEngineTest extends CakeTestCase {
/**
* setUp method
*
@ -812,7 +839,6 @@ class JsBaseEngineTest extends CakeTestCase {
* @return void
*/
public function testObject() {
$object = array('title' => 'New thing', 'indexes' => array(5, 6, 7, 8));
$result = $this->JsEngine->object($object);
$expected = '{"title":"New thing","indexes":[5,6,7,8]}';

View file

@ -22,6 +22,7 @@ App::uses('JsHelper', 'View/Helper');
App::uses('MootoolsEngineHelper', 'View/Helper');
class MootoolsEngineHelperTest extends CakeTestCase {
/**
* setUp
*

View file

@ -68,7 +68,6 @@ class NumberHelperTest extends CakeTestCase {
unset($this->View);
}
/**
* test CakeNumber class methods are called correctly
*/

View file

@ -212,13 +212,11 @@ class PaginatorHelperTest extends CakeTestCase {
$result = $this->Paginator->sort('title', 'Title', array('direction' => 'asc'));
$this->assertRegExp('/\/accounts\/index\/param\/page:1\/sort:title\/direction:asc" class="desc">Title<\/a>$/', $result);
$this->Paginator->request->params['paging']['Article']['options']['order'] = array('Article.title' => 'asc');
$this->Paginator->request->params['paging']['Article']['options']['sort'] = null;
$result = $this->Paginator->sort('title', 'Title', array('direction' => 'asc'));
$this->assertRegExp('/\/accounts\/index\/param\/page:1\/sort:title\/direction:desc" class="asc">Title<\/a>$/', $result);
$this->Paginator->request->params['paging']['Article']['options']['order'] = array('Article.title' => 'asc');
$this->Paginator->request->params['paging']['Article']['options']['sort'] = null;
$result = $this->Paginator->sort('title', 'Title', array('direction' => 'desc'));
@ -330,7 +328,6 @@ class PaginatorHelperTest extends CakeTestCase {
);
$this->assertTags($result, $expected);
$this->Paginator->request->params['paging']['Article']['options']['order'] = array('Article.title' => 'asc');
$result = $this->Paginator->sort('Article.title', 'Title');
$expected = array(
@ -1344,7 +1341,6 @@ class PaginatorHelperTest extends CakeTestCase {
);
$this->assertTags($result, $expected);
$this->Paginator->request->params['paging'] = array(
'Client' => array(
'page' => 14,
@ -1417,7 +1413,7 @@ class PaginatorHelperTest extends CakeTestCase {
array('span' => array('class' => 'page-link')), array('a' => array('href' => '/index/page:9')), '9', '/a', '/span',
);
$this->assertTags($result, $expected);
$result = $this->Paginator->numbers(array('first' => 1, 'currentClass' => 'active'));
$expected = array(
array('span' => array()), array('a' => array('href' => '/index/page:1')), '1', '/a', '/span',
@ -1439,7 +1435,7 @@ class PaginatorHelperTest extends CakeTestCase {
array('span' => array()), array('a' => array('href' => '/index/page:9')), '9', '/a', '/span',
);
$this->assertTags($result, $expected);
$result = $this->Paginator->numbers(array('first' => 1, 'class' => 'page-link', 'currentClass' => 'active'));
$expected = array(
array('span' => array('class' => 'page-link')), array('a' => array('href' => '/index/page:1')), '1', '/a', '/span',
@ -1699,7 +1695,6 @@ class PaginatorHelperTest extends CakeTestCase {
);
$this->assertTags($result, $expected);
$this->Paginator->request->params['paging'] = array(
'Client' => array(
'page' => 4895,

View file

@ -22,6 +22,7 @@ App::uses('JsHelper', 'View/Helper');
App::uses('PrototypeEngineHelper', 'View/Helper');
class PrototypeEngineHelperTest extends CakeTestCase {
/**
* setUp
*

View file

@ -377,7 +377,7 @@ class RssHelperTest extends CakeTestCase {
'url' => 'http://example.com/foo?a=1&b=2',
'convertEntities' => false
),
'description' => array(
'description' => array(
'value' => 'descriptive words',
'cdata' => true,
),

View file

@ -128,7 +128,7 @@ class SessionHelperTest extends CakeTestCase {
$this->assertEquals($expected, $result);
App::build(array(
'View' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'View'. DS)
'View' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'View' . DS)
));
$result = $this->Session->flash('notification');
$result = str_replace("\r\n", "\n", $result);
@ -161,7 +161,7 @@ class SessionHelperTest extends CakeTestCase {
*/
public function testFlashElementInAttrs() {
App::build(array(
'View' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'View'. DS)
'View' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'View' . DS)
));
$result = $this->Session->flash('flash', array(
'element' => 'session_helper',
@ -178,7 +178,7 @@ class SessionHelperTest extends CakeTestCase {
*/
public function testFlashWithPluginElement() {
App::build(array(
'Plugin' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'Plugin'. DS)
'Plugin' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'Plugin' . DS)
));
CakePlugin::load('TestPlugin');

View file

@ -28,6 +28,7 @@ class HtmlAliasHelper extends HtmlHelper {
}
class HelperCollectionTest extends CakeTestCase {
/**
* setUp
*

View file

@ -93,6 +93,7 @@ class HelperTestComment extends Model {
);
return $this->_schema;
}
}
/**
@ -123,6 +124,7 @@ class HelperTestTag extends Model {
);
return $this->_schema;
}
}
/**
@ -151,9 +153,11 @@ class HelperTestPostsTag extends Model {
);
return $this->_schema;
}
}
class TestHelper extends Helper {
/**
* Helpers for this helper.
*
@ -173,6 +177,7 @@ class TestHelper extends Helper {
public function parseAttributes($options, $exclude = null, $insertBefore = ' ', $insertAfter = null) {
return $this->_parseAttributes($options, $exclude, $insertBefore, $insertAfter);
}
}
/**
@ -644,12 +649,12 @@ class HelperTest extends CakeTestCase {
* @return void
*/
public function testAssetTimestampPluginsAndThemes() {
$_timestamp = Configure::read('Asset.timestamp');
$timestamp = Configure::read('Asset.timestamp');
Configure::write('Asset.timestamp', 'force');
App::build(array(
'View' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'View' . DS),
));
CakePlugin::load(array('TestPlugin'));;
CakePlugin::load(array('TestPlugin'));
$result = $this->Helper->assetTimestamp('/test_plugin/css/test_plugin_asset.css');
$this->assertRegExp('#/test_plugin/css/test_plugin_asset.css\?[0-9]+$#', $result, 'Missing timestamp plugin');
@ -664,7 +669,7 @@ class HelperTest extends CakeTestCase {
$this->assertRegExp('#/theme/test_theme/js/non_existant.js\?$#', $result, 'No error on missing file');
App::build();
Configure::write('Asset.timestamp', $_timestamp);
Configure::write('Asset.timestamp', $timestamp);
}
/**
@ -834,7 +839,7 @@ class HelperTest extends CakeTestCase {
$this->Helper->request->data['My']['title'] = 'My Title';
$result = $this->Helper->value('My.title');
$this->assertEquals($result,'My Title');
$this->assertEquals($result, 'My Title');
}
public function testWebrootPaths() {
@ -846,7 +851,7 @@ class HelperTest extends CakeTestCase {
$this->Helper->theme = 'test_theme';
App::build(array(
'View' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'View'. DS)
'View' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'View' . DS)
));
$result = $this->Helper->webroot('/img/cake.power.gif');
@ -916,10 +921,11 @@ class HelperTest extends CakeTestCase {
*/
public function testLazyLoadingUsesReferences() {
$Helper = new TestHelper($this->View);
$result1 = $Helper->Html;
$result2 = $Helper->Html;
$resultA = $Helper->Html;
$resultB = $Helper->Html;
$result1->testprop = 1;
$this->assertEquals($result1->testprop, $result2->testprop);
$resultA->testprop = 1;
$this->assertEquals($resultA->testprop, $resultB->testprop);
}
}

View file

@ -62,7 +62,7 @@ class JsonViewTest extends CakeTestCase {
$View = new JsonView($Controller);
$output = $View->render(false);
$this->assertIdentical(json_encode(array('no' =>$data['no'], 'user' => $data['user'])), $output);
$this->assertIdentical(json_encode(array('no' => $data['no'], 'user' => $data['user'])), $output);
$this->assertIdentical('application/json', $Response->type());
}

View file

@ -70,7 +70,7 @@ class MediaViewTest extends CakeTestCase {
*/
public function testRender() {
$this->MediaView->viewVars = array(
'path' => CAKE . 'Test' . DS . 'test_app' . DS . 'Vendor' . DS .'css' . DS,
'path' => CAKE . 'Test' . DS . 'test_app' . DS . 'Vendor' . DS . 'css' . DS,
'id' => 'test_asset.css',
'extension' => 'css',
);
@ -117,7 +117,7 @@ class MediaViewTest extends CakeTestCase {
$currentUserAgent = isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : null;
$_SERVER['HTTP_USER_AGENT'] = 'Some generic browser';
$this->MediaView->viewVars = array(
'path' => CAKE . 'Test' . DS . 'test_app' . DS . 'Config' . DS,
'path' => CAKE . 'Test' . DS . 'test_app' . DS . 'Config' . DS,
'id' => 'no_section.ini',
'extension' => 'ini',
);
@ -176,7 +176,7 @@ class MediaViewTest extends CakeTestCase {
$currentUserAgent = isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : null;
$_SERVER['HTTP_USER_AGENT'] = 'Opera/9.80 (Windows NT 6.0; U; en) Presto/2.8.99 Version/11.10';
$this->MediaView->viewVars = array(
'path' => CAKE . 'Test' . DS . 'test_app' . DS . 'Config' . DS,
'path' => CAKE . 'Test' . DS . 'test_app' . DS . 'Config' . DS,
'id' => 'no_section.ini',
'extension' => 'ini',
);
@ -240,7 +240,7 @@ class MediaViewTest extends CakeTestCase {
$currentUserAgent = isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : null;
$_SERVER['HTTP_USER_AGENT'] = 'Mozilla/5.0 (compatible; MSIE 8.0; Windows NT 5.2; Trident/4.0; Media Center PC 4.0; SLCC1; .NET CLR 3.0.04320)';
$this->MediaView->viewVars = array(
'path' => CAKE . 'Test' . DS . 'test_app' . DS . 'Config' . DS,
'path' => CAKE . 'Test' . DS . 'test_app' . DS . 'Config' . DS,
'id' => 'no_section.ini',
'extension' => 'ini',
'name' => 'config'
@ -303,7 +303,7 @@ class MediaViewTest extends CakeTestCase {
*/
public function testConnectionAborted() {
$this->MediaView->viewVars = array(
'path' => CAKE . 'Test' . DS . 'test_app' . DS . 'Vendor' . DS .'css' . DS,
'path' => CAKE . 'Test' . DS . 'test_app' . DS . 'Vendor' . DS . 'css' . DS,
'id' => 'test_asset.css',
'extension' => 'css',
);
@ -326,7 +326,7 @@ class MediaViewTest extends CakeTestCase {
*/
public function testConnectionAbortedOnBuffering() {
$this->MediaView->viewVars = array(
'path' => CAKE . 'Test' . DS . 'test_app' . DS . 'Vendor' . DS .'css' . DS,
'path' => CAKE . 'Test' . DS . 'test_app' . DS . 'Vendor' . DS . 'css' . DS,
'id' => 'test_asset.css',
'extension' => 'css',
);
@ -359,7 +359,7 @@ class MediaViewTest extends CakeTestCase {
*/
public function testRenderUpperExtension() {
$this->MediaView->viewVars = array(
'path' => CAKE . 'Test' . DS . 'test_app' . DS . 'Vendor' . DS .'img' . DS,
'path' => CAKE . 'Test' . DS . 'test_app' . DS . 'Vendor' . DS . 'img' . DS,
'id' => 'test_2.JPG',
'extension' => 'JPG',
);
@ -383,7 +383,7 @@ class MediaViewTest extends CakeTestCase {
*/
public function testRenderExtensionNotSet() {
$this->MediaView->viewVars = array(
'path' => CAKE . 'Test' . DS . 'test_app' . DS . 'Vendor' . DS .'img' . DS,
'path' => CAKE . 'Test' . DS . 'test_app' . DS . 'Vendor' . DS . 'img' . DS,
'id' => 'test_2.JPG',
);

View file

@ -39,6 +39,7 @@ class TestScaffoldView extends ScaffoldView {
public function testGetFilename($action) {
return $this->_getViewFileName($action);
}
}
/**
@ -141,7 +142,7 @@ class ScaffoldViewTest extends CakeTestCase {
$this->assertEquals($expected, $result);
$result = $ScaffoldView->testGetFilename('admin_edit');
$expected =CAKE . 'View' . DS . 'Scaffolds' . DS . 'form.ctp';
$expected = CAKE . 'View' . DS . 'Scaffolds' . DS . 'form.ctp';
$this->assertEquals($expected, $result);
$result = $ScaffoldView->testGetFilename('admin_add');
@ -159,11 +160,11 @@ class ScaffoldViewTest extends CakeTestCase {
$ScaffoldView = new TestScaffoldView($Controller);
$result = $ScaffoldView->testGetFilename('admin_edit');
$expected = CAKE . 'Test' . DS . 'test_app' .DS . 'View' . DS . 'Posts' . DS . 'scaffold.form.ctp';
$expected = CAKE . 'Test' . DS . 'test_app' . DS . 'View' . DS . 'Posts' . DS . 'scaffold.form.ctp';
$this->assertEquals($expected, $result);
$result = $ScaffoldView->testGetFilename('edit');
$expected = CAKE . 'Test' . DS . 'test_app' .DS . 'View' . DS . 'Posts' . DS . 'scaffold.form.ctp';
$expected = CAKE . 'Test' . DS . 'test_app' . DS . 'View' . DS . 'Posts' . DS . 'scaffold.form.ctp';
$this->assertEquals($expected, $result);
$Controller = new ScaffoldViewMockController($this->request);
@ -178,13 +179,13 @@ class ScaffoldViewTest extends CakeTestCase {
$ScaffoldView = new TestScaffoldView($Controller);
$result = $ScaffoldView->testGetFilename('admin_add');
$expected = CAKE . 'Test' . DS . 'test_app' . DS . 'Plugin'
. DS .'TestPlugin' . DS . 'View' . DS . 'Tests' . DS . 'scaffold.form.ctp';
$expected = CAKE . 'Test' . DS . 'test_app' . DS . 'Plugin' .
DS . 'TestPlugin' . DS . 'View' . DS . 'Tests' . DS . 'scaffold.form.ctp';
$this->assertEquals($expected, $result);
$result = $ScaffoldView->testGetFilename('add');
$expected = CAKE . 'Test' . DS . 'test_app' . DS . 'Plugin'
. DS .'TestPlugin' . DS . 'View' . DS . 'Tests' . DS . 'scaffold.form.ctp';
$expected = CAKE . 'Test' . DS . 'test_app' . DS . 'Plugin' .
DS . 'TestPlugin' . DS . 'View' . DS . 'Tests' . DS . 'scaffold.form.ctp';
$this->assertEquals($expected, $result);
Configure::write('Routing.prefixes', $_admin);
@ -202,8 +203,8 @@ class ScaffoldViewTest extends CakeTestCase {
$ScaffoldView = new TestScaffoldView($this->Controller);
$result = $ScaffoldView->testGetFilename('index');
$expected = CAKE . 'Test' . DS . 'test_app' . DS . 'View' . DS
. 'Themed' . DS . 'TestTheme' . DS . 'Posts' . DS . 'scaffold.index.ctp';
$expected = CAKE . 'Test' . DS . 'test_app' . DS . 'View' . DS .
'Themed' . DS . 'TestTheme' . DS . 'Posts' . DS . 'scaffold.index.ctp';
$this->assertEquals($expected, $result);
}

View file

@ -48,6 +48,7 @@ class ThemePosts2Controller extends Controller {
$test3 = 'even more data';
$this->set(compact('test2', 'test3'));
}
}
/**
@ -112,7 +113,7 @@ class ThemeViewTest extends CakeTestCase {
$this->ThemeView = new ThemeView($this->PostsController);
App::build(array(
'Plugin' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'Plugin' . DS),
'View' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'View'. DS)
'View' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'View' . DS)
));
App::objects('plugins', null, false);
CakePlugin::load(array('TestPlugin'));
@ -144,15 +145,15 @@ class ThemeViewTest extends CakeTestCase {
$this->Controller->theme = 'TestTheme';
$ThemeView = new TestTheme2View($this->Controller);
$expected = CAKE . 'Test' . DS . 'test_app' . DS . 'View' . DS . 'Themed' . DS . 'TestTheme' . DS . 'Plugin' . DS . 'TestPlugin' . DS . 'Tests' . DS .'index.ctp';
$expected = CAKE . 'Test' . DS . 'test_app' . DS . 'View' . DS . 'Themed' . DS . 'TestTheme' . DS . 'Plugin' . DS . 'TestPlugin' . DS . 'Tests' . DS . 'index.ctp';
$result = $ThemeView->getViewFileName('index');
$this->assertEquals($expected, $result);
$expected = CAKE . 'Test' . DS . 'test_app' . DS . 'View' . DS . 'Themed' . DS . 'TestTheme' . DS . 'Plugin' . DS . 'TestPlugin' . DS . 'Layouts' . DS .'plugin_default.ctp';
$expected = CAKE . 'Test' . DS . 'test_app' . DS . 'View' . DS . 'Themed' . DS . 'TestTheme' . DS . 'Plugin' . DS . 'TestPlugin' . DS . 'Layouts' . DS . 'plugin_default.ctp';
$result = $ThemeView->getLayoutFileName('plugin_default');
$this->assertEquals($expected, $result);
$expected = CAKE . 'Test' . DS . 'test_app' . DS . 'View' . DS . 'Themed' . DS . 'TestTheme' . DS . 'Layouts' . DS .'default.ctp';
$expected = CAKE . 'Test' . DS . 'test_app' . DS . 'View' . DS . 'Themed' . DS . 'TestTheme' . DS . 'Layouts' . DS . 'default.ctp';
$result = $ThemeView->getLayoutFileName('default');
$this->assertEquals($expected, $result);
}
@ -171,15 +172,15 @@ class ThemeViewTest extends CakeTestCase {
$ThemeView = new TestTheme2View($this->Controller);
$ThemeView->theme = 'TestTheme';
$expected = CAKE . 'Test' . DS . 'test_app' . DS . 'View' . DS .'Pages' . DS .'home.ctp';
$expected = CAKE . 'Test' . DS . 'test_app' . DS . 'View' . DS . 'Pages' . DS . 'home.ctp';
$result = $ThemeView->getViewFileName('home');
$this->assertEquals($expected, $result);
$expected = CAKE . 'Test' . DS . 'test_app' . DS . 'View' . DS . 'Themed' . DS . 'TestTheme' . DS . 'Posts' . DS .'index.ctp';
$expected = CAKE . 'Test' . DS . 'test_app' . DS . 'View' . DS . 'Themed' . DS . 'TestTheme' . DS . 'Posts' . DS . 'index.ctp';
$result = $ThemeView->getViewFileName('/Posts/index');
$this->assertEquals($expected, $result);
$expected = CAKE . 'Test' . DS . 'test_app' . DS . 'View' . DS . 'Themed' . DS . 'TestTheme' . DS . 'Layouts' . DS .'default.ctp';
$expected = CAKE . 'Test' . DS . 'test_app' . DS . 'View' . DS . 'Themed' . DS . 'TestTheme' . DS . 'Layouts' . DS . 'default.ctp';
$result = $ThemeView->getLayoutFileName();
$this->assertEquals($expected, $result);

View file

@ -66,6 +66,7 @@ class ViewPostsController extends Controller {
$this->set('foo', 'this is foo var');
$this->set('bar', 'this is bar var');
}
}
/**
@ -95,6 +96,7 @@ class ThemePostsController extends Controller {
$test3 = 'even more data';
$this->set(compact('test2', 'test3'));
}
}
/**
@ -196,6 +198,7 @@ class TestView extends View {
public function scripts() {
return $this->_scripts;
}
}
/**
@ -229,6 +232,7 @@ class TestAfterHelper extends Helper {
public function afterLayout($layoutFile) {
$this->_View->output .= 'modified in the afterlife';
}
}
@ -270,7 +274,7 @@ class ViewTest extends CakeTestCase {
App::build(array(
'Plugin' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'Plugin' . DS),
'View' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'View'. DS)
'View' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'View' . DS)
), App::RESET);
App::objects('plugins', null, false);
@ -292,8 +296,8 @@ class ViewTest extends CakeTestCase {
unset($this->ThemeView);
unset($this->ThemePostsController);
unset($this->ThemeController);
}
/**
* testGetTemplate method
*
@ -308,15 +312,15 @@ class ViewTest extends CakeTestCase {
$ThemeView = new TestThemeView($this->Controller);
$ThemeView->theme = 'TestTheme';
$expected = CAKE . 'Test' . DS . 'test_app' . DS . 'View' . DS .'Pages' . DS .'home.ctp';
$expected = CAKE . 'Test' . DS . 'test_app' . DS . 'View' . DS . 'Pages' . DS . 'home.ctp';
$result = $ThemeView->getViewFileName('home');
$this->assertEquals($expected, $result);
$expected = CAKE . 'Test' . DS . 'test_app' . DS . 'View' . DS . 'Themed' . DS . 'TestTheme' . DS . 'Posts' . DS .'index.ctp';
$expected = CAKE . 'Test' . DS . 'test_app' . DS . 'View' . DS . 'Themed' . DS . 'TestTheme' . DS . 'Posts' . DS . 'index.ctp';
$result = $ThemeView->getViewFileName('/Posts/index');
$this->assertEquals($expected, $result);
$expected = CAKE . 'Test' . DS . 'test_app' . DS . 'View' . DS . 'Themed' . DS . 'TestTheme' . DS . 'Layouts' . DS .'default.ctp';
$expected = CAKE . 'Test' . DS . 'test_app' . DS . 'View' . DS . 'Themed' . DS . 'TestTheme' . DS . 'Layouts' . DS . 'default.ctp';
$result = $ThemeView->getLayoutFileName();
$this->assertEquals($expected, $result);
@ -344,11 +348,11 @@ class ViewTest extends CakeTestCase {
$View = new TestView($this->Controller);
$expected = CakePlugin::path('TestPlugin') . 'View' . DS .'Tests' . DS .'index.ctp';
$expected = CakePlugin::path('TestPlugin') . 'View' . DS . 'Tests' . DS . 'index.ctp';
$result = $View->getViewFileName('index');
$this->assertEquals($expected, $result);
$expected = CakePlugin::path('TestPlugin') . 'View' . DS . 'Layouts' . DS .'default.ctp';
$expected = CakePlugin::path('TestPlugin') . 'View' . DS . 'Layouts' . DS . 'default.ctp';
$result = $View->getLayoutFileName();
$this->assertEquals($expected, $result);
}
@ -366,15 +370,15 @@ class ViewTest extends CakeTestCase {
$this->Controller->theme = 'TestTheme';
$ThemeView = new TestThemeView($this->Controller);
$expected = CAKE . 'Test' . DS . 'test_app' . DS . 'View' . DS . 'Themed' . DS . 'TestTheme' . DS . 'Plugin' . DS . 'TestPlugin' . DS . 'Tests' . DS .'index.ctp';
$expected = CAKE . 'Test' . DS . 'test_app' . DS . 'View' . DS . 'Themed' . DS . 'TestTheme' . DS . 'Plugin' . DS . 'TestPlugin' . DS . 'Tests' . DS . 'index.ctp';
$result = $ThemeView->getViewFileName('index');
$this->assertEquals($expected, $result);
$expected = CAKE . 'Test' . DS . 'test_app' . DS . 'View' . DS . 'Themed' . DS . 'TestTheme' . DS . 'Plugin' . DS . 'TestPlugin' . DS . 'Layouts' . DS .'plugin_default.ctp';
$expected = CAKE . 'Test' . DS . 'test_app' . DS . 'View' . DS . 'Themed' . DS . 'TestTheme' . DS . 'Plugin' . DS . 'TestPlugin' . DS . 'Layouts' . DS . 'plugin_default.ctp';
$result = $ThemeView->getLayoutFileName('plugin_default');
$this->assertEquals($expected, $result);
$expected = CAKE . 'Test' . DS . 'test_app' . DS . 'View' . DS . 'Themed' . DS . 'TestTheme' . DS . 'Layouts' . DS .'default.ctp';
$expected = CAKE . 'Test' . DS . 'test_app' . DS . 'View' . DS . 'Themed' . DS . 'TestTheme' . DS . 'Layouts' . DS . 'default.ctp';
$result = $ThemeView->getLayoutFileName('default');
$this->assertEquals($expected, $result);
}
@ -421,15 +425,15 @@ class ViewTest extends CakeTestCase {
$View = new TestView($this->Controller);
App::build(array(
'Plugin' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'Plugin' . DS),
'View' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'View'. DS)
'View' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'View' . DS)
));
$pluginPath = CakePlugin::path('TestPlugin');
$expected = CAKE . 'Test' . DS . 'test_app' . DS . 'Plugin' . DS .'TestPlugin' . DS . 'View' . DS .'Tests' . DS .'index.ctp';
$expected = CAKE . 'Test' . DS . 'test_app' . DS . 'Plugin' . DS . 'TestPlugin' . DS . 'View' . DS . 'Tests' . DS . 'index.ctp';
$result = $View->getViewFileName('index');
$this->assertEquals($expected, $result);
$expected = $pluginPath. 'View' . DS . 'Layouts' . DS .'default.ctp';
$expected = $pluginPath . 'View' . DS . 'Layouts' . DS . 'default.ctp';
$result = $View->getLayoutFileName();
$this->assertEquals($expected, $result);
}
@ -448,29 +452,29 @@ class ViewTest extends CakeTestCase {
$View = new TestView($this->Controller);
$expected = CAKE . 'Test' . DS . 'test_app' . DS . 'View' . DS .'Pages' . DS .'home.ctp';
$expected = CAKE . 'Test' . DS . 'test_app' . DS . 'View' . DS . 'Pages' . DS . 'home.ctp';
$result = $View->getViewFileName('home');
$this->assertEquals($expected, $result);
$expected = CAKE . 'Test' . DS . 'test_app' . DS . 'View' . DS .'Posts' . DS .'index.ctp';
$expected = CAKE . 'Test' . DS . 'test_app' . DS . 'View' . DS . 'Posts' . DS . 'index.ctp';
$result = $View->getViewFileName('/Posts/index');
$this->assertEquals($expected, $result);
$expected = CAKE . 'Test' . DS . 'test_app' . DS . 'View' . DS .'Posts' . DS .'index.ctp';
$expected = CAKE . 'Test' . DS . 'test_app' . DS . 'View' . DS . 'Posts' . DS . 'index.ctp';
$result = $View->getViewFileName('../Posts/index');
$this->assertEquals($expected, $result);
$expected = CAKE . 'Test' . DS . 'test_app' . DS . 'View' . DS .'Pages' . DS .'page.home.ctp';
$expected = CAKE . 'Test' . DS . 'test_app' . DS . 'View' . DS . 'Pages' . DS . 'page.home.ctp';
$result = $View->getViewFileName('page.home');
$this->assertEquals($expected, $result, 'Should not ruin files with dots.');
CakePlugin::load('TestPlugin');
$expected = CAKE . 'Test' . DS . 'test_app' . DS . 'View' . DS .'Pages' . DS .'home.ctp';
$expected = CAKE . 'Test' . DS . 'test_app' . DS . 'View' . DS . 'Pages' . DS . 'home.ctp';
$result = $View->getViewFileName('TestPlugin.home');
$this->assertEquals($expected, $result, 'Plugin is missing the view, cascade to app.');
$View->viewPath = 'Tests';
$expected = CAKE . 'Test' . DS . 'test_app' . DS . 'Plugin' . DS . 'TestPlugin' . DS . 'View' . DS .'Tests' . DS .'index.ctp';
$expected = CAKE . 'Test' . DS . 'test_app' . DS . 'Plugin' . DS . 'TestPlugin' . DS . 'View' . DS . 'Tests' . DS . 'index.ctp';
$result = $View->getViewFileName('TestPlugin.index');
$this->assertEquals($expected, $result);
}
@ -488,7 +492,7 @@ class ViewTest extends CakeTestCase {
$View = new TestView($this->Controller);
$expected = CAKE . 'Test' . DS . 'test_app' . DS . 'View' . DS . 'Layouts' . DS .'default.ctp';
$expected = CAKE . 'Test' . DS . 'test_app' . DS . 'View' . DS . 'Layouts' . DS . 'default.ctp';
$result = $View->getLayoutFileName();
$this->assertEquals($expected, $result);
@ -517,12 +521,12 @@ class ViewTest extends CakeTestCase {
$View = new TestView($this->Controller);
CakePlugin::load('TestPlugin');
$expected = CAKE . 'Test' . DS . 'test_app' . DS . 'Plugin' . DS . 'TestPlugin' . DS . 'View' . DS . 'Layouts' . DS .'default.ctp';
$expected = CAKE . 'Test' . DS . 'test_app' . DS . 'Plugin' . DS . 'TestPlugin' . DS . 'View' . DS . 'Layouts' . DS . 'default.ctp';
$result = $View->getLayoutFileName('TestPlugin.default');
$this->assertEquals($expected, $result);
$View->plugin = 'TestPlugin';
$expected = CAKE . 'Test' . DS . 'test_app' . DS . 'Plugin' . DS . 'TestPlugin' . DS . 'View' . DS . 'Layouts' . DS .'default.ctp';
$expected = CAKE . 'Test' . DS . 'test_app' . DS . 'Plugin' . DS . 'TestPlugin' . DS . 'View' . DS . 'Layouts' . DS . 'default.ctp';
$result = $View->getLayoutFileName('default');
$this->assertEquals($expected, $result);
}
@ -1042,10 +1046,9 @@ class ViewTest extends CakeTestCase {
$result = $View->getViewFileName('../Themed/TestTheme/Posts/index');
$this->assertRegExp('/Themed(\/|\\\)TestTheme(\/|\\\)Posts(\/|\\\)index.ctp/', $result);
$expected = CAKE . 'Test' . DS . 'test_app' . DS . 'View' . DS .'Posts' . DS .'index.ctp';
$expected = CAKE . 'Test' . DS . 'test_app' . DS . 'View' . DS . 'Posts' . DS . 'index.ctp';
$result = $View->getViewFileName('../Posts/index');
$this->assertEquals($expected, $result);
}
/**
@ -1114,44 +1117,6 @@ class ViewTest extends CakeTestCase {
$this->assertNotRegExp('/cake:nocache/', $result);
}
/**
* testRenderNocache method
*
* @return void
*/
/* This is a new test case for a pending enhancement
public function testRenderNocache() {
$this->PostsController->helpers = array('Cache', 'Html');
$this->PostsController->constructClasses();
$this->PostsController->cacheAction = 21600;
$this->PostsController->here = '/posts/nocache_multiple_element';
$this->PostsController->action = 'nocache_multiple_element';
$this->PostsController->nocache_multiple_element();
Configure::write('Cache.check', true);
Configure::write('Cache.disable', false);
$filename = CACHE . 'views' . DS . 'posts_nocache_multiple_element.php';
$View = new TestView($this->PostsController);
$View->render();
ob_start();
$View->renderCache($filename, getMicroTime());
$result = ob_get_clean();
@unlink($filename);
$this->assertRegExp('/php echo \$foo;/', $result);
$this->assertRegExp('/php echo \$bar;/', $result);
$this->assertRegExp('/php \$barfoo = \'in sub2\';/', $result);
$this->assertRegExp('/php echo \$barfoo;/', $result);
$this->assertRegExp('/printing: "in sub2"/', $result);
$this->assertRegExp('/php \$foobar = \'in sub1\';/', $result);
$this->assertRegExp('/php echo \$foobar;/', $result);
$this->assertRegExp('/printing: "in sub1"/', $result);
}
*/
/**
* testSet method
*

View file

@ -64,7 +64,7 @@ class XmlViewTest extends CakeTestCase {
$output = $View->render(false);
$expected = array(
'response' => array('no' =>$data['no'], 'user' => $data['user'])
'response' => array('no' => $data['no'], 'user' => $data['user'])
);
$this->assertIdentical(Xml::build($expected)->asXML(), $output);
$this->assertIdentical('application/xml', $Response->type());