Skip to content

Commit d9a6721

Browse files
committed
Fixed all tests
1 parent e100671 commit d9a6721

19 files changed

+135
-20
lines changed

src/Business/Logger/Formatter/Format/AbstractFormat.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919

2020
/**
2121
* @author Stanislau Komar <kost@micro-php.net>
22+
*
23+
* @codeCoverageIgnore
2224
*/
2325
abstract class AbstractFormat implements LogFormatterInterface
2426
{

src/HttpLoggerPlugin.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@
3131
* @author Stanislau Komar <kost@micro-php.net>
3232
*
3333
* @method HttpLoggerPluginConfigurationInterface configuration()
34+
*
35+
* @codeCoverageIgnore
3436
*/
3537
class HttpLoggerPlugin implements DependencyProviderInterface, PluginDependedInterface, ConfigurableInterface
3638
{

tests/Unit/Micro/Plugin/Http/Business/Executor/HttpExecutorLoggerAwareDecoratorFactoryTest.php renamed to tests/Unit/Business/Executor/HttpExecutorLoggerAwareDecoratorFactoryTest.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,10 @@
99
* file that was distributed with this source code.
1010
*/
1111

12-
namespace Micro\Plugin\Http\Business\Executor;
12+
namespace Micro\Plugin\Http\Test\Unit\Business\Executor;
1313

14+
use Micro\Plugin\Http\Business\Executor\HttpExecutorLoggerAwareDecoratorFactory;
15+
use Micro\Plugin\Http\Business\Executor\RouteExecutorInterface;
1416
use Micro\Plugin\Http\Business\Logger\Formatter\LogFormatterFactoryInterface;
1517
use Micro\Plugin\Http\Facade\HttpFacadeInterface;
1618
use Micro\Plugin\Http\HttpLoggerPluginConfigurationInterface;

tests/Unit/Micro/Plugin/Http/Business/Executor/HttpExecutorLoggerAwareDecoratorTest.php renamed to tests/Unit/Business/Executor/HttpExecutorLoggerAwareDecoratorTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,9 @@
99
* file that was distributed with this source code.
1010
*/
1111

12-
namespace Micro\Plugin\Http\Business\Executor;
12+
namespace Micro\Plugin\Http\Test\Unit\Business\Executor;
1313

14+
use Micro\Plugin\Http\Business\Executor\HttpExecutorLoggerAwareDecorator;
1415
use Micro\Plugin\Http\Business\Logger\Formatter\LogFormatterInterface;
1516
use Micro\Plugin\Http\Exception\HttpException;
1617
use Micro\Plugin\Http\Facade\HttpFacadeInterface;

tests/Unit/Micro/Plugin/Http/Business/Logger/Formatter/Format/AbstractFormatTest.php renamed to tests/Unit/Business/Logger/Formatter/Format/AbstractFormatTest.php

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
* file that was distributed with this source code.
1212
*/
1313

14-
namespace Micro\Plugin\Http\Business\Logger\Formatter\Format;
14+
namespace Micro\Plugin\Http\Test\Unit\Business\Logger\Formatter\Format;
1515

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

34-
$this->assertIsString(
34+
$this->assertResult(
35+
$object,
3536
$object->format(
3637
$this->createRequest(),
3738
$this->createResponse($hasResponse),
@@ -52,6 +53,14 @@ public function dataProvider()
5253
];
5354
}
5455

56+
protected function assertResult(mixed $object, mixed $result)
57+
{
58+
$this->assertEquals(
59+
$this->getVariable(),
60+
$result
61+
);
62+
}
63+
5564
public function createThrowable(\Throwable|null $throwable): \Throwable|null
5665
{
5766
return $throwable;

tests/Unit/Micro/Plugin/Http/Business/Logger/Formatter/Format/HttpRefererFormatTest.php renamed to tests/Unit/Business/Logger/Formatter/Format/HttpRefererFormatTest.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@
99
* file that was distributed with this source code.
1010
*/
1111

12-
namespace Micro\Plugin\Http\Business\Logger\Formatter\Format;
12+
namespace Micro\Plugin\Http\Test\Unit\Business\Logger\Formatter\Format;
13+
14+
use Micro\Plugin\Http\Business\Logger\Formatter\Format\HttpRefererFormat;
1315

1416
class HttpRefererFormatTest extends AbstractFormatTest
1517
{
@@ -22,4 +24,9 @@ public function getVariable(): string
2224
{
2325
return 'http_referer';
2426
}
27+
28+
public function assertResult(mixed $object, mixed $result)
29+
{
30+
$this->assertEquals('', $result);
31+
}
2532
}

tests/Unit/Micro/Plugin/Http/Business/Logger/Formatter/Format/IpFormatTest.php renamed to tests/Unit/Business/Logger/Formatter/Format/IpFormatTest.php

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,9 @@
99
* file that was distributed with this source code.
1010
*/
1111

12-
namespace Micro\Plugin\Http\Business\Logger\Formatter\Format;
12+
namespace Micro\Plugin\Http\Test\Unit\Business\Logger\Formatter\Format;
1313

14+
use Micro\Plugin\Http\Business\Logger\Formatter\Format\IpFormat;
1415
use Micro\Plugin\Http\Exception\HttpException;
1516
use Symfony\Component\HttpFoundation\Request;
1617

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

26-
$this->assertIsString(
27+
$this->assertEquals(
28+
'127.0.0.1',
2729
$object->format(
2830
$this->createRequest($hasIp),
2931
$this->createResponse($hasResponse),
@@ -60,7 +62,9 @@ protected function createRequest(bool $hasIp = null): Request
6062
return parent::createRequest();
6163
}
6264

63-
$request = new Request([], [], [], [], [], ['REMOTE_ADDR' => '0.0.0.0']);
65+
return parent::createRequest();
66+
67+
$request = new Request([], [], [], [], [], []);
6468

6569
return $request;
6670
}
@@ -72,6 +76,6 @@ protected function getTestClass(): string
7276

7377
public function getVariable(): string
7478
{
75-
return 'remote_ip';
79+
return 'remote_addr';
7680
}
7781
}

tests/Unit/Micro/Plugin/Http/Business/Logger/Formatter/Format/MethodFormatTest.php renamed to tests/Unit/Business/Logger/Formatter/Format/MethodFormatTest.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@
99
* file that was distributed with this source code.
1010
*/
1111

12-
namespace Micro\Plugin\Http\Business\Logger\Formatter\Format;
12+
namespace Micro\Plugin\Http\Test\Unit\Business\Logger\Formatter\Format;
13+
14+
use Micro\Plugin\Http\Business\Logger\Formatter\Format\MethodFormat;
1315

1416
class MethodFormatTest extends AbstractFormatTest
1517
{
@@ -22,4 +24,9 @@ public function getVariable(): string
2224
{
2325
return 'request_method';
2426
}
27+
28+
public function assertResult(mixed $object, mixed $result)
29+
{
30+
$this->assertEquals('GET', $result);
31+
}
2532
}

tests/Unit/Micro/Plugin/Http/Business/Logger/Formatter/Format/RequestBodyFormatTest.php renamed to tests/Unit/Business/Logger/Formatter/Format/RequestBodyFormatTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,9 @@
99
* file that was distributed with this source code.
1010
*/
1111

12-
namespace Micro\Plugin\Http\Business\Logger\Formatter\Format;
12+
namespace Micro\Plugin\Http\Test\Unit\Business\Logger\Formatter\Format;
1313

14+
use Micro\Plugin\Http\Business\Logger\Formatter\Format\RequestBodyFormat;
1415
use Symfony\Component\HttpFoundation\Request;
1516

1617
class RequestBodyFormatTest extends AbstractFormatTest

tests/Unit/Micro/Plugin/Http/Business/Logger/Formatter/Format/RequestFormatTest.php renamed to tests/Unit/Business/Logger/Formatter/Format/RequestFormatTest.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@
99
* file that was distributed with this source code.
1010
*/
1111

12-
namespace Micro\Plugin\Http\Business\Logger\Formatter\Format;
12+
namespace Micro\Plugin\Http\Test\Unit\Business\Logger\Formatter\Format;
13+
14+
use Micro\Plugin\Http\Business\Logger\Formatter\Format\RequestFormat;
1315

1416
class RequestFormatTest extends AbstractFormatTest
1517
{
@@ -22,4 +24,9 @@ public function getVariable(): string
2224
{
2325
return 'request';
2426
}
27+
28+
public function assertResult(mixed $object, mixed $result)
29+
{
30+
$this->assertEquals('/test', $result);
31+
}
2532
}

0 commit comments

Comments
 (0)