Note that there are some explanatory texts on larger screens.

plurals
  1. POTrouble with the ZF2 Getting Started tutorial and PHPUnit
    text
    copied!<p>In the "<a href="http://zf2.readthedocs.org/en/latest/user-guide/overview.html" rel="nofollow">Getting Started with Zend Framework 2</a>" tutorial there is an example for the basic unit testing of the application: <a href="http://zf2.readthedocs.org/en/latest/user-guide/unit-testing.html" rel="nofollow">http://zf2.readthedocs.org/en/latest/user-guide/unit-testing.html</a> I've just copied the code (had only to change <code>include __DIR__ . '/../init_autoloader.php';</code> to <code>include __DIR__ . '/../../../init_autoloader.php';</code>) and now I'm getting an error:</p> <pre><code>root@devmv:/var/www/sandbox/zf2sandbox/module/Application/test# phpunit PHPUnit 3.7.13 by Sebastian Bergmann. Configuration read from /var/www/sandbox/zf2sandbox/module/Application/test/phpunit.xml E Time: 0 seconds, Memory: 3.75Mb There was 1 error: 1) ApplicationTest\Controller\IndexControllerTest::testIndexActionCanBeAccessed array_replace_recursive(): Argument #1 is not an array /lib/ZendFramework/ZendFramework-2.1.0/library/Zend/Test/PHPUnit/Controller/AbstractControllerTestCase.php:144 /lib/ZendFramework/ZendFramework-2.1.0/library/Zend/Test/PHPUnit/Controller/AbstractControllerTestCase.php:173 /lib/ZendFramework/ZendFramework-2.1.0/library/Zend/Test/PHPUnit/Controller/AbstractControllerTestCase.php:193 /lib/ZendFramework/ZendFramework-2.1.0/library/Zend/Test/PHPUnit/Controller/AbstractControllerTestCase.php:236 /var/www/sandbox/zf2sandbox/module/Application/test/ApplicationTest/Controller/IndexControllerTest.php:18 FAILURES! Tests: 1, Assertions: 0, Errors: 1. </code></pre> <p>When I use only the standard PHPUnit assertion methodes like assertEmpty(...), it works fine.</p> <p>Here is my IndexControllerTest.php:</p> <pre><code>&lt;?php namespace ApplicationTest\Controller; use Zend\Test\PHPUnit\Controller\AbstractHttpControllerTestCase; class IndexControllerTest extends AbstractHttpControllerTestCase { public function setUp() { $this-&gt;setApplicationConfig( include '/var/www/sandbox/zf2sandbox/config/test/application.config.php' ); parent::setUp(); } public function testIndexActionCanBeAccessed() { $this-&gt;dispatch('/'); $this-&gt;assertResponseStatusCode(200); $this-&gt;assertModuleName('application'); $this-&gt;assertControllerName('application_index'); $this-&gt;assertControllerClass('IndexController'); $this-&gt;assertMatchedRouteName('home'); // $this-&gt;assertEmpty(null); } } </code></pre> <p>Can somebody help?</p> <p>Thx</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload