for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace TildBJ\Seeder\Tests\Unit\Generator;
use TildBJ\Seeder\Generator;
use TildBJ\Seeder\Generator\MethodNameGenerator;
use Nimut\TestingFramework\TestCase\UnitTestCase;
/**
* Class MethodNameGeneratorTest
*
* @package TildBJ\Seeder\Tests\Generator
*/
class MethodNameGeneratorTest extends UnitTestCase
{
* @var Generator $subject
protected $subject;
public function setUp()
$faker = $this->createMock(\TildBJ\Seeder\Faker::class);
$this->subject = new MethodNameGenerator($faker);
$faker
object<PHPUnit\Framework\MockObject\MockObject>
object<TildBJ\Seeder\Faker>
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example:
function acceptsInteger($int) { } $x = '123'; // string "123" // Instead of acceptsInteger($x); // we recommend to use acceptsInteger((integer) $x);
}
* @method generate
* @test
public function generateReturnsIntegerIfParameterIsInteger()
$this->assertSame(4, $this->subject->generate(4));
public function generateReturnsIntegerIfParameterCanBeConvertedToInteger()
$this->assertSame(4, $this->subject->generate('4'));
public function generateReturnsMethodName()
$this->assertSame('$faker->getName()', $this->subject->generate('name'));
public function generateReturnsNullWithInvalidParameter()
$faker->method('get')->willThrowException(new \TildBJ\Seeder\Provider\NotFoundException());
$generator = new MethodNameGenerator($faker);
$this->assertSame(null, $generator->generate('InvalidParameter'));
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: