EllisLab text mark
Advanced Search
2 of 2
2
   
How to use PHPUnit (CIUnit) with CodeIgniter 2.1.0
Posted: 17 October 2012 12:07 PM   [ Ignore ]   [ # 21 ]   [ Rating: 0 ]
Joined: 2010-03-19
329 posts

Hello again,

I still have problems with running the first test smile

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

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.

 
Posted: 20 October 2012 03:37 AM   [ Ignore ]   [ # 22 ]   [ Rating: 0 ]
Joined: 2010-03-19
329 posts

So I fixed the connection settings, but still getting error:

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

....
[CIUnit] PHP ErrorWarning - include(E:\projektai\php projektai\htdocs\ci_u
nit\application\config\testing\database
.php): failed to open streamPermission
denied File Path
database/DB.php (line41)
[CIUnit] PHP ErrorWarning - 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 Pathdatabase/DB.php (line41)
[CIUnit] Error500 MessageNo 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..

 
Posted: 22 October 2012 12:56 PM   [ Ignore ]   [ # 23 ]   [ Rating: 0 ]
Joined: 2010-03-19
329 posts

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

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

........

Time3 secondsMemory5.75Mb

←[30
;42m←[2KOK (8 tests4 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

 
Posted: 23 October 2012 01:27 PM   [ Ignore ]   [ # 24 ]   [ Rating: 0 ]
Joined: 2010-03-19
329 posts

Btw, I assume this

←[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?

 
Posted: 27 October 2012 03:56 AM   [ Ignore ]   [ # 25 ]   [ Rating: 0 ]
Joined: 2010-03-19
329 posts

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

 
Posted: 11 March 2013 02:10 PM   [ Ignore ]   [ # 26 ]   [ Rating: 0 ]
Joined: 2013-03-11
1 posts
Kenji @ CodeIgniter Users Group in Japan - 08 March 2012 10:26 PM

The way to truncate the tables in CIUnit is not good.
Any contributions is welcome. grin

Is there way to have “Unit tests do not connect to the database” instead mock out the database layer entirely
with CIUnit?.

 
2 of 2
2