I'd really like to get PHPUnit working with CI |
[eluser]vendiddy[/eluser]
I am also interested in using PHPUnit in my project.
[eluser]kenjis[/eluser]
Hi guys, CIUnit worked and passed all sample tests within with CodeIgniter 2.0. https://bitbucket.org/kenjis/my-ciunit
[eluser]P.T.[/eluser]
Seems like it can't handle CSRF protection. He can't find the function csrf_verify(). And I am getting errors on my autoloaded models: Quote:[CIUnit] PHP Error: Notice - Undefined property: Welcome::$config_model File Path: core/MY_Controller.php (line: 40)
[eluser]Unknown[/eluser]
[quote author="CarloGl" date="1304476108"]Hi Zair, I'm not using FooStack. I plug in PHPUnit directly. The way I go about this is by providing an alternative entry point that uses the same bootstrapping sequence provided by core/CodeIgniter.php, but stops before routing kicks in. This requires: - extracting the variable definitions in the index page into a config/settings.php file - providing a bootstrap.php file included in test classes I also use a sub class of PHPUnit_Framework_TestCase ( CITestCaseExtension ) to provide some basic common functionality to the test classes, including some rudimentary functions to set up fixtures. The test classes are organized in an application/tests directory that mirrors the controllers' so that by pointing the phpunit script to that directory all the tests wherein are run together. [/quote] I was able to use PHPUnit with CI 2.0 using something like that. I don't use fixtures but mocks. It works as I want. Uncompress the attached files in the application directory and should work (code is quite dirty, I finished it today :-P )
[eluser]kenjis[/eluser]
[quote author="P.T." date="1311085509"] And I am getting errors on my autoloaded models: Quote:[CIUnit] PHP Error: Notice - Undefined property: Welcome::$config_model File Path: core/MY_Controller.php (line: 40)[/quote] I commited the fix. https://bitbucket.org/kenjis/my-ciunit/c...8c637ad9b9
[eluser]Unknown[/eluser]
Had to register just to say thanks for this Kenji So far so good on some minimal tests
[eluser]P.T.[/eluser]
MY_Controller is giving me a headache. It seems that the autoloaded classes are not available in MY_Controller. Even when I a this-load->model() just before i use the model, the model seems to be null. So I am unable to test my controllers
[eluser]kenjis[/eluser]
[quote author="P.T." date="1311277232"]MY_Controller is giving me a headache. It seems that the autoloaded classes are not available in MY_Controller. Even when I a this-load->model() just before i use the model, the model seems to be null. So I am unable to test my controllers [/quote] I can't reproduce the error. Autoloading model in MY_Controller works fine.
[eluser]belial.seed[/eluser]
Hi i´m new to TDD, can you point me towards some information on how to use CIUnit, thanks in advance. |
Welcome Guest, Not a member yet? Register Sign In |