ZF-11275: PHPUnit_Framework_AssertionFailedError : Failed asserting last action used <"get-Resume"> was "getResume"

Description

Some problems with camelCased action in default tests.

STR: 1. Create new app using Zend_Tool. 2. Create some camelCased action (using Zend_Tool) like "getResume". 3. Run generated tests.

Comments

I've reproduced the issue: (Zend_Tool output clipped for brevity)


[webadmin@spiral ZF-11275]$ zf create project app app
[webadmin@spiral ZF-11275]$ cd app
[webadmin@spiral app]$ zf create controller test
[webadmin@spiral app]$ zf create action myCamelCaseTest Test
[webadmin@spiral app]$ cd tests
[webadmin@spiral tests]$ phpunit
PHPUnit 3.5.13 by Sebastian Bergmann.

.F.

Time: 0 seconds, Memory: 12.00Mb

There was 1 failure:

1) TestControllerTest::testMyCamelCaseTestAction
Failed asserting last action used <"my-Camel-Case-Test"> was "myCamelCaseTest"

/usr/local/apache2/htdocs/lib/ZendFramework-1.11.4/library/Zend/Test/PHPUnit/ControllerTestCase.php:1041
/usr/local/apache2/htdocs/test/zf/ZF-11275/app/tests/application/controllers/TestControllerTest.php:37

FAILURES!
Tests: 3, Assertions: 11, Failures: 1.

The issue is that the test is generated using the controller action function name format (ie: testCamelCase) instead of the url format (ie: test-camel-case). This can be fixed by changing the auto-generated test stub like so:


31,32c31
<         $urlParams = $this->urlizeOptions($params);
<         $url = $this->url($urlParams);
---
>         $url = $this->url($this->urlizeOptions($params));
36,38c35,37
<         $this->assertModule($urlParams['module']);
<         $this->assertController($urlParams['controller']);
<         $this->assertAction($urlParams['action']);
---
>         $this->assertModule($params['module']);
>         $this->assertController($params['controller']);
>         $this->assertAction($params['action']);

The unit test passes after I make this change.

I've updated Zend_Tool_Project_Context_Zf_TestApplicationActionMethod to reflect the "fixed" action test format and attached a patch against trunk. Here's what happens when I follow the reproduction steps after applying the patch:


[webadmin@spiral ZF-11275]$ zf.sh show version
Zend Framework Version: 1.11.0dev

[webadmin@spiral ZF-11275]$ zf.sh show version
[webadmin@spiral ZF-11275]$ mkdir app2 ; zf.sh create project app2 app2
Creating project at ZF-11275/app2
Note: This command created a web project, for more information setting up your VHOST, please see docs/README

[webadmin@spiral ZF-11275]$ cd app2
[webadmin@spiral app2]$ zf.sh create controller CamelCaseTest
Creating a controller at ZF-11275/app2/application/controllers/CamelCaseTestController.php
Creating an index action method in controller CamelCaseTest
Creating a view script for the index action method at ZF-11275/app2/application/views/scripts/camel-case-test/index.phtml
Creating a controller test file at ZF-11275/app2/tests/application/controllers/CamelCaseTestControllerTest.php
Updating project profile 'ZF-11275/app2/.zfproject.xml'

[webadmin@spiral app2]$ zf.sh create action camelCaseTest CamelCaseTest
Creating an action named camelCaseTest inside controller at ZF-11275/app2/application/controllers/CamelCaseTestController.php
Creating an action test in ZF-11275/app2/tests/application/controllers/CamelCaseTestControllerTest.php
Updating project profile 'ZF-11275/app2/.zfproject.xml'
Creating a view script for the camelCaseTest action method at ZF-11275/app2/application/views/scripts/camel-case-test/camel-case-test.phtml
Updating project profile 'ZF-11275/app2/.zfproject.xml'

[webadmin@spiral app2]$ less ZF-11275/app2/tests/application/controllers/CamelCaseTestControllerTest.php
[webadmin@spiral app2]$ cd tests
[webadmin@spiral tests]$ phpunit
PHPUnit 3.5.13 by Sebastian Bergmann.

...

Time: 0 seconds, Memory: 12.00Mb

OK (3 tests, 12 assertions)

Comments?

Fixed in trunk r23943

Fixed in 1.11 at r23982