Commit 5a876398 authored by Jens Segers's avatar Jens Segers

Make testing easier with docker

parent 321885c9
......@@ -103,6 +103,15 @@ Embedded relations now return an `Illuminate\Database\Eloquent\Collection` rathe
$books = $user->books()->sortBy('title');
```
Testing
-------
To run the test for this package, run:
```
docker-compose up
```
Configuration
-------------
......
version: '3'
services:
php:
build:
context: .
dockerfile: docker/Dockerfile
volumes:
- .:/code
working_dir: /code
command: php ./vendor/bin/phpunit
depends_on:
- mysql
- mongodb
mysql:
image: mysql
environment:
MYSQL_ROOT_PASSWORD:
MYSQL_DATABASE: unittest
MYSQL_ALLOW_EMPTY_PASSWORD: 'yes'
logging:
driver: none
mongodb:
image: mongo
logging:
driver: none
FROM php:7.1-cli
RUN apt-get update && \
apt-get install -y autoconf pkg-config libssl-dev && \
pecl install mongodb && docker-php-ext-enable mongodb && \
docker-php-ext-install -j$(nproc) pdo pdo_mysql
......@@ -98,12 +98,13 @@ class ConnectionTest extends TestCase
public function testAuth()
{
$host = Config::get('database.connections.mongodb.host');
Config::set('database.connections.mongodb.username', 'foo');
Config::set('database.connections.mongodb.password', 'bar');
Config::set('database.connections.mongodb.options.database', 'custom');
$connection = DB::connection('mongodb');
$this->assertEquals('mongodb://127.0.0.1/custom', (string) $connection->getMongoClient());
$this->assertEquals('mongodb://' . $host . '/custom', (string) $connection->getMongoClient());
}
public function testCustomHostAndPort()
......
......@@ -7,15 +7,15 @@ return [
'mongodb' => [
'name' => 'mongodb',
'driver' => 'mongodb',
'host' => '127.0.0.1',
'host' => 'mongodb',
'database' => 'unittest',
],
'mysql' => [
'driver' => 'mysql',
'host' => '127.0.0.1',
'host' => 'mysql',
'database' => 'unittest',
'username' => 'travis',
'username' => 'root',
'password' => '',
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment