4

I am trying to install ecomdevs' unit testing with my copy of magento. I have added the folders manually to the relevant directories and added the below in app/etc/local.xml.phpunit

<default>
    <web>
        ...
        <secure>
            <base_url>http://siteName.local</base_url><!--also tried localhost and siteName.local-->
        <secure>
        <unsecure>
            <base_url>http://siteName.local</base_url><!--also tried localhost and siteName.local-->
        <unsecure>
        ...
    </web>
</default>

When I go to the command line in the root folder of my site and enter phpunit I get a fatal error returned

Uncaught exception 'RuntimeException' with message 'Cannot run controller test, because the host is not set for base url

I know I'm missing something obvious but ive been looking at this problem for far to long, why am I getting this error? (I'm following this guide)

  • Your base urls are missing the trailing slash. Maybe that's the problem, I could always use .local domains without trouble. – Fabian Schmengler Nov 11 '14 at 15:08
  • I'd add that it's probably better to use somesite.local given cookie handling issues that may affect all versions of magento per @alan-kent : magento.stackexchange.com/questions/64619/… At least, you can expect more consistent behavior when you modify your local hosts file to use local domains that have three-part names based on the results of those tests. – Bryan 'BJ' Hoffpauir Jr. Apr 27 '15 at 16:18
1

I'll post my comment as an answer too: Your base urls are missing the trailing slash. Maybe that's the problem, I could always use .local domains without trouble.

Also, EcomDev_PhpUnit comes with a setup shell script that you can use to set the base URL and other things (but the magento-config action basically writes to local.xml.phpunit):

cd shell
php -f ecomdev-phpunit.php -- -a magento-config --base-url http://sitename.local/
0

I had the same issue a while ago and I think inserting a record into core_config_data table in tests database helped. Something like:

INSERT INTO core_config_data SET path = 'web/unsecure/base_url', value='http://localhost/magento/';

-3

Shouldn't you put those changes in app/etc/local.xml so they get read into Magento directly? The .phpunit file is not a file that affects Magento unless you've customized the code.

  • It is the file that is used by EcomDev_PHPUnit for running tests. – Fabian Schmengler Nov 11 '14 at 15:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.