Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Rename package core #2

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 4 commits into from
Jan 15, 2023
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
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
}
],
"require": {
"micro/http-core": "^1",
"micro/plugin-http-core": "^1",
"micro/plugin-logger-core": "^1"
},
"require-dev": {
Expand Down
9 changes: 0 additions & 9 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,6 @@
<directory>tests/Unit</directory>
</testsuite>
</testsuites>
<filter>
<whitelist>
<directory suffix=".php">src/</directory>
<exclude>
<directory>src/Exception</directory>
<file>src/HttpCorePlugin.php</file>
</exclude>
</whitelist>
</filter>
<coverage>
<include>
<directory suffix=".php">src</directory>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

use Micro\Plugin\Http\Business\Logger\Formatter\LogFormatterFactoryInterface;
use Micro\Plugin\Http\HttpLoggerPluginConfigurationInterface;
use Micro\Plugin\Logger\LoggerFacadeInterface;
use Micro\Plugin\Logger\Facade\LoggerFacadeInterface;

/**
* @author Stanislau Komar <[email protected]>
Expand Down
2 changes: 2 additions & 0 deletions src/Business/Logger/Formatter/Format/AbstractFormat.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@

/**
* @author Stanislau Komar <[email protected]>
*
* @codeCoverageIgnore
*/
abstract class AbstractFormat implements LogFormatterInterface
{
Expand Down
4 changes: 3 additions & 1 deletion src/HttpLoggerPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,15 @@
use Micro\Plugin\Http\Business\Logger\Formatter\LogFormatterFactoryInterface;
use Micro\Plugin\Http\Decorator\HttpFacadeLoggerDecorator;
use Micro\Plugin\Http\Facade\HttpFacadeInterface;
use Micro\Plugin\Logger\LoggerFacadeInterface;
use Micro\Plugin\Logger\Facade\LoggerFacadeInterface;
use Micro\Plugin\Logger\LoggerPlugin;

/**
* @author Stanislau Komar <[email protected]>
*
* @method HttpLoggerPluginConfigurationInterface configuration()
*
* @codeCoverageIgnore
*/
class HttpLoggerPlugin implements DependencyProviderInterface, PluginDependedInterface, ConfigurableInterface
{
Expand Down
9 changes: 5 additions & 4 deletions src/HttpLoggerPluginConfiguration.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
namespace Micro\Plugin\Http;

use Micro\Framework\Kernel\Configuration\PluginConfiguration;
use Micro\Plugin\Logger\LoggerPluginConfiguration;

/**
* @author Stanislau Komar <[email protected]>
Expand All @@ -31,14 +32,14 @@ class HttpLoggerPluginConfiguration extends PluginConfiguration implements HttpL

public const DECORATION_DEFAULT = 10;

public function getAccessLoggerName(): string|null
public function getAccessLoggerName(): string
{
return $this->configuration->get(self::CFG_LOGGER_ACCESS);
return (string) $this->configuration->get(self::CFG_LOGGER_ACCESS, LoggerPluginConfiguration::LOGGER_NAME_DEFAULT);
}

public function getErrorLoggerName(): string|null
public function getErrorLoggerName(): string
{
return $this->configuration->get(self::CFG_LOGGER_ERROR);
return (string) $this->configuration->get(self::CFG_LOGGER_ERROR, LoggerPluginConfiguration::LOGGER_NAME_DEFAULT);
}

public function getWeight(): int
Expand Down
4 changes: 2 additions & 2 deletions src/HttpLoggerPluginConfigurationInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@
*/
interface HttpLoggerPluginConfigurationInterface
{
public function getAccessLoggerName(): string|null;
public function getAccessLoggerName(): string;

public function getErrorLoggerName(): string|null;
public function getErrorLoggerName(): string;

public function getErrorLogFormat(): string;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,14 @@
* file that was distributed with this source code.
*/

namespace Micro\Plugin\Http\Business\Executor;
namespace Micro\Plugin\Http\Test\Unit\Business\Executor;

use Micro\Plugin\Http\Business\Executor\HttpExecutorLoggerAwareDecoratorFactory;
use Micro\Plugin\Http\Business\Executor\RouteExecutorInterface;
use Micro\Plugin\Http\Business\Logger\Formatter\LogFormatterFactoryInterface;
use Micro\Plugin\Http\Facade\HttpFacadeInterface;
use Micro\Plugin\Http\HttpLoggerPluginConfigurationInterface;
use Micro\Plugin\Logger\LoggerFacadeInterface;
use Micro\Plugin\Logger\Facade\LoggerFacadeInterface;
use PHPUnit\Framework\TestCase;

class HttpExecutorLoggerAwareDecoratorFactoryTest extends TestCase
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@
* file that was distributed with this source code.
*/

namespace Micro\Plugin\Http\Business\Executor;
namespace Micro\Plugin\Http\Test\Unit\Business\Executor;

use Micro\Plugin\Http\Business\Executor\HttpExecutorLoggerAwareDecorator;
use Micro\Plugin\Http\Business\Logger\Formatter\LogFormatterInterface;
use Micro\Plugin\Http\Exception\HttpException;
use Micro\Plugin\Http\Facade\HttpFacadeInterface;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
* file that was distributed with this source code.
*/

namespace Micro\Plugin\Http\Business\Logger\Formatter\Format;
namespace Micro\Plugin\Http\Test\Unit\Business\Logger\Formatter\Format;

use Micro\Plugin\Http\Business\Logger\Formatter\LogFormatterInterface;
use Micro\Plugin\Http\Exception\HttpException;
Expand All @@ -31,7 +31,8 @@ public function testFormat(bool $hasResponse, \Throwable|null $throwable)
{
$object = $this->createTestObject();

$this->assertIsString(
$this->assertResult(
$object,
$object->format(
$this->createRequest(),
$this->createResponse($hasResponse),
Expand All @@ -52,6 +53,14 @@ public function dataProvider()
];
}

protected function assertResult(mixed $object, mixed $result)
{
$this->assertEquals(
$this->getVariable(),
$result
);
}

public function createThrowable(\Throwable|null $throwable): \Throwable|null
{
return $throwable;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@
* file that was distributed with this source code.
*/

namespace Micro\Plugin\Http\Business\Logger\Formatter\Format;
namespace Micro\Plugin\Http\Test\Unit\Business\Logger\Formatter\Format;

use Micro\Plugin\Http\Business\Logger\Formatter\Format\HttpRefererFormat;

class HttpRefererFormatTest extends AbstractFormatTest
{
Expand All @@ -22,4 +24,9 @@ public function getVariable(): string
{
return 'http_referer';
}

public function assertResult(mixed $object, mixed $result)
{
$this->assertEquals('', $result);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@
* file that was distributed with this source code.
*/

namespace Micro\Plugin\Http\Business\Logger\Formatter\Format;
namespace Micro\Plugin\Http\Test\Unit\Business\Logger\Formatter\Format;

use Micro\Plugin\Http\Business\Logger\Formatter\Format\IpFormat;
use Micro\Plugin\Http\Exception\HttpException;
use Symfony\Component\HttpFoundation\Request;

Expand All @@ -23,7 +24,8 @@ public function testFormat(bool $hasResponse, \Throwable|null $throwable, $hasIp
{
$object = $this->createTestObject();

$this->assertIsString(
$this->assertEquals(
'127.0.0.1',
$object->format(
$this->createRequest($hasIp),
$this->createResponse($hasResponse),
Expand Down Expand Up @@ -60,7 +62,9 @@ protected function createRequest(bool $hasIp = null): Request
return parent::createRequest();
}

$request = new Request([], [], [], [], [], ['REMOTE_ADDR' => '0.0.0.0']);
return parent::createRequest();

$request = new Request([], [], [], [], [], []);

return $request;
}
Expand All @@ -72,6 +76,6 @@ protected function getTestClass(): string

public function getVariable(): string
{
return 'remote_ip';
return 'remote_addr';
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@
* file that was distributed with this source code.
*/

namespace Micro\Plugin\Http\Business\Logger\Formatter\Format;
namespace Micro\Plugin\Http\Test\Unit\Business\Logger\Formatter\Format;

use Micro\Plugin\Http\Business\Logger\Formatter\Format\MethodFormat;

class MethodFormatTest extends AbstractFormatTest
{
Expand All @@ -22,4 +24,9 @@ public function getVariable(): string
{
return 'request_method';
}

public function assertResult(mixed $object, mixed $result)
{
$this->assertEquals('GET', $result);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@
* file that was distributed with this source code.
*/

namespace Micro\Plugin\Http\Business\Logger\Formatter\Format;
namespace Micro\Plugin\Http\Test\Unit\Business\Logger\Formatter\Format;

use Micro\Plugin\Http\Business\Logger\Formatter\Format\RequestBodyFormat;
use Symfony\Component\HttpFoundation\Request;

class RequestBodyFormatTest extends AbstractFormatTest
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@
* file that was distributed with this source code.
*/

namespace Micro\Plugin\Http\Business\Logger\Formatter\Format;
namespace Micro\Plugin\Http\Test\Unit\Business\Logger\Formatter\Format;

use Micro\Plugin\Http\Business\Logger\Formatter\Format\RequestFormat;

class RequestFormatTest extends AbstractFormatTest
{
Expand All @@ -22,4 +24,9 @@ public function getVariable(): string
{
return 'request';
}

public function assertResult(mixed $object, mixed $result)
{
$this->assertEquals('/test', $result);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@
* file that was distributed with this source code.
*/

namespace Micro\Plugin\Http\Business\Logger\Formatter\Format;
namespace Micro\Plugin\Http\Test\Unit\Business\Logger\Formatter\Format;

use Micro\Plugin\Http\Business\Logger\Formatter\Format\StatusFormat;

class StatusFormatTest extends AbstractFormatTest
{
Expand All @@ -22,4 +24,11 @@ public function getVariable(): string
{
return 'status';
}

protected function assertResult(mixed $object, mixed $result)
{
$this->assertTrue(
\in_array($result, ['500', 0])
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@
* file that was distributed with this source code.
*/

namespace Micro\Plugin\Http\Business\Logger\Formatter\Format;
namespace Micro\Plugin\Http\Test\Unit\Business\Logger\Formatter\Format;

use Micro\Plugin\Http\Business\Logger\Formatter\Format\TimeFormat;

class TimeFormatTest extends AbstractFormatTest
{
Expand All @@ -22,4 +24,11 @@ public function getVariable(): string
{
return 'time';
}

public function assertResult(mixed $object, mixed $result)
{
$date = new \DateTime($result);

$this->assertEquals($result, $date->format('c'));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@
* file that was distributed with this source code.
*/

namespace Micro\Plugin\Http\Business\Logger\Formatter\Format;
namespace Micro\Plugin\Http\Test\Unit\Business\Logger\Formatter\Format;

use Micro\Plugin\Http\Business\Logger\Formatter\Format\UsernameFormat;

class UsernameFormatTest extends AbstractFormatTest
{
Expand All @@ -22,4 +24,9 @@ public function getVariable(): string
{
return 'remote_user';
}

public function assertResult(mixed $object, mixed $result)
{
$this->assertEquals('', $result);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,10 @@
* file that was distributed with this source code.
*/

namespace Micro\Plugin\Http\Business\Logger\Formatter;
namespace Micro\Plugin\Http\Test\Unit\Business\Logger\Formatter;

use Micro\Plugin\Http\Business\Logger\Formatter\LogFormatterFactory;
use Micro\Plugin\Http\Business\Logger\Formatter\LogFormatterInterface;
use PHPUnit\Framework\TestCase;

class LogFormatterFactoryTest extends TestCase
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,10 @@
* file that was distributed with this source code.
*/

namespace Micro\Plugin\Http\Business\Logger\Formatter;
namespace Micro\Plugin\Http\Test\Unit\Business\Logger\Formatter;

use Micro\Plugin\Http\Business\Logger\Formatter\LogFormatter;
use Micro\Plugin\Http\Business\Logger\Formatter\LogFormatterInterface;
use PHPUnit\Framework\TestCase;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,12 @@
* file that was distributed with this source code.
*/

namespace Micro\Plugin\Http\Decorator;
namespace Micro\Plugin\Http\Test\Unit\Decorator;

use Micro\Plugin\Http\Business\Executor\RouteExecutorFactoryInterface;
use Micro\Plugin\Http\Business\Route\RouteBuilderInterface;
use Micro\Plugin\Http\Business\Route\RouteInterface;
use Micro\Plugin\Http\Decorator\HttpFacadeLoggerDecorator;
use Micro\Plugin\Http\Facade\HttpFacadeInterface;
use PHPUnit\Framework\TestCase;
use Symfony\Component\HttpFoundation\Request;
Expand Down
Loading