Skip to content
This repository has been archived by the owner on Nov 24, 2021. It is now read-only.

Added Travis CI #315

Open
wants to merge 30 commits into
base: master
Choose a base branch
from
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
53 changes: 33 additions & 20 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,31 +1,44 @@
---
dist: trusty
sudo: false
language: php
addons:
chrome: stable
cache:
directories:
- $HOME/.composer/cache/files

services:
- mysql
before_script:
- '! find . -type f -name "*.php" -exec php -d error_reporting=32767 -l {} \; 2>&1 >&- | grep "^"'
- php -S 0.0.0.0:8000
- google-chrome-stable --headless --disable-gpu --remote-debugging-port=9222 http://localhost:8000s &
- mysql -e 'CREATE DATABASE 2moons;'

env:
global:
- TEST_BASE_URI=http://localhost:8888
- DB_HOST=localhost
- DB_USER=travis
- DB_PASSWORD=""
- DB_NAME=2moons
- ADMIN_NAME=admin
- ADMIN_PASSWORD=admin
- [email protected]

php:
- '7.0'

matrix:
fast_finish: true

install:
- mysql -e 'CREATE DATABASE IF NOT EXISTS 2moons;' -uroot
- composer install
env:
- DB_HOST: localhost
- DB_USER: travis
- DB_PASSWORD:
- DB_NAME: 2moons
- ADMIN_NAME: admin
- ADMIN_PASSWORD: admin
- ADMIN_MAIL: [email protected]

cache:
directories:
- $HOME/.composer/cache/files
before_script:
- phpenv config-rm xdebug.ini
- '! find . ! -path "./includes/libs/*" ! -path "./vendor/*" -type f -name "*.php" -exec php -d error_reporting=32767 -l {} \; 2>&1 >&- | grep "^"'
# Start a web server on port 8888, run in the background; wait for
# initialization.
- nohup php -d variables_order=EGPCS -S localhost:8888 > /dev/null 2>&1 &

script:
- 'vendor/bin/phpunit'
# - phpdbg -qrr phpunit

script: '! find . -type f -name "*.php" -exec php -d error_reporting=32767 -l {} \; 2>&1 >&- | grep "^"'
notifications:
email: false
5 changes: 4 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,8 @@
],
"minimum-stability": "stable",
"require": {},
"require-dev": {}
"require-dev": {
"guzzlehttp/guzzle": "~6",
"phpunit/phpunit": "~6"
}
}
5 changes: 5 additions & 0 deletions phpunit.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<phpunit colors="true" verbose="true" strict="true" bootstrap="vendor/autoload.php">
<testsuite name="installation">
<directory>./tests/Install/</directory>
</testsuite>
</phpunit>
66 changes: 66 additions & 0 deletions tests/Install/InstallTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
<?php

use PHPUnit\Framework\TestCase;

class InstallTest extends TestCase
{
private $http;

protected function setUp()
{
$this->http = new GuzzleHttp\Client(['base_uri' => $_SERVER['TEST_BASE_URI']]);
}

public function tearDown() {
$this->http = null;
}

public function testInstallRedirect()
{
$response = $this->http->request('GET', '/', ['allow_redirects' => false]);

$this->assertEquals(302, $response->getStatusCode());

$location = $response->getHeaders()["Location"][0];
$this->assertRegexp('/install\/index.php/', $location);
}

public function testInstallHome()
{
$response = $this->http->request('GET', '/install/index.php');

$this->assertEquals(200, $response->getStatusCode());
}

public function testInstallStep2()
{
$response = $this->http->request('GET', '/index.php?mode=install&step=2');

$this->assertEquals(200, $response->getStatusCode());

$this->assertRegexp('/<span class="yes">/', $response->getBody());
$this->assertRegexp('/<a href="index.php?mode=install&step=3">/', $response->getBody());
}

public function testInstallStep3()
{
$response = $this->http->request('GET', 'index.php?mode=install&step=3');

$this->assertEquals(200, $response->getStatusCode());
}

public function testInstallSql()
{
$response = $this->http->request('POST', 'index.php?mode=install&step=3', [
'form_params' => [
'host' => $_SERVER['DB_HOST'],
'user' => $_SERVER['DB_USER'],
'passwort' => $_SERVER['DB_PASSWORD'],
'dbname' => $_SERVER['DB_NAME'],
'prefix' => '2moons_',
]
]);

$this->assertEquals(200, $response->getStatusCode());
}
}
9 changes: 0 additions & 9 deletions tests/run.js

This file was deleted.