Skip to content
This repository was archived by the owner on May 1, 2019. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ matrix:
- php: 7.0
fast_finish: true
sudo: false
services:
- docker
cache:
directories:
- $HOME/.composer/cache
Expand Down
2 changes: 1 addition & 1 deletion resources/conf/mysql.cnf
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ socket = /var/run/mysqld/mysqld.sock
nice = 0

[mysqld]
user = root
user = mysql
pid-file = /var/run/mysqld/mysqld.pid
socket = /var/run/mysqld/mysqld.sock
port = 3306
Expand Down
2 changes: 1 addition & 1 deletion src/Docker/ComposeContainers.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public function addDatabase()
{
$this->config['mariadb'] = [
// @todo if comman run with verbose, tag verbose.
'command' => 'mysqld --user=root --verbose',
'command' => 'mysqld --verbose',
'image' => 'mariadb',
'ports' => [
'3306',
Expand Down
17 changes: 9 additions & 8 deletions tests/Utils/BaseUtilsTest.php → tests/BaseTest.php
Original file line number Diff line number Diff line change
@@ -1,18 +1,13 @@
<?php
/**
* Created by PhpStorm.
* User: mglaman
* Date: 8/30/15
* Time: 5:39 AM
*/

namespace mglaman\PlatformDocker\Tests\Utils;
namespace mglaman\PlatformDocker\Tests;

use mglaman\PlatformDocker\Config;

abstract class BaseUtilsTest extends \PHPUnit_Framework_TestCase
abstract class BaseTest extends \PHPUnit_Framework_TestCase
{
protected static $tmpName;
protected static $dockerCleanup = FALSE;

/**
* Sets up the fixture, for example, open a network connection.
Expand All @@ -30,6 +25,12 @@ protected function setUp()
*/
public static function tearDownAfterClass()
{
if (self::$dockerCleanup) {
$dir_path = explode(DIRECTORY_SEPARATOR, self::$tmpName);
$project_prefix = strtolower(end($dir_path));
exec('docker stop $(docker ps -q -f name=' . $project_prefix . ')');
exec('docker rm $(docker ps -q -f name=' . $project_prefix . ')');
}
exec('rm -Rf ' . escapeshellarg(self::$tmpName));
}

Expand Down
31 changes: 31 additions & 0 deletions tests/Commands/RebuildCommandTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?php

namespace mglaman\PlatformDocker\Tests\Commands;

use mglaman\Docker\Docker;
use mglaman\PlatformDocker\Command\Docker\RebuildCommand;
use mglaman\PlatformDocker\Tests\BaseTest;
use Symfony\Component\Console\Tester\CommandTester;

class RebuildCommandTest extends BaseTest
{
protected static $dockerCleanup = TRUE;

public function testRunCommand()
{
$tester = new CommandTester(new RebuildCommand());
$tester->execute([], ['interactive' => true]);
// Let all containers boot
sleep(20);

$dir_path = explode(DIRECTORY_SEPARATOR, self::$tmpName);
$project_prefix = strtolower(end($dir_path));
$process = Docker::inspect(['--format="{{ .State.Running }}"', $project_prefix . '_nginx_1'], true);
$this->assertTrue(trim($process->getOutput()) == '"true"', $project_prefix . '_nginx_1 as not running');
$process = Docker::inspect(['--format="{{ .State.Running }}"', $project_prefix . '_phpfpm_1'], true);
$this->assertTrue(trim($process->getOutput()) == '"true"', $project_prefix . '_phpfpm_1 as not running');
// MariaDB takes a little.
$process = Docker::inspect(['--format="{{ .State.Running }}"', $project_prefix . '_mariadb_1'], true);
$this->assertTrue(trim($process->getOutput()) == '"true"', $project_prefix . '_mariadb_1 as not running');
}
}
9 changes: 2 additions & 7 deletions tests/Utils/ComposeContainersTest.php
Original file line number Diff line number Diff line change
@@ -1,19 +1,14 @@
<?php
/**
* Created by PhpStorm.
* User: mglaman
* Date: 8/30/15
* Time: 7:31 AM
*/

namespace mglaman\PlatformDocker\Tests\Utils;


use mglaman\PlatformDocker\Docker\ComposeContainers;
use mglaman\PlatformDocker\Platform;
use mglaman\PlatformDocker\Tests\BaseTest;
use Symfony\Component\Yaml\Yaml;

class ComposeContainersTest extends BaseUtilsTest
class ComposeContainersTest extends BaseTest
{
public function testDefaultConfig()
{
Expand Down
3 changes: 2 additions & 1 deletion tests/Utils/ConfigTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@


use mglaman\PlatformDocker\Config;
use mglaman\PlatformDocker\Tests\BaseTest;

class ConfigTest extends BaseUtilsTest
class ConfigTest extends BaseTest
{

public function testGet()
Expand Down
3 changes: 2 additions & 1 deletion tests/Utils/PlatformTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@

use mglaman\PlatformDocker\Config;
use mglaman\PlatformDocker\Platform;
use mglaman\PlatformDocker\Tests\BaseTest;

class PlatformTest extends BaseUtilsTest
class PlatformTest extends BaseTest
{
public function testProjectName()
{
Expand Down
2 changes: 2 additions & 0 deletions tests/bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,5 @@
* A script containing any set-up steps required for PHPUnit testing.
*/
require __DIR__ . '/../vendor/autoload.php';

define('CLI_ROOT', dirname(__DIR__));