Skip to content

Resolves issue #20 #21

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 31, 2020
Merged
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
20 changes: 16 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,24 +1,36 @@
language: php

dist: trusty

matrix:
include:
- php: 5.5
dist: trusty
- php: 5.6
- php: 7.0
- php: 7.1
- php: 7.2
- php: 7.3
- php: 7.4

sudo: false
sudo: required

install:
- composer install

before_script:
- php -S localhost:5000 tests/fixtures/server.php &
- sudo apt-get update
- sudo apt-get install -y apache2 libapache2-mod-fastcgi
# enable php-fpm
- if [[ ${TRAVIS_PHP_VERSION:0:1} == "7" ]]; then sudo cp tests/fixtures/www.conf.default ~/.phpenv/versions/$(phpenv version-name)/etc/php-fpm.conf; fi
- if [[ ${TRAVIS_PHP_VERSION:0:1} == "5" ]]; then sudo cp ~/.phpenv/versions/$(phpenv version-name)/etc/php-fpm.conf.default ~/.phpenv/versions/$(phpenv version-name)/etc/php-fpm.conf; fi
- sudo a2enmod rewrite actions fastcgi alias
- echo "cgi.fix_pathinfo = 1" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini
- sudo sed -i -e "s,www-data,travis,g" /etc/apache2/envvars
- sudo chown -R travis:travis /var/lib/apache2/fastcgi
- ~/.phpenv/versions/$(phpenv version-name)/sbin/php-fpm
# configure apache virtual hosts
- sudo cp -f tests/fixtures/travis-ci-apache /etc/apache2/sites-available/000-default.conf
- sudo sed -e "s?%TRAVIS_BUILD_DIR%?$(pwd)?g" --in-place /etc/apache2/sites-available/000-default.conf
- sudo service apache2 restart
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just notice that I refer this reference to accomplish this Apache + PHP on Travis CI build :).


script:
- vendor/bin/phpunit
6 changes: 3 additions & 3 deletions tests/RouterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ protected function tearDown()

public function testGetIndexRoute()
{
$request = $this->client->createRequest('GET', 'http://localhost:5000/');
$request = $this->client->createRequest('GET', 'http://localhost/tests/fixtures/');
$response = $this->client->send($request);

$this->assertSame('Hello World!', (string) $response->getBody());
Expand All @@ -46,13 +46,13 @@ public function testGetIndexRoute()
*/
public function testGetNotFoundRoute()
{
$request = $this->client->createRequest('GET', 'http://localhost:5000/not/found');
$request = $this->client->createRequest('GET', 'http://localhost/tests/fixtures/not/found');
$response = $this->client->send($request);
}

public function testGetControllerRoute()
{
$request = $this->client->createRequest('GET', 'http://localhost:5000/controllers');
$request = $this->client->createRequest('GET', 'http://localhost/tests/fixtures/controller');
$response = $this->client->send($request);

$this->assertSame('controller route', (string) $response->getBody());
Expand Down
2 changes: 0 additions & 2 deletions tests/bootstrap.php

This file was deleted.

5 changes: 5 additions & 0 deletions tests/fixtures/.htaccess
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
RewriteEngine On
RewriteBase /tests/fixtures
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^ index.php [QSA,L]
2 changes: 1 addition & 1 deletion tests/fixtures/server.php → tests/fixtures/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@
return 'Hello World!';
});

$router->get('/controllers', 'TestController@main');
$router->get('/controller', 'TestController@main');

$router->run();
21 changes: 21 additions & 0 deletions tests/fixtures/travis-ci-apache
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<VirtualHost *:80>
DocumentRoot %TRAVIS_BUILD_DIR%

<Directory "%TRAVIS_BUILD_DIR%">
Options FollowSymLinks MultiViews ExecCGI
AllowOverride All
Require all granted
</Directory>

# Wire up Apache to use Travis CI's php-fpm.
<IfModule mod_fastcgi.c>
AddHandler php-fcgi .php
Action php-fcgi /php-fcgi
Alias /php-fcgi /usr/lib/cgi-bin/php-fcgi
FastCgiExternalServer /usr/lib/cgi-bin/php-fcgi -host 127.0.0.1:9000 -pass-header Authorization

<Directory /usr/lib/cgi-bin>
Require all granted
</Directory>
</IfModule>
</VirtualHost>
Loading