Skip to content
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
33 changes: 33 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: Testing

on: [push]

jobs:
test:

runs-on: ubuntu-latest

strategy:
matrix:
php-versions: ['8.0', '8.1', '8.2', '8.3', '8.4']
include:
- operating-system: 'ubuntu-latest'
php-versions: '8.0'
phpunit-versions: 9

steps:

- name: Checkout
uses: actions/checkout@v3

- name: Composer Install
uses: php-actions/composer@v6
with:
php_version: ${{ matrix.php-versions }}

- name: PHPUnit tests
uses: php-actions/phpunit@v4
with:
php_extensions: "pcov"
version: "9.6"
php_version: ${{ matrix.php-versions }}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ builds
.idea
docs
phpunit.xml
.phpunit.result.cache
tmp/
*.iml
composer.lock
Expand Down
60 changes: 32 additions & 28 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,32 +1,36 @@
{
"name": "fluent/logger",
"type": "library",
"description": "a logging library for Fluentd",
"keywords": ["log","logging"],
"homepage": "http://github.com/fluent/fluent-logger-php",
"license": "Apache",
"authors": [
{
"name": "Shuhei Tanuma",
"email": "[email protected]"
},
{
"name": "Sotaro Karasawa",
"email": "[email protected]"
},
{
"name": "DQNEO",
"email": "[email protected]"
}
],
"require": {
"php": "^5.6"
"name": "dealnews/fluent-logger",
"type": "library",
"description": "a logging library for Fluentd",
"keywords": [
"log",
"logging"
],
"homepage": "http://github.com/fluent/fluent-logger-php",
"license": "Apache-2.0",
"authors": [
{
"name": "Shuhei Tanuma",
"email": "[email protected]"
},
"require-dev": {
"phpunit/phpunit": "~4.3",
"phpunit/phpunit-mock-objects": "2.3.0"
{
"name": "Sotaro Karasawa",
"email": "[email protected]"
},
"autoload": {
"psr-4": {"Fluent\\Logger\\": "src/"}
{
"name": "DQNEO",
"email": "[email protected]"
}
}
],
"require": {
"php": "^8.0"
},
"require-dev": {
"phpunit/phpunit": "^9.5"
},
"autoload": {
"psr-4": {
"Fluent\\Logger\\": "src/"
}
}
}
65 changes: 21 additions & 44 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,48 +1,25 @@
<?xml version="1.0" encoding="UTF-8" ?>
<phpunit backupGlobals="true"
backupStaticAttributes="false"
bootstrap="tests/bootstrap.php"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="false"
convertWarningsToExceptions="false"
processIsolation="false"
stopOnError="false"
stopOnFailure="false"
stopOnIncomplete="false"
stopOnSkipped="false"
syntaxCheck="true"
reportUselessTests="true"
strictCoverage="true"
disallowTestOutput="true"
beStrictAboutTestSize="true"
verbose="true">
<php>
<ini name="date.timezone" value="Asia/Tokyo" />
</php>
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" bootstrap="./tests/bootstrap.php" colors="true" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd">
<coverage includeUncoveredFiles="true" processUncoveredFiles="false">
<include>
<directory suffix=".php">./src</directory>
</include>
<exclude>
<directory suffix=".php">./tests</directory>
<directory suffix=".php">./vendor</directory>
</exclude>
<report>
<text outputFile="php://stdout" showUncoveredFiles="true"/>
</report>
</coverage>
<testsuites>
<testsuite name="Fluent\\Logger Test Suite">
<directory>tests</directory>
<testsuite name="default">
<directory>./tests</directory>
</testsuite>
</testsuites>

<logging>
<log type="coverage-html" target="builds/coverage" title="fluent-logger-php"
charset="UTF-8" yui="true" highlight="true"
lowUpperBound="35" highLowerBound="70"/>
<log type="coverage-clover" target="builds/logs/clover.xml"/>
<log type="junit" target="builds/logs/junit.xml" logIncompleteSkipped="false"/>
</logging>

<filter>
<whitelist addUncoveredFilesFromWhitelist="true">
<directory suffix=".php">src</directory>
<exclude>
<directory>examples</directory>
<directory>tests</directory>
<directory>cookbooks</directory>
<directory>builds</directory>
</exclude>
</whitelist>
</filter>
<groups>
<exclude>
<group>functional</group>
</exclude>
</groups>
</phpunit>
2 changes: 1 addition & 1 deletion src/FluentLogger.php
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ class FluentLogger implements LoggerInterface
public function __construct($host = FluentLogger::DEFAULT_ADDRESS,
$port = FluentLogger::DEFAULT_LISTEN_PORT,
array $options = array(),
PackerInterface $packer = null)
?PackerInterface $packer = null)
{
/* keep original host and port */
$this->host = $host;
Expand Down
4 changes: 2 additions & 2 deletions tests/Fluent/Logger/BaseLoggerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ function fluentTests_FluentLogger_DummyFunction()
{
}

class BaseLoggerTest extends \PHPUnit_Framework_TestCase
class BaseLoggerTest extends \PHPUnit\Framework\TestCase
{
/**
* testing compatible before and after
Expand Down Expand Up @@ -42,10 +42,10 @@ function () {

/**
* @dataProvider invalidErrorHandlerProvider
* @expectedException InvalidArgumentException
*/
public function testRegisterInvalidErrorHandler($eh)
{
$this->expectException(\InvalidArgumentException::class);
$base = $this->getMockForAbstractClass('Fluent\Logger\FluentLogger');
$base->registerErrorHandler($eh);
}
Expand Down
2 changes: 1 addition & 1 deletion tests/Fluent/Logger/EntityTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

use Fluent\Logger\Entity;

class EntityTest extends \PHPUnit_Framework_TestCase
class EntityTest extends \PHPUnit\Framework\TestCase
{
const TAG = "debug.test";

Expand Down
19 changes: 11 additions & 8 deletions tests/Fluent/Logger/FluentLoggerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@
use Fluent\Logger;
use Fluent\Logger\FluentLogger;

class FluentLoggerTest extends \PHPUnit_Framework_TestCase
class FluentLoggerTest extends \PHPUnit\Framework\TestCase
{
const TAG = 'debug.test';
const OBJECT_KEY = 'hello';
const OBJECT_VALUE = 'world';

public function tearDown()
public function tearDown(): void
{
FluentLogger::clearInstances();
}
Expand Down Expand Up @@ -104,7 +104,9 @@ private function setSocket($logger, $socket)

private function getMockOfLogger(array $method)
{
return $this->getMock("Fluent\Logger\FluentLogger", array("write"), array("localhost"));
return $this->getMockBuilder(\Fluent\Logger\FluentLogger::class)
->onlyMethods(array("write"))
->getMock();
}

/**
Expand Down Expand Up @@ -164,12 +166,13 @@ public function testClearInstances()
$prop = new \ReflectionProperty("\Fluent\Logger\FluentLogger", "instances");
$prop->setAccessible(true);

FluentLogger::open("localhost", 1191);
FluentLogger::open("localhost", 1192);
$this->assertCount(2, $prop->getValue("FluentLogger"));
$logger = new FluentLogger("localhost");
$logger::open("localhost", 1191);
$logger::open("localhost", 1192);
$this->assertCount(2, $prop->getValue($logger));

FluentLogger::clearInstances();
$this->assertCount(0, $prop->getValue("FluentLogger"));
$logger::clearInstances();
$this->assertCount(0, $prop->getValue($logger));
}

public function testMergeOptions()
Expand Down
4 changes: 2 additions & 2 deletions tests/Fluent/Logger/JsonPackerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@
use Fluent\Logger\Entity;
use Fluent\Logger\JsonPacker;

class JsonPackerTest extends \PHPUnit_Framework_TestCase
class JsonPackerTest extends \PHPUnit\Framework\TestCase
{
const TAG = "debug.test";
const EXPECTED_TIME = 123456789;

protected $time;
protected $expected_data = array();

public function setUp()
public function setUp(): void
{
$this->expected_data = array("abc" => "def");
}
Expand Down