Testing ZF2 apps -- best practices?

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Testing ZF2 apps -- best practices?

demiankatz

I’m just curious if there is documentation somewhere on testing a ZF2 application.  I don’t see any ZF2 equivalent of the old Zend_Test_PHPUnit_ControllerTestCase class.  I understand that with dependency injection and the new controller model, it’s easier to test individual components of a system, but it would still be nice to build some end-to-end smoke tests to make sure pages are rendering correctly.  Is this something that’s coming further down the roadmap, or am I just missing an existing feature?

 

thanks,
Demian

Reply | Threaded
Open this post in threaded view
|

Re: Testing ZF2 apps -- best practices?

Jurian Sluiman
CONTENTS DELETED
The author has deleted this message.
Reply | Threaded
Open this post in threaded view
|

Re: Testing ZF2 apps -- best practices?

SocalNick
Demian,

Here is how I test my entire application: https://gist.github.com/3147364

If you are just testing a module, check out the test framework I've added to ZendSkeletonModule: https://github.com/zendframework/ZendSkeletonModule


-Nick (@SocalNick)


On Thu, Jul 19, 2012 at 1:14 PM, Jurian Sluiman <[hidden email]> wrote:
2012/7/19 Demian Katz <[hidden email]>

I’m just curious if there is documentation somewhere on testing a ZF2 application.  I don’t see any ZF2 equivalent of the old Zend_Test_PHPUnit_ControllerTestCase class.  I understand that with dependency injection and the new controller model, it’s easier to test individual components of a system, but it would still be nice to build some end-to-end smoke tests to make sure pages are rendering correctly.  Is this something that’s coming further down the roadmap, or am I just missing an existing feature?

 

thanks,
Demian


There are a few examples which you can have a look at.

1. A very simple module with only a dependency on Zend\View, able to test with Composer integration: https://github.com/juriansluiman/SlmGoogleAnalytics [note: this is my module]
2. A more complex module which requires the SkeletonApplication to load for integration tests: https://github.com/doctrine/DoctrineORMModule
3. A blog post from Tom Oram about discovering ZF2. Here's his post about unit testing ZF2 controllers: http://devblog.x2k.co.uk/unit-testing-a-zend-framework-2-controller/

As you see, there are a few possibilities to start testing independent modules or taking the holistic approach. You can also have a look at Selenium, to fire requests and check if the response contains some specific html (for example) to get full integration tests.
--
Jurian Sluiman

Reply | Threaded
Open this post in threaded view
|

RE: Testing ZF2 apps -- best practices?

Roediger, Tim
In reply to this post by Jurian Sluiman

I have a small module to help with unit testing: https://github.com/superdweebie/moduleUnitTester

 

It allows you to set a testing specific composer.json and application.config, and then runs the whole mvc while testing – also makes it easy to have a Travis CI script that that loads the skeletonApplication and uses the same testing configuration.

 

You can see it in action on another module like https://github.com/superdweebie/doctrineExtensionsModule

 

Tim Roediger

 

From: Jurian Sluiman [[hidden email]]
Sent: Friday, 20 July 2012 6:15 AM
To: Demian Katz
Cc: [hidden email]
Subject: Re: [zf-contributors] Testing ZF2 apps -- best practices?

 

2012/7/19 Demian Katz <[hidden email]>

I’m just curious if there is documentation somewhere on testing a ZF2 application.  I don’t see any ZF2 equivalent of the old Zend_Test_PHPUnit_ControllerTestCase class.  I understand that with dependency injection and the new controller model, it’s easier to test individual components of a system, but it would still be nice to build some end-to-end smoke tests to make sure pages are rendering correctly.  Is this something that’s coming further down the roadmap, or am I just missing an existing feature?

 

thanks,
Demian


There are a few examples which you can have a look at.

 

1. A very simple module with only a dependency on Zend\View, able to test with Composer integration: https://github.com/juriansluiman/SlmGoogleAnalytics [note: this is my module]

2. A more complex module which requires the SkeletonApplication to load for integration tests: https://github.com/doctrine/DoctrineORMModule

3. A blog post from Tom Oram about discovering ZF2. Here's his post about unit testing ZF2 controllers: http://devblog.x2k.co.uk/unit-testing-a-zend-framework-2-controller/

 

As you see, there are a few possibilities to start testing independent modules or taking the holistic approach. You can also have a look at Selenium, to fire requests and check if the response contains some specific html (for example) to get full integration tests.

--
Jurian Sluiman

Reply | Threaded
Open this post in threaded view
|

Re: Testing ZF2 apps -- best practices?

Sascha-Oliver Prolic
In reply to this post by demiankatz
2012/7/19 Demian Katz <[hidden email]>:

> I’m just curious if there is documentation somewhere on testing a ZF2
> application.  I don’t see any ZF2 equivalent of the old
> Zend_Test_PHPUnit_ControllerTestCase class.  I understand that with
> dependency injection and the new controller model, it’s easier to test
> individual components of a system, but it would still be nice to build some
> end-to-end smoke tests to make sure pages are rendering correctly.  Is this
> something that’s coming further down the roadmap, or am I just missing an
> existing feature?
>
>
>
> thanks,
> Demian

Hi Demian,
Hi all,

there is also HumusPHPUnitModule (https://github.com/prolic/HumusPHPUnitModule).
It is able to test all your zf2 modules and libraries at once.

Best Regards

Sascha

--
Sascha-Oliver Prolic