I would like to use codeception as a testing framework in my existing zend framework 2 project. I installed codeception via composer but i dont know what to do next to get my first tests running.
I found the following github file but i dont really understand for what this is good for.
ZF2 Module - Codeception
Can someone tell me what to do next ?
THX
Since acceptance tests are not FW dependent (Codeception accesses your web application via URL), you shouldn't have problems with running those tests. I was following these great tutorials from Jeffrey, and I really advice you check them out if you have no idea where to start: https://tutsplus.com/course/modern-testing-in-php-with-codeception/
However, I still didn't figure out how to configure CC to run functional tests on ZF2 (I think this is the only hard part, since form here on you just use pre-defined TestGuy methods), neither I found any examples online, so I really hope that someone who got this working will be able to provide a more complete answer or maybe even share a config example. In case I find a way I'll update my answer at that point.
Related
I recently started with the unit testing for my php website made in CodeIgniter 1.7.2. I want to test my web site using PHPUnit.
So I Googled it and came to know that there is a library for CodeIgniter & PHPUnit Bridge: http://www.foostack.com/foostack/. I have followed all the steps, and got the code running, but when I execute a test case from console, my default controller is executed and the html for the page is printed on the console.
Can any one please tell me what exactly is happening or am I doing something wrong? Also if any one has any other ideas to test the model without using the foostack library please suggest it. Please let me know if any other details are required.
Thanks in Advance.
CodeIgniter is not an ideal framework where you can unit test your code with PHPUnit. I have myself tried using FooStack once and was successful then, but it is too cumbersome. There is no way of testing a model isolated in CI because of the god object CI makes.
You can however try SimpleTest, here is a good library that can help you with it: https://github.com/ericbarnes/codeigniter-simpletest
Other than that there is the Unit Test library provided with CI - which in nowhere near a full unit testing framework, but does let you do basic assertions, reporting etc.
If you're really serious about unit testing, I'd suggest you move to frameworks that value this. My favorite is Zend Framework, but there are other good ones as well: Symfony, Kohana, Lithium, etc.
I do some PHP with Kohana 3 (IDE:Netbeans), and got excited about idea of writing tests for code. It sounds pretty cool thing to do, but i have few complications and worries.
Why using Kohana unittest module in browser is like 5 times faster then running tests in Netbeans or command Line ?
How could i exclude all kohana internal tests? In the PHPUnit .xml configuration file ?
Why when run any test i've got in Netbeans panel two entries for it - one with yellow triangle (it says 'file x skipped'), and entry with normal test result. I do get that double entries for every test, also those native from Kohana. I don't mind but it's strange.
All over the Web i see examples, tutorials and screencasts of PHPUnit with sample classes and methods that add two numbers or displays name or do some other trivial things. I've learnt to do those kind of assertions, but how could i test my code in Kohana? My Models are 90% ORM stuff. Controllers? How? Any 'How-tos' and examples are welcome.
I've seen in Ruby tutorial about Rspec a way to test DB by using testing enviroment Databse and rollbacks after finisning tests. Also user actions like clicking links were simulated. Is it possible with PHPUnit ?
There always has been a lot of discussion on what has to be tested and what has not to be tested. Generally my opinion is that you shouldn't test things that should work, like the database driver and connection, this has little to do with your code. Some then argue that you should be able to test it anyway, but in most environment this isn't an easy thing to do and usually a big hassle.
Generally controller actions should be tested as well as any helpers or modules you've written. Usually one uses the paradigm of a mocking framework to get around the database. The good thing about this is a gigantic speed increase in your testing. There are several PHP mocking frameworks as well I suppose.
Another great thing to keep in mind is that you also have user testing. This cannot be simulated with the kind of tests you write in kohana. For this it is interesting to look at http://seleniumhq.org/
It's probably better to split such a rambling question into multiple SO questions.
No idea. Perhaps there's an invocation overhead for NetBeans to invoke phpunit, compared to apache passing the request to PHP.
That might be possible, or you could find a way to set the following option: --exclude-group kohana
No idea sorry.
AFAIK PHPUnit can't do client-interaction tests. How to do system behaviour testing could be a question on its own.
I am in the process of planning a custom web application which will be sold (not SaaS) and so will be required to be installed on different servers. Do you think it would be a bad/good idea to go with Symfony2 or Zend Framework.
I have to choose 1 and can't go with any other framework as I only have extensive knowledge with both of these. Despite my experience with Symfony2, I would still appreciate another opinion.
My main concerns are ease of install on servers and source code protection. Sadly, it would seem ZF already has this going for it in that you don't need 5.3 like Symfony2, and we have Zend Guard.
Any advice is welcome! I am looking to nurture and grow this app and I really want to be sure the first step is the right one.
The Symfony2 download page still says:
Be warned that Symfony 2.0 is not
stable yet; use it with caution
(current version is Beta 1).
So I would wait just a but for Symfony2.
I'm not sure what you mean by source code protection but there is no point in encoding any part of any of the two frameworks since they are both open source (and you should see if their licenses actually do permit that!).
Zend Framework 2 is still in the oven and for the looks of it, Symfony2 will be out of beta way before ZF2. If you can't wait, then use the one that you are most comfortable with. Otherwise, wait for Symfony2 to come out of beta and then wait a little bit more until they iron out it's bugs.
Now, about bundling the framework in your application, you are probably going to need to write an installer of sorts. You could first look at the "sandbox" version of Symfony to see how they did that. It's basically an unzip-it-and-it-works kind of install. No need to set anything up. That could give you some pointers.
Whatever you do, you'll need to write a minimum specs script that users can download and run to check whether their system has everything ready to run your app (check configs, php modules, etc, etc). See SlideShowPro Director for an example of such scripts.
Subjective answer: I'd go with ZF because that's what I know better, but having said that, performance wise I've had better results with Symfony. Apparently ZF2 will have see huge speed improvements.
Hai
I want to create a project in Zend framework, but I don't know any idea about how to include this zend framework in to wamp server.
Any one please helps me...?
Thanks in advance..
It seems you need a tutorial to start from scratch, I'd say.
Here are a couple of links that could interest you :
Survive The Deep End! : a free electronic-book about ZF
It's still work in progress,
but the Chapter 4. Installing The Zend Framework is finished, and gives several way to use ZF
Don't forget to read to other chapters too, btw ;-)
The official Quickstart
Those might be helpful, for you to start.
And here are some other resources :
The official Reference Guide -- not quite perfect as a starting point, but contains the documentation of every classes ; you'll work with this one pretty often, I guess !
A couple of screencasts (including one about Installing ZF)
There are also webinars, and a couple podcasts
More advanced, there are interesting articles about ZF on devzone
Of course, you can find books about ZF, too. For instance :
Beginning Zend Framework
Zend Framework in Action
All you need to do is ensure that the Zend/lib directory from the framework download is in your include path.
That should work just as well on WAMP as it does anywhere else.
I haven't configured an IIS server in ages... but it's probably just as easy as a nicely crafted "ini_set('include_path",'..') in your bootstrap script.
Once you've got Zend/lib in your include path, you can include (or autoload) Zend things as needed.
i used this tutorial when i started to work with zf:
http://www.ibm.com/developerworks/library/os-php-zend1/
It's from 2006 but you should get the clue.
Have fun!
Which unit testing framework do you use for Symfony?
Lime or PHPUnit? What are the pros and cons of using them?
In my opinion, here are a few things that come to my mind :
PHPUnit is more integrated with other tools, like, for instance,
Selenium (PHPUnit can use it to open true real browsers to test your site)
phpUnderControl for continuous-integration
PHPUnit works well with Xdebug, to generate code-coverage reports
PHPUnit is more widely used ; which probably means more support
But note I don't work with symfony, nor lime...
Still, I've never heards anyone speak about it, except for those working with symfony -- that not a good thing, for the day you'll have to work with another framework (yes, this happens ^^ )
One thing that's not in PHPUnit :
"false" browser (being able to do HTTP Requests to the application, without using Selenium to open a real browser)
But some frameworks (Zend Framework does, with it's Zend_Test component) integrate with PHPUnit (or use it), while allowing injection of data into the MVC and fetching of the response, without having to issue any HTTP Request.
I don't know if symfony allows that, but that's a nice thing with ZF/PHPUnit ^^
(Yes, not a symfony-specific answer ; but of the things I said must still be valid with that framework)
Lime is a much more simple testing framework, which can be a good or a bad thing depending on how you want to use it.
The symfony library itself uses its own testing framework, Lime, to test its code base. From the symfony book:
It is based on the Test::More Perl
library, and is TAP compliant, which
means that the result of tests is
displayed as specified in the Test
Anything Protocol, designed for better
readability of test output.
I cannot vouch for the statement that the lime framework is "more lightweight" than other PHP testing frameworks as the symfony docs claim, but I do really like that it's built right into your symfony project and works well with the symfony command line tools without any additional configuration. One thing that is especially cool is that the lime tests within symfony are set to run within your "test" environment which has it's own database, symfony cache (which gets cleared out during each test session), and environment variables. This comes in handy when you want to do functional testing (checking server response and your html output in your modules/actions, versus basic unit testing). I also like that lime is super easy to pick up and understand since it's so simple. You also have the ability to put your tests into YAML configuration file rather than write the tests by hand.
Pascal is entirely right that PHPUnit is much more widely used and you'd be able to use it in non-symfony projects. There is even a plugin for it, PHPUnit symfony plugin. My best advice would be to use lime if you just wanted to jump right into writing simple tests while you develop your symfony app. But, if you have the time and hope to use these testing skills outside of the symfony world, or bring in pre-existing PHPUnit tests into your symfony code, it'd be worth your time to check out the plugin and give it a spin.