Welcome Guest, Not a member yet? Register   Sign In
How to use PHPUnit (CIUnit) with CodeIgniter 2.1.0
#21

[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.
#22

[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-v...a-run-box/

but still the same..
#23

[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
#24

[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?
#25

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

http://net.tutsplus.com/tutorials/php/te...rst-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
#26

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





Theme © iAndrew 2016 - Forum software by © MyBB