for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace SubjectivePHPTest\Psr\Log;
use SubjectivePHP\Psr\Log\MessageValidatorTrait;
/**
* @coversDefaultClass \SubjectivePHP\Psr\Log\MessageValidatorTrait
*/
final class MessageValidatorTraitTest extends \PHPUnit\Framework\TestCase
{
use MessageValidatorTrait;
* @param mixed $message The message that will validate.
*
* @test
* @covers ::validateMessage
* @dataProvider provideValidValidateData
* @return void
public function validateMessageValid($message)
$this->assertNull($this->validateMessage($message));
$this->validateMessage($message)
SubjectivePHPTest\Psr\Lo...Test::validateMessage()
This check looks for function or method calls that always return null and whose return value is used.
class A { function getObject() { return null; } } $a = new A(); if ($a->getObject()) {
The method getObject() can return nothing but null, so it makes no sense to use the return value.
getObject()
The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.
}
* Provides valid messages for testing.
* @return array
public function provideValidValidateData()
return [
['a string' => 'the message'],
['a boolean' => true],
['an int' => 123],
['a float' => 12.3],
['an object' => new \SplFileInfo(__FILE__)],
];
public function validateMessageInvalid()
$this->expectException(\Psr\Log\InvalidArgumentException::class);
$this->validateMessage(new \StdClass());
This check looks for function or method calls that always return null and whose return value is used.
The method
getObject()can return nothing but null, so it makes no sense to use the return value.The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.