CodeIgniter Forums
How to use PHPUnit (CIUnit) with CodeIgniter 2.1.0 - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Libraries & Helpers (https://forum.codeigniter.com/forumdisplay.php?fid=22)
+--- Thread: How to use PHPUnit (CIUnit) with CodeIgniter 2.1.0 (/showthread.php?tid=48438)

Pages: 1 2 3


How to use PHPUnit (CIUnit) with CodeIgniter 2.1.0 - El Forum - 10-17-2012

[eluser]SPeed_FANat1c[/eluser]
Hello again,

I still have problems with running the first test Smile

Code:
Darius@Darius-PC /cygdrive/e/projektai/php projektai/htdocs/ci_unit/tests
$ phpunit models/PhoneCarrierModelTest.php
Could not open input file: /cygdrive/e/other/xampp/php/phpunit

why it cannot open the file, I don't get?

the same is when I don't specify the file

Code:
Darius@Darius-PC /cygdrive/e/projektai/php projektai/htdocs/ci_unit/tests
$ phpunit
Could not open input file: /cygdrive/e/other/xampp/php/phpunit



Oh, btw I tried it with windows native cmd and it did not throw this error, it told that cannot connect to database and so on, so I will fix the connection settings and will check.


How to use PHPUnit (CIUnit) with CodeIgniter 2.1.0 - El Forum - 10-20-2012

[eluser]SPeed_FANat1c[/eluser]
So I fixed the connection settings, but still getting error:

Code:
E:\projektai\php projektai\htdocs\ci_unit\tests>phpunit
PHPUnit 3.5.14 by Sebastian Bergmann.

....[CIUnit] PHP Error: Warning - include(E:\projektai\php projektai\htdocs\ci_u
nit\application\config\testing\database.php): failed to open stream: Permission
denied File Path: database/DB.php (line: 41)
[CIUnit] PHP Error: Warning - include(): Failed opening 'E:\projektai\php projek
tai\htdocs\ci_unit\application/config/testing/database.php' for inclusion (inclu
de_path='.;E:\\\\\\\\other\\\\\\\\xampp\\\\\\\\php\\\\\\\\PEAR\\\\\\\\pear;C:\\\\\\\\Users\\\\\\\\Darius\\\\\\\\Desktop\\\\\\\\siuksles\\\\\\\\pear;E:
\\\\\\\\other\\\\\\\\xampp\\\\\\\\php\\\\\\\\PEAR') File Path: database/DB.php (line: 41)
[CIUnit] Error: 500 Message: No database connection settings were found in the d
atabase config file.

Then I open the file

E:\projektai\php projektai\htdocs\ci_u
nit\application\config\testing\database.php

to see whats on 41 line, and I see empty file. But it takes 4 KB. So it should not be empty. What is wrong there?

Edit:
tired opening it with few other editrods, and when opening with notepad then it shows acces s denied message. So its somehow locked and phpunit also probably cannot open it or something like that. What is going on Smile


I also tried running cmd as administrator:
http://www.howtogeek.com/howto/windows-vista/run-a-command-as-administrator-from-the-windows-vista-run-box/

but still the same..


How to use PHPUnit (CIUnit) with CodeIgniter 2.1.0 - El Forum - 10-22-2012

[eluser]SPeed_FANat1c[/eluser]
I replaced the database.php in application/config/testing with the file application/config/database.php and it started working.

Code:
E:\projektai\php projektai\htdocs\ci_unit\tests>phpunit
PHPUnit 3.5.14 by Sebastian Bergmann.

........

Time: 3 seconds, Memory: 5.75Mb

←[30;42m←[2KOK (8 tests, 4 assertions)
←[0m←[2K
E:\projektai\php projektai\htdocs\ci_unit\tests>

So cool, I will be able now experiment with php unit. I hope I will not get those nonsenses anymore with this ciunit Smile


How to use PHPUnit (CIUnit) with CodeIgniter 2.1.0 - El Forum - 10-23-2012

[eluser]SPeed_FANat1c[/eluser]
Btw, I assume this

Code:
←[30;42m←[2K

had to mean color coding for command line. But I am not seeing colors. How to make that it would show colors instead of code on windows cmd?


How to use PHPUnit (CIUnit) with CodeIgniter 2.1.0 - El Forum - 10-27-2012

[eluser]SPeed_FANat1c[/eluser]
Accidentally found maybe an easier way to install PHP unit - its Composer.

http://net.tutsplus.com/tutorials/php/test-driven-development-in-php-first-steps/

Composer is "Dependency Manager for PHP". I did not tried it but watched video, maybe someone will have less headache when installing PEAR Smile


How to use PHPUnit (CIUnit) with CodeIgniter 2.1.0 - El Forum - 03-11-2013

[eluser]Unknown[/eluser]
[quote author="Kenji @ CodeIgniter Users Group in Japan" date="1331259973"]The way to truncate the tables in CIUnit is not good.
Any contributions is welcome. :-)
[/quote]
Is there way to have "Unit tests do not connect to the database" instead mock out the database layer entirely
with CIUnit?.