0

I'm trying to build a CodeCeption acceptance test environment for Joomla. To make it easier to reproduce the tests on any developer's machine, I want to provide a Docker based environment.

I'm creating the environment using docker-compose:

web:
  image: php:5-apache
  volumes:
    - ../..:/var/www/html
  ports:
    - 8080:80
  links:
    - db:db

db:
  image: mysql
  volumes:
    - ../../tests/_envs/sql:/var/lib/mysql
  ports:
    - 3306:3306

hub:
  image: selenium/hub
  ports:
    - 4444:4444

firefox:
  image: selenium/node-firefox-debug
  ports:
    - 5900
  links:
    - hub:hub

The CodeCeption setup looks like this (JoomlaBrowser is just extending WebDriver, adding Joomla specific functionality):

class_name: AcceptanceTester
modules:
    enabled:
        - JoomlaBrowser:
            url: 'http://localhost:8080/'     # the url that points to the joomla installation at /tests/system/joomla-cms
            browser: 'firefox'
            window_size: 1024x768
            capabilities:
              unexpectedAlertBehaviour: 'accept'
            username: 'admin'
            password: 'admin'
            database host: 'localhost'             # place where the Application is Hosted #server Address
            database user: 'root'                  # MySQL Server user ID, usually root
            database password: '1234'                  # MySQL Server password, usually empty or root
            database name: 'dbname'            # DB Name, at the Server
            database type: 'mysqli'                # type in lowercase one of the options: MySQL\MySQLi\PDO
            database prefix: 'jos_'                # DB Prefix for tables
            install sample data: 'Yes'              # Do you want to Download the Sample Data Along with Joomla Installation, then keep it Yes
            sample data: 'Default English (GB) Sample Data'    # Default Sample Data
            admin email: '[email protected]'      # email Id of the Admin
            language: 'English (United Kingdom)'   # Language in which you want the Application to be Installed
            joomla folder: '/home/.../path to Joomla Folder' # Path to Joomla installation where we execute the tests
        - \Helper\Acceptance
error_reporting: E_ALL

Once started, the web environment is accessible through http://localhost:8080 (redirecting to installation/index.php on a fresh copy of Joomla as expected) manually. So is the Selenium grid at http://localhost:4444/grid/console. Nevertheless, when running a CodeCeption acceptance test, the test only sees the 'Problem loading page' browser message.

What did I miss?

1 Answer 1

0

Finally solved it myself.

The problem is, that the firefox container should not access localhost, but the web container. Thus, a link to that container is needed. The fixed docker-compose.yml file now looks like

web:
  image: php:5-apache
  volumes:
    - .:/var/www/html
  ports:
    - "8080:80"
  links:
    - db:db

db:
  image: mysql
  volumes:
    - tests/_envs/sql:/var/lib/mysql
  environment:
    - MYSQL_ROOT_PASSWORD=root
  ports:
    - "3306:3306"

hub:
  image: selenium/hub
  ports:
    - "4444:4444"

firefox:
  image: selenium/node-firefox-debug
  links:
    - hub:hub
    - web:web
  ports:
    - "5900:5900"
  expose:
    - "5555"

The main difference is the link to web.

The acceptance test setup has to be changed accordingly:

class_name: AcceptanceTester
modules:
    enabled:
        - JoomlaBrowser:
            url: 'http://web/'     # the url that points to the joomla installation at /tests/system/joomla-cms
            browser: 'firefox'
            window_size: 1024x768
            capabilities:
              unexpectedAlertBehaviour: 'accept'
            username: 'admin'
            password: 'admin'
            database host: 'localhost'             # place where the Application is Hosted #server Address
            database user: 'root'                  # MySQL Server user ID, usually root
            database password: '1234'                  # MySQL Server password, usually empty or root
            database name: 'dbname'            # DB Name, at the Server
            database type: 'mysqli'                # type in lowercase one of the options: MySQL\MySQLi\PDO
            database prefix: 'jos_'                # DB Prefix for tables
            install sample data: 'Yes'              # Do you want to Download the Sample Data Along with Joomla Installation, then keep it Yes
            sample data: 'Default English (GB) Sample Data'    # Default Sample Data
            admin email: '[email protected]'      # email Id of the Admin
            language: 'English (United Kingdom)'   # Language in which you want the Application to be Installed
            joomla folder: '/home/.../path to Joomla Folder' # Path to Joomla installation where we execute the tests
        - \Helper\Acceptance
error_reporting: E_ALL

The main change here is to point the URL to http:/web/ instead of localhost.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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