Skip to content

Commit 2e27cde

Browse files
committed
Merge branch 'master' of https://github.com/izniburak/php-router
2 parents e36195f + 9664bb3 commit 2e27cde

File tree

7 files changed

+430
-10
lines changed

7 files changed

+430
-10
lines changed

.travis.yml

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,36 @@
11
language: php
22

3-
dist: trusty
4-
53
matrix:
64
include:
75
- php: 5.5
6+
dist: trusty
87
- php: 5.6
98
- php: 7.0
109
- php: 7.1
1110
- php: 7.2
1211
- php: 7.3
1312
- php: 7.4
1413

15-
sudo: false
14+
sudo: required
1615

1716
install:
1817
- composer install
1918

2019
before_script:
21-
- php -S localhost:5000 tests/fixtures/server.php &
20+
- sudo apt-get update
21+
- sudo apt-get install -y apache2 libapache2-mod-fastcgi
22+
# enable php-fpm
23+
- 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
24+
- 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
25+
- sudo a2enmod rewrite actions fastcgi alias
26+
- echo "cgi.fix_pathinfo = 1" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini
27+
- sudo sed -i -e "s,www-data,travis,g" /etc/apache2/envvars
28+
- sudo chown -R travis:travis /var/lib/apache2/fastcgi
29+
- ~/.phpenv/versions/$(phpenv version-name)/sbin/php-fpm
30+
# configure apache virtual hosts
31+
- sudo cp -f tests/fixtures/travis-ci-apache /etc/apache2/sites-available/000-default.conf
32+
- sudo sed -e "s?%TRAVIS_BUILD_DIR%?$(pwd)?g" --in-place /etc/apache2/sites-available/000-default.conf
33+
- sudo service apache2 restart
2234

2335
script:
2436
- vendor/bin/phpunit

tests/RouterTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ protected function tearDown()
3535

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

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

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

5858
$this->assertSame('controller route', (string) $response->getBody());

tests/bootstrap.php

Lines changed: 0 additions & 2 deletions
This file was deleted.

tests/fixtures/.htaccess

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
RewriteEngine On
2+
RewriteBase /tests/fixtures
3+
RewriteCond %{REQUEST_FILENAME} !-f
4+
RewriteCond %{REQUEST_FILENAME} !-d
5+
RewriteRule ^ index.php [QSA,L]

tests/fixtures/server.php renamed to tests/fixtures/index.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,6 @@
2121
return 'Hello World!';
2222
});
2323

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

2626
$router->run();

tests/fixtures/travis-ci-apache

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<VirtualHost *:80>
2+
DocumentRoot %TRAVIS_BUILD_DIR%
3+
4+
<Directory "%TRAVIS_BUILD_DIR%">
5+
Options FollowSymLinks MultiViews ExecCGI
6+
AllowOverride All
7+
Require all granted
8+
</Directory>
9+
10+
# Wire up Apache to use Travis CI's php-fpm.
11+
<IfModule mod_fastcgi.c>
12+
AddHandler php-fcgi .php
13+
Action php-fcgi /php-fcgi
14+
Alias /php-fcgi /usr/lib/cgi-bin/php-fcgi
15+
FastCgiExternalServer /usr/lib/cgi-bin/php-fcgi -host 127.0.0.1:9000 -pass-header Authorization
16+
17+
<Directory /usr/lib/cgi-bin>
18+
Require all granted
19+
</Directory>
20+
</IfModule>
21+
</VirtualHost>

0 commit comments

Comments
 (0)