for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
/**
* Copyright (C) 2017 Gerrit Addiks.
* This package (including this file) was released under the terms of the GPL-3.0.
* You should have received a copy of the GNU General Public License along with this program.
* If not, see <http://www.gnu.org/licenses/> or send me a mail so i can send you a copy.
* @license GPL-3.0
* @author Gerrit Addiks <[email protected]>
*/
namespace Addiks\SymfonyGenerics\Tests\Unit\Arguments;
use PHPUnit\Framework\TestCase;
use Addiks\SymfonyGenerics\Arguments\AdditionalDataArgument;
use Addiks\SymfonyGenerics\Arguments\ArgumentContextInterface;
final class AdditionalDataArgumentTest extends TestCase
{
* @test
public function shouldResolveAdditionalDataArgument()
$context = $this->createMock(ArgumentContextInterface::class);
$context->method('get')->willReturn(12345);
$argument = new AdditionalDataArgument("some-key", $context);
$context
object<PHPUnit\Framework\MockObject\MockObject>
object<Addiks\SymfonyGen...gumentContextInterface>
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);
$this->assertEquals(12345, $argument->resolve());
}
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: