0
votes

I am working on a ZF project wich use a postgre database, on my local server (ubuntu 10.04 LTS Lucid Lynx).
I'm trying to run a very simple test with phpunit:

    public function testIndexAction() {
        $this->dispatch('/');  
        $this->assertController('index');  
        $this->assertAction('index');  
        $this->assertModule('default');  
        $this->assertXpathContentContains('/html/body/div[1]/div[@id=\'content\']/p', 'Los puntos de mis amigos son mis amigos..');  
    }

but it fails on the first assertion with this message:

Failed asserting last controller used <"error"> was "index"
I found this question where the author had the same problem: he solved it by adding to his 2nd php.ini the php_pdo_pgsql.dll library. But he's on windows and using xampp.
Anyway I checked it: the /etc/php5/apache2/php.ini has those 3 lines:
extension=msql.so
extension=pgsql.so
extension=pdo_pgsql.so
and I added them in the other php.ini file I found: /etc/php5/cli/php.ini and now when I run the test it says:
PHP Warning:  PHP Startup: Unable to load dynamic library '/usr/lib/php5/20090626+lfs/msql.so' - /usr/lib/php5/20090626+lfs/msql.so: cannot open shared object file: No such file or directory in Unknown on line 0
PHP Warning:  PHP Startup: Unable to load dynamic library '/usr/lib/php5/20090626+lfs/pdo_pgsql.so' - /usr/lib/php5/20090626+lfs/pdo_pgsql.so: undefined symbol: php_pdo_register_driver in Unknown on line 0
PHP Warning:  Module 'pgsql' already loaded in Unknown on line 0
and now I''m really out of ideas...
Can anyone point me in the right direction?
thanx
1
it sounds to me that some error occurs and it dispatches to the error controller and not to the index controller. what code do you have in your index controller? - robertbasic
you're right robert: I was afk and then suddenly I thaught "f**k, I haven't checked if the error isn't in my code". It turned out that there was one column missing in one table of my test db. I added it and now it's fine. As I had spent the last few hours trying to get phpunit working I was still thinking about general configuration, not about my code. Sorry about this. What should I do now: Can i give you the right answer? should I answer myself? I feel like a total noob for asking this and don't check first :( ... - OSdave
David, can you make this error message "Failed asserting last controller used <"error"> was "index" become has more useful information about the error? Ex: In you case, the message should be "column blabla is not exists". - deerawan

1 Answers

0
votes

It turned out that there was one column missing in one table of my test db. I added it and now it's fine. As I had spent the last few hours trying to get phpunit working I was still thinking about general configuration, not about my code.