jhartlep (3) [Avatar] Offline
#1
Hi,
I have a problem using phpunit on Chapter 3.
Instead of MySQL, I'm using SQLite on my local machine.

Using this code:
$db = sqlite_open('../db/places_test.db');
$res = sqlite_query($db,'select * from places');
var_dump(sqlite_fetch_all($res));

gives me the three places from my db.
But using "phpunit models_PlaceTest" I get this error:

There was 1 error:

1) models_PlacesTest::testFetchAll
Zend_Db_Adapter_Exception: SQLSTATE[HY000] [14] unable to open database file

/home/workspace/zfia/library/Zend/Db/Adapter/Pdo/Abstract.php:144
/home/workspace/zfia/library/Zend/Db/Adapter/Pdo/Sqlite.php:137
/home/workspace/zfia/library/Zend/Db/Adapter/Abstract.php:448
/home/workspace/zfia/library/Zend/Db/Adapter/Pdo/Abstract.php:238
/home/workspace/zfia/tests/TestConfiguration.php:21
/home/workspace/zfia/tests/models/PlacesTest.php:8

FAILURES!
Tests: 1, Assertions: 0, Errors: 1.

Here is my config.ini:
[general]
db.adapter = PDO_SQLITE
db.params.dbname = APPLICATION_PATH "/../db/places.db"
date_default_timezone = "Europe/Berlin"

[live : general]

[dev : general]

[test : general]
db.params.dbname = APPLICATION_PATH "/../db/places_test.db"

I hope you can help me with this... - without changing to mysql...
akrabat (479) [Avatar] Offline
#2
Re: ZFiA - Chapter3 - SQLite
I would check that the path is correct.

What path do you get when you dump out realpath(APPLICATION_PATH . "/../db/places_test.db") and does a file exist there?

Regards,

Rob..
jhartlep (3) [Avatar] Offline
#3
Re: ZFiA - Chapter3 - SQLite
Got it. Thanks for the hint...
I forgot to define APPLICATION_PATH... :S ...