Skip to content

Commit

Permalink
Fix server travis
Browse files Browse the repository at this point in the history
  • Loading branch information
stelin committed May 19, 2019
1 parent 30bab1f commit 0986ca9
Show file tree
Hide file tree
Showing 4 changed files with 71 additions and 4 deletions.
22 changes: 22 additions & 0 deletions phpunit.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit
bootstrap="test/bootstrap.php"
backupGlobals="false"
backupStaticAttributes="false"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false">
<testsuites>
<testsuite name="test">
<directory suffix="Test.php">./test/unit</directory>
</testsuite>
</testsuites>
<filter>
<whitelist processUncoveredFilesFromWhitelist="true">
<directory suffix=".php">./src/*</directory>
</whitelist>
</filter>
</phpunit>
33 changes: 29 additions & 4 deletions test/bootstrap.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,31 @@
<?php
// Composer autoload
$autoloadFile = dirname(__DIR__) . '/vendor/autoload.php';
if (file_exists($autoloadFile)) {
require_once $autoloadFile;
// vendor at component dir
if (file_exists(dirname(__DIR__) . '/vendor/autoload.php')) {
require dirname(__DIR__) . '/vendor/autoload.php';
// application's vendor
} elseif (file_exists(dirname(__DIR__, 3) . '/vendor/autoload.php')) {
/** @var \Composer\Autoload\ClassLoader $loader */
$loader = require dirname(__DIR__, 3) . '/vendor/autoload.php';

// need load testing psr4 config map
$componentDir = dirname(__DIR__, 3);
$componentJson = $componentDir . '/composer.json';
$composerData = json_decode(file_get_contents($componentJson), true);
foreach ($composerData['autoload-dev']['psr-4'] as $prefix => $dir) {
$loader->addPsr4($prefix, $componentDir . '/' . $dir);
}
} elseif (file_exists(dirname(__DIR__, 5) . '/autoload.php')) {
/** @var \Composer\Autoload\ClassLoader $loader */
$loader = require dirname(__DIR__, 5) . '/autoload.php';

// need load testing psr4 config map
$componentDir = dirname(__DIR__, 3);
$componentJson = $componentDir . '/composer.json';
$composerData = json_decode(file_get_contents($componentJson), true);

foreach ($composerData['autoload-dev']['psr-4'] as $prefix => $dir) {
$loader->addPsr4($prefix, $componentDir . '/' . $dir);
}
} else {
exit('Please run "composer install" to install the dependencies' . PHP_EOL);
}
Empty file removed test/unit/.keep
Empty file.
20 changes: 20 additions & 0 deletions test/unit/ServerTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php declare(strict_types=1);


namespace SwoftTest\Server\Unit;


use PHPUnit\Framework\TestCase;

/**
* Class ServerTest
*
* @since 2.0
*/
class ServerTest extends TestCase
{
public function testMethod()
{
$this->assertTrue(true);
}
}

0 comments on commit 0986ca9

Please sign in to comment.