Skip to content
Permalink
Browse files

Remove deprecated method usage in tests. Make typehinting possible wh…

…ich reveals coding errors.
  • Loading branch information...
dereuromark committed Nov 24, 2016
1 parent 256b2e0 commit 9df5f574fe816459a969f4d2fcb44e17bea45d99
@@ -43,6 +43,11 @@ class HelperRegistryTest extends TestCase
*/
public $Helpers;
/**
* @var \Cake\Event\EventManager
*/
public $Events;
/**
* setUp
*
@@ -241,7 +246,7 @@ public function testReset()
);
$this->assertCount(1, $this->Events->listeners('View.beforeRender'));
$this->assertNull($this->Helpers->reset(), 'No return expected');
$this->Helpers->reset();
$this->assertCount(0, $this->Events->listeners('View.beforeRender'));
$this->assertNotSame($instance, $this->Helpers->load('EventListenerTest'));
@@ -44,19 +44,6 @@ class TestHelper extends Helper
*/
public $helpers = ['Html', 'TestPlugin.OtherHelper'];
/**
* expose a method as public
*
* @param string $options
* @param string $exclude
* @param string $insertBefore
* @param string $insertAfter
* @return void
*/
public function parseAttributes($options, $exclude = null, $insertBefore = ' ', $insertAfter = null)
{
return $this->_parseAttributes($options, $exclude, $insertBefore, $insertAfter);
}
}
/**
@@ -65,6 +52,11 @@ public function parseAttributes($options, $exclude = null, $insertBefore = ' ',
class HelperTest extends TestCase
{
/**
* @var \Cake\View\View
*/
public $View;
/**
* setUp method
*
@@ -76,8 +68,6 @@ public function setUp()
Router::reload();
$this->View = new View();
$this->Helper = new Helper($this->View);
$this->Helper->request = new Request();
}
/**
@@ -91,7 +81,7 @@ public function tearDown()
Configure::delete('Asset');
Plugin::unload();
unset($this->Helper, $this->View);
unset($this->View);
}
/**
@@ -241,7 +241,7 @@ public function testRenderWithoutView($data, $serialize, $jsonOptions, $expected
$Controller->set($data);
$Controller->set('_serialize', $serialize);
$Controller->set('_jsonOptions', $jsonOptions);
$Controller->viewBuilder()->className('Json');
$Controller->viewBuilder()->setClassName('Json');
$View = $Controller->createView();
$output = $View->render(false);
@@ -264,7 +264,7 @@ public function testRenderSerializeNoHelpers()
'tags' => ['cakephp', 'framework'],
'_serialize' => 'tags'
]);
$Controller->viewBuilder()->className('Json');
$Controller->viewBuilder()->setClassName('Json');
$View = $Controller->createView();
$View->render();
@@ -288,7 +288,7 @@ public function testJsonpResponse()
'_serialize' => 'data',
'_jsonp' => true
]);
$Controller->viewBuilder()->className('Json');
$Controller->viewBuilder()->setClassName('Json');
$View = $Controller->createView();
$output = $View->render(false);
@@ -330,7 +330,7 @@ public function testRenderWithView()
]
];
$Controller->set('user', $data);
$Controller->viewBuilder()->className('Json');
$Controller->viewBuilder()->setClassName('Json');
$View = $Controller->createView();
$View->viewPath = $Controller->name;
$output = $View->render('index');
@@ -41,6 +41,11 @@ class TestStringTemplate
class StringTemplateTraitTest extends TestCase
{
/**
* @var TestStringTemplate
*/
public $Template;
/**
* setUp method
*
@@ -62,13 +67,13 @@ public function testInitStringTemplates()
$templates = [
'text' => '<p>{{text}}</p>',
];
$this->Template->templates($templates);
$this->Template->setTemplates($templates);
$this->assertEquals(
[
'text' => '<p>{{text}}</p>'
],
$this->Template->templates(),
$this->Template->getTemplates(),
'newly added template should be included in template list'
);
}
@@ -89,7 +94,7 @@ public function testInitStringTemplatesArrayForm()
[
'text' => '<p>{{text}}</p>'
],
$this->Template->templates(),
$this->Template->getTemplates(),
'Configured templates should be included in template list'
);
}
@@ -104,7 +109,7 @@ public function testFormatStringTemplate()
$templates = [
'text' => '<p>{{text}}</p>',
];
$this->Template->templates($templates);
$this->Template->setTemplates($templates);
$result = $this->Template->formatTemplate('text', [
'text' => 'CakePHP'
]);
@@ -124,7 +129,7 @@ public function testGetTemplater()
$templates = [
'text' => '<p>{{text}}</p>',
];
$this->Template->templates($templates);
$this->Template->setTemplates($templates);
$result = $this->Template->templater();
$this->assertInstanceOf('Cake\View\StringTemplate', $result);
}
@@ -114,15 +114,15 @@ public function testBuildComplete()
$events = $this->getMockBuilder('Cake\Event\EventManager')->getMock();
$builder = new ViewBuilder();
$builder->name('Articles')
->className('Ajax')
->template('edit')
->layout('default')
->templatePath('Articles/')
->helpers(['Form', 'Html'])
->layoutPath('Admin/')
->theme('TestTheme')
->plugin('TestPlugin');
$builder->setName('Articles')
->setClassName('Ajax')
->setTemplate('edit')
->setLayout('default')
->setTemplatePath('Articles/')
->setHelpers(['Form', 'Html'])
->setLayoutPath('Admin/')
->setTheme('TestTheme')
->setPlugin('TestPlugin');
$view = $builder->build(
['one' => 'value'],
$request,
@@ -180,7 +180,7 @@ public function testBuildAppViewPresent()
public function testBuildMissingViewClass()
{
$builder = new ViewBuilder();
$builder->className('Foo');
$builder->setClassName('Foo');
$builder->build();
}
@@ -194,10 +194,10 @@ public function testJsonSerialize()
$builder = new ViewBuilder();
$builder
->template('default')
->layout('test')
->helpers(['Html'])
->className('JsonView');
->setTemplate('default')
->setLayout('test')
->setHelpers(['Html'])
->setClassName('JsonView');
$result = json_decode(json_encode($builder), true);
@@ -223,19 +223,19 @@ public function testCreateFromArray()
$builder = new ViewBuilder();
$builder
->template('default')
->layout('test')
->helpers(['Html'])
->className('JsonView');
->setTemplate('default')
->setLayout('test')
->setHelpers(['Html'])
->setClassName('JsonView');
$result = json_encode($builder);
$builder = new ViewBuilder();
$builder->createFromArray(json_decode($result, true));
$this->assertEquals('default', $builder->template());
$this->assertEquals('test', $builder->layout());
$this->assertEquals(['Html'], $builder->helpers());
$this->assertEquals('JsonView', $builder->className());
$this->assertEquals('default', $builder->getTemplate());
$this->assertEquals('test', $builder->getLayout());
$this->assertEquals(['Html'], $builder->getHelpers());
$this->assertEquals('JsonView', $builder->getClassName());
}
}
@@ -279,6 +279,16 @@ class ViewTest extends TestCase
*/
public $fixtures = ['core.posts', 'core.users'];
/**
* @var \Cake\View\View
*/
public $View;
/**
* @var ViewPostsController
*/
public $PostsController;
/**
* setUp method
*
@@ -22,6 +22,11 @@
class ViewVarsTraitTest extends TestCase
{
/**
* @var \Cake\Controller\Controller;
*/
public $subject;
/**
* setup
*
@@ -79,7 +84,7 @@ public function testSetChained()
*
* @return void
*/
public function testSetTwoParamCombind()
public function testSetTwoParamCombined()
{
$keys = ['one', 'key'];
$vals = ['two', 'val'];
@@ -183,7 +188,7 @@ public function testViewOptionsGetsToBuilder()
{
$this->subject->passedArgs = 'test';
$this->subject->createView();
$result = $this->subject->viewbuilder()->options();
$result = $this->subject->viewBuilder()->getOptions();
$this->assertEquals(['passedArgs' => 'test'], $result);
}
@@ -196,7 +201,7 @@ public function testCreateViewViewClass()
{
$this->subject->viewClass = 'Json';
$view = $this->subject->createView();
$this->assertInstanceof('Cake\View\JsonView', $view);
$this->assertInstanceOf('Cake\View\JsonView', $view);
}
/**
@@ -206,10 +211,10 @@ public function testCreateViewViewClass()
*/
public function testCreateViewViewBuilder()
{
$this->subject->viewBuilder()->className('Xml');
$this->subject->viewBuilder()->setClassName('Xml');
$this->subject->viewClass = 'Json';
$view = $this->subject->createView();
$this->assertInstanceof('Cake\View\XmlView', $view);
$this->assertInstanceOf('Cake\View\XmlView', $view);
}
/**
@@ -219,10 +224,10 @@ public function testCreateViewViewBuilder()
*/
public function testCreateViewParameter()
{
$this->subject->viewBuilder()->className('View');
$this->subject->viewBuilder()->setClassName('View');
$this->subject->viewClass = 'Json';
$view = $this->subject->createView('Xml');
$this->assertInstanceof('Cake\View\XmlView', $view);
$this->assertInstanceOf('Cake\View\XmlView', $view);
}
/**

0 comments on commit 9df5f57

Please sign in to comment.
You can’t perform that action at this time.