-
Notifications
You must be signed in to change notification settings - Fork 166
controller tests do not load custom layout template #60
Comments
I tried to reproduce your bug but with no luck: public function testDispatch()
{
$this->dispatch('');
$this->assertRequestRoute('cms/index/index');
$this->assertLayoutBlockCreated('left');
$this->assertLayoutBlockCreated('right');
$this->assertLayoutBlockRendered('content');
$this->assertLayoutBlockTypeOf('left', 'core/text_list');
$this->assertLayoutBlockNotTypeOf('left', 'core/links');
$this->assertResponseBodyContains('Magento');
$this->assertResponseBodyContains('Home Page');
$this->assertResponseBodyContains('Compare Products');
$this->assertResponseBodyNotContains('Non existing text');
// This will fail!
# $this->assertResponseBodyContains('Non existing text');
} However I have some thoughts about your problem in general, it might be possible that you haven't specified your design/theme configuration for test case, since tests are executed agains default database, which design settings are:
So don't forget to specify your design in fixture, it is very easy: config:
default/design/package/name: your_package
default/design/theme/default: your_theme |
I'm not sure I follow 100%. Why is it necessary to specify any fixtures at all for a test like If I don't have any custom design or theme, what are good values to use On Fri, 2013-01-04 at 11:18 -0800, Ivan Chepurnyi wrote:
The coming out tells the story. savon - Saving your work to svn |
You mentioned in the title of your ticket "load custom layout template", that supposed to mean that you have a custom layout file in custom theme that is somehow cannot not load template on particular page. That's why I suggested you to change current design package theme via fixture. It is mostly because test database is not a copy of your live db instance it is clean install though db upgrade scripts. If you haven't specified your theme in XML file or db upgrade, then it uses default Magento theme and your test case will not work! Test framework is not affecting in any way the layout XML building and template file inclusion procedure and if you checked the following test case I provided to you, you'll see that assertResponseBodyContains() method is working without any problems. |
I've written a controller test and am asserting that what's in my .phtml comes out in the test.
When I go to the page in the browser, the .phtml content is there.
When I assert for it in the test case, it's not.
The controller action is simply load/render.
The phtml is simply a php file printing one line.
The test is:
(I use a custom assertResponseBodyContains because I found the standard one did not work - are there any unit tests out there in a git repo that use it that I can check ?)
public function _assertResponseBodyContains($string)
{
$body = $this->getResponse()->getOutputBody();
$constraint = $this->stringContains($string);
$this->assertThat($body, $constraint);
}
Are there any known and working tests of controllers out there ? Preferably one with a custom layout template ?
The text was updated successfully, but these errors were encountered: