for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
declare(strict_types=1);
namespace SlayerBirden\DFCodeGeneration\Generator\Tests;
use PHPUnit\Framework\TestCase;
use Prophecy\Argument;
use SlayerBirden\DFCodeGeneration\CodeLoader;
class GetsTest extends TestCase
{
private $provider;
private $factory;
protected function setUp()
$this->provider = $this->prophesize(EntityProviderInterface::class);
$this->factory = $this->prophesize(EntityProviderFactoryInterface::class);
$this->factory->create(Argument::any())->willReturn($this->provider->reveal());
}
public function testCreateClass()
$this->provider->getId()->willReturn(1);
$this->provider->getEntitySpec()->willReturn([
[
'name' => 'id',
'type' => 'integer',
'nullable' => false,
],
'name' => 'name',
'type' => 'string',
'nullable' => true,
'name' => 'email',
]);
$this->provider->getPostParams()->willReturn([
'name' => 'bob',
'email' => '[email protected]',
$this->provider->getParams()->willReturn([
'id' => 1,
$this->provider->getBaseName()->willReturn('User');
$this->provider->getShortName()->willReturn('user');
$this->provider->getEntityClassName()->willReturn('Dummy\\User');
$this->provider->hasUnique()->willReturn(true);
$this->provider->getIdName()->willReturn('id');
$gets = new Gets('Dummy\\User', $this->factory->reveal());
$code = $gets->generate();
$this->assertNotEmpty($code);
// asserting php code is valid and can be loaded
CodeLoader::loadCode($code, 'GetsCest.php');