Simplify the usage of
-
Logging with Monolog
-
Testing with PHPUnit
-
Reflection with PHP
-
Developer shortkeys for composer
-
Monolog/ConsoleLogger - Logging to console
-
Log format:
%datetime% [%level%] %class%→%function%() - %message% %context% %extra%
-
-
Monolog/FileLogger - Logging to a file
-
Monolog/PlainLogger - Sending the output "as it is" to the console (raw)
-
EasyGoingTestCase - All you need is already prepared, so concentrate on unit tests
-
UnavailableFieldsTrait - Get value from unaccessable class fields (aka properties)
-
UnavailableMethodsTrait - Call unaccessable class methods
<?php
declare(strict_types=1);
namespace foo;
class FooClazz
{
public function isValid(): bool
{
return true; // not very complex, i know ;-)
}
}<?php
declare(strict_types=1);
namespace foo;
require_once __DIR__ . './bootstrap.php';
use PHPUnit\Framework\EasyGoingTestCase;
class FooClazzTest extends EasyGoingTestCase
{
protected function prepareO2t(): FooClazz // cast to business class
{
return new FooClazz();
}
protected function getCasto2t(): FooClazz // cast to business class
{
return $this->o2t;
}
public function testFoo(): void
{
$this->logger->debug('testFoo() - Start');
// test code
static::assertTrue($this->getCasto2t()->isValid());
// or
static::assertTrue($this->o2t->isValid());
$this->logger->info('testFoo() - End');
}
}PHPUnit 9.6.25 by Sebastian Bergmann and contributors.
20250821-162846.609 [DEBUG ] PHPUnit\Framework\EasyGoingTestCase->testFoo() - testFoo() - Start
20250821-162846.611 [INFO ] PHPUnit\Framework\EasyGoingTestCase->testFoo() - testFoo() - End
..<?php
declare(strict_types=1);
namespace foo;
class FooClazz
{
private $privateFoo = 'privateFooValue';
protected function protectedFoo(): string
{
return 'protectedFooMethod';
}
}<?php
declare(strict_types=1);
namespace foo;
require_once __DIR__ . './bootstrap.php';
use ollily\Tools\Reflection\UnavailableFieldsTrait;
use ollily\Tools\Reflection\UnavailableMethodsTrait;
use PHPUnit\Framework\EasyGoingTestCase;
class FooClazzTest extends EasyGoingTestCase
{
use UnavailableFieldsTrait;
use UnavailableMethodsTrait;
protected function prepareO2t(): FooClazz // cast to business class
{
return new FooClazz();
}
protected function getCasto2t(): FooClazz // cast to business class
{
return $this->o2t;
}
public function testPrivateField(): void
{
$result = $this->getFieldFromO2t('privateFoo');
// or
$result2 = $this->getFieldByReflection(FooClazz::class, 'privateFoo', $this->o2t);
$this->logger->info("privateFoo is '${result}' or '${result2}'");
static::assertEquals('privateFooValue', $result);
static::assertEquals($result, $result2);
}
public function testProtectedMethod(): void
{
$result = $this->callMethodOnO2t('protectedFoo');
// or
$result2 = $this->callMethodByReflection(FooClazz::class, 'protectedFoo', $this->o2t);
$this->logger->info("protectedFoo returns '${result}' or '${result2}'");
static::assertEquals('protectedFooMethod', $result);
static::assertEquals($result, $result2);
}
}PHPUnit 9.6.25 by Sebastian Bergmann and contributors.
20250821-162846.588 [INFO ] PHPUnit\Framework\EasyGoingTestCase->testPrivateField() - privateFoo is 'privateFooValue' or 'privateFooValue'
20250821-162846.608 [INFO ] PHPUnit\Framework\EasyGoingTestCase->testProtectedMethod() - protectedFoo returns 'protectedFooMethod' or 'protectedFooMethod'
..-
Configuration - How to configure
-
Composer Commands - New commands for composer
-
Analysis - Project Status
(c) 2025 by Oliver Glowa