laminas / laminas-test

Tools to facilitate integration testing of laminas-mvc applications
https://docs.laminas.dev/laminas-test/
BSD 3-Clause "New" or "Revised" License
14 stars 24 forks source link

`assertTemplateName` returns too early #3

Closed weierophinney closed 1 month ago

weierophinney commented 4 years ago

assertTemplateName appears to return too early, and does not recursively search all child templates (see below).

<?php

public function myAction()
{
    $vm = new ViewModel();

    $child1 = (new ViewModel())->setTemplate('foo');
    $child2 = (new ViewModel())->setTemplate('bar');

    $vm->addChild($child1);
    $vm->addChild($child2);

    return $vm;
}

...

class testCase extends AbstractHttpControllerTestCase {

    public function testMyAction()
    {
        $this->dispatch('/my/action', 'GET', []);
        $this->assertTemplateName('foo'); // <-- true
        $this->assertTemplateName('bar'); // <-- false
    }

}

Originally posted by @SorX14 at https://github.com/zendframework/zend-test/issues/59

visto9259 commented 1 month ago

This is a very old issue but I was able to reproduce it with the latest version. The function searchTemplates() cycles through the tree of children correctly except when a view has more than one child where it returns early if the first child's template does not match the asserted template. Assign it to me and I will fix it.