Browse Source

Merge 1388ecd551 into da26affe26

pull/65/merge
op-simoneromeo 6 days ago
committed by GitHub
parent
commit
22016ff351
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
8 changed files with 1204 additions and 363 deletions
  1. +3
    -0
      README.md
  2. +38
    -2
      compass/bootstrap/app.php
  3. +1
    -2
      compass/composer.json
  4. +1125
    -331
      compass/composer.lock
  5. +10
    -12
      compass/phpunit.xml
  6. +14
    -8
      compass/tests/ExampleTest.php
  7. +8
    -8
      compass/tests/TestCase.php
  8. +5
    -0
      compass/tests/bootstrap.php

+ 3
- 0
README.md View File

@ -9,6 +9,9 @@ Compass is a GPS tracking server that stores data in [flat files](https://github
* PHP 5.5 or above * PHP 5.5 or above
* MySQL (for storing user accounts and lists of databases, not for storing the actual location data) * MySQL (for storing user accounts and lists of databases, not for storing the actual location data)
This branch has been verified for PHP 8 compatibility, including PHP 8.0 and
PHP 8.4.
### PHP extensions ### PHP extensions
You'll need to make sure the following PHP extensions are installed. Typically these are installed using the package manager of your operating system. You'll need to make sure the following PHP extensions are installed. Typically these are installed using the package manager of your operating system.

+ 38
- 2
compass/bootstrap/app.php View File

@ -1,8 +1,14 @@
<?php <?php
$legacyErrorReporting = E_ALL & ~E_DEPRECATED & ~E_USER_DEPRECATED;
error_reporting($legacyErrorReporting);
require_once __DIR__.'/../vendor/autoload.php'; require_once __DIR__.'/../vendor/autoload.php';
Dotenv::load(__DIR__.'/../');
if (file_exists(__DIR__.'/../.env')) {
Dotenv::load(__DIR__.'/../');
}
/* /*
|-------------------------------------------------------------------------- |--------------------------------------------------------------------------
@ -19,7 +25,37 @@ $app = new Laravel\Lumen\Application(
realpath(__DIR__.'/../') realpath(__DIR__.'/../')
); );
$app->withFacades();
error_reporting($legacyErrorReporting);
Illuminate\Support\Facades\Facade::setFacadeApplication($app);
// Lumen 5.1 aliases Event globally, which can collide with PHP's event extension.
foreach ([
'App' => Illuminate\Support\Facades\App::class,
'Auth' => Illuminate\Support\Facades\Auth::class,
'Bus' => Illuminate\Support\Facades\Bus::class,
'DB' => Illuminate\Support\Facades\DB::class,
'Cache' => Illuminate\Support\Facades\Cache::class,
'Cookie' => Illuminate\Support\Facades\Cookie::class,
'Crypt' => Illuminate\Support\Facades\Crypt::class,
'Hash' => Illuminate\Support\Facades\Hash::class,
'Log' => Illuminate\Support\Facades\Log::class,
'Mail' => Illuminate\Support\Facades\Mail::class,
'Queue' => Illuminate\Support\Facades\Queue::class,
'Request' => Illuminate\Support\Facades\Request::class,
'Schema' => Illuminate\Support\Facades\Schema::class,
'Session' => Illuminate\Support\Facades\Session::class,
'Storage' => Illuminate\Support\Facades\Storage::class,
'Validator' => Illuminate\Support\Facades\Validator::class,
] as $alias => $class) {
if (!class_exists($alias, false)) {
class_alias($class, $alias);
}
}
$aliasesRegistered = new ReflectionProperty(Laravel\Lumen\Application::class, 'aliasesRegistered');
$aliasesRegistered->setAccessible(true);
$aliasesRegistered->setValue(true);
// $app->withEloquent(); // $app->withEloquent();

+ 1
- 2
compass/composer.json View File

@ -17,8 +17,7 @@
"p3k/timezone": "^0.1.0" "p3k/timezone": "^0.1.0"
}, },
"require-dev": { "require-dev": {
"phpunit/phpunit": "~4.0",
"fzaninotto/faker": "~1.0"
"phpunit/phpunit": "^9.6"
}, },
"autoload": { "autoload": {
"psr-4": { "psr-4": {

+ 1125
- 331
compass/composer.lock
File diff suppressed because it is too large
View File


+ 10
- 12
compass/phpunit.xml View File

@ -1,26 +1,24 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<phpunit backupGlobals="false"
backupStaticAttributes="false"
bootstrap="bootstrap/app.php"
<phpunit bootstrap="tests/bootstrap.php"
colors="true" colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false" processIsolation="false"
stopOnFailure="false"
syntaxCheck="false">
stopOnFailure="false">
<testsuites> <testsuites>
<testsuite name="Application Test Suite"> <testsuite name="Application Test Suite">
<directory>./tests/</directory> <directory>./tests/</directory>
</testsuite> </testsuite>
</testsuites> </testsuites>
<filter>
<whitelist>
<coverage>
<include>
<directory suffix=".php">app/</directory> <directory suffix=".php">app/</directory>
</whitelist>
</filter>
</include>
</coverage>
<php> <php>
<env name="APP_ENV" value="testing"/> <env name="APP_ENV" value="testing"/>
<env name="APP_KEY" value="CompassPhp8LocalSmokeTestKey1234"/>
<env name="BASE_URL" value="http://localhost/"/>
<env name="ALLOW_NEW_USERS" value="false"/>
<env name="STORAGE_DIR" value="/tmp/compass-test-storage/"/>
<env name="CACHE_DRIVER" value="array"/> <env name="CACHE_DRIVER" value="array"/>
<env name="SESSION_DRIVER" value="array"/> <env name="SESSION_DRIVER" value="array"/>
<env name="QUEUE_DRIVER" value="sync"/> <env name="QUEUE_DRIVER" value="sync"/>

+ 14
- 8
compass/tests/ExampleTest.php View File

@ -2,14 +2,20 @@
class ExampleTest extends TestCase class ExampleTest extends TestCase
{ {
/**
* A basic test example.
*
* @return void
*/
public function testBasicExample()
public function testHomePageLoads()
{ {
$this->visit('/')
->see('Lumen.');
$response = $this->request('GET', '/');
$this->assertSame(200, $response->getStatusCode());
$this->assertStringContainsString('Compass', $response->getContent());
}
public function testApiInputRequiresToken()
{
$response = $this->request('GET', '/api/input');
$this->assertSame(200, $response->getStatusCode());
$this->assertSame('application/json', $response->headers->get('Content-Type'));
$this->assertSame(['error' => 'no token provided'], json_decode($response->getContent(), true));
} }
} }

+ 8
- 8
compass/tests/TestCase.php View File

@ -1,14 +1,14 @@
<?php <?php
class TestCase extends Laravel\Lumen\Testing\TestCase
use Illuminate\Http\Request;
use PHPUnit\Framework\TestCase as BaseTestCase;
abstract class TestCase extends BaseTestCase
{ {
/**
* Creates the application.
*
* @return \Laravel\Lumen\Application
*/
public function createApplication()
protected function request($method, $uri)
{ {
return require __DIR__.'/../bootstrap/app.php';
$app = require __DIR__.'/../bootstrap/app.php';
return $app->handle(Request::create($uri, $method));
} }
} }

+ 5
- 0
compass/tests/bootstrap.php View File

@ -0,0 +1,5 @@
<?php
error_reporting(E_ALL & ~E_DEPRECATED & ~E_USER_DEPRECATED);
require __DIR__.'/../vendor/autoload.php';

Loading…
Cancel
Save