Skip to content

Commit

Permalink
Merge pull request #15 from maurobonfietti/0.14.0
Browse files Browse the repository at this point in the history
Version 0.14.0
  • Loading branch information
maurobonfietti committed Aug 15, 2020
2 parents 02252e8 + e7fb85d commit 809632c
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 22 deletions.
2 changes: 1 addition & 1 deletion src/Command/CrudGeneratorCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

class CrudGeneratorCommand extends Command
{
const COMMAND_VERSION = '0.13.0';
const COMMAND_VERSION = '0.14.0';

public function __construct($app)
{
Expand Down
18 changes: 9 additions & 9 deletions src/Command/CrudGeneratorService.php
Original file line number Diff line number Diff line change
Expand Up @@ -114,11 +114,11 @@ private function getBaseUpdateQueryFunction($fields3, $fields4, $fields5)
private function updateRoutes()
{
$routes = '
$app->get("/'.$this->entity.'", "App\Controller\\'.$this->entityUpper.'\GetAll");
$app->post("/'.$this->entity.'", "App\Controller\\'.$this->entityUpper.'\Create");
$app->get("/'.$this->entity.'/{id}", "App\Controller\\'.$this->entityUpper.'\GetOne");
$app->put("/'.$this->entity.'/{id}", "App\Controller\\'.$this->entityUpper.'\Update");
$app->delete("/'.$this->entity.'/{id}", "App\Controller\\'.$this->entityUpper.'\Delete");
$app->get(\'/'.$this->entity.'\', App\Controller\\'.$this->entityUpper.'\GetAll::class);
$app->post(\'/'.$this->entity.'\', App\Controller\\'.$this->entityUpper.'\Create::class);
$app->get(\'/'.$this->entity.'/{id}\', App\Controller\\'.$this->entityUpper.'\GetOne::class);
$app->put(\'/'.$this->entity.'/{id}\', App\Controller\\'.$this->entityUpper.'\Update::class);
$app->delete(\'/'.$this->entity.'/{id}\', App\Controller\\'.$this->entityUpper.'\Delete::class);
';
$file = __DIR__ . '/../../../../../src/App/Routes.php';
$content = file_get_contents($file);
Expand All @@ -129,8 +129,8 @@ private function updateRoutes()
private function updateRepository()
{
$repository = '
$container["'.$this->entity.'_repository"] = static function ($container): App\Repository\\'.$this->entityUpper.'Repository {
return new App\Repository\\'.$this->entityUpper.'Repository($container["db"]);
$container[\''.$this->entity.'_repository\'] = static function ($container): App\Repository\\'.$this->entityUpper.'Repository {
return new App\Repository\\'.$this->entityUpper.'Repository($container[\'db\']);
};
';
$file = __DIR__ . '/../../../../../src/App/Repositories.php';
Expand All @@ -142,8 +142,8 @@ private function updateRepository()
private function updateServices()
{
$service = '
$container["'.$this->entity.'_service"] = static function ($container): App\Service\\'.$this->entityUpper.'Service {
return new App\Service\\'.$this->entityUpper.'Service($container["'.$this->entity.'_repository"]);
$container[\''.$this->entity.'_service\'] = static function ($container): App\Service\\'.$this->entityUpper.'Service {
return new App\Service\\'.$this->entityUpper.'Service($container[\''.$this->entity.'_repository\']);
};
';
$file = __DIR__ . '/../../../../../src/App/Services.php';
Expand Down
18 changes: 6 additions & 12 deletions src/Command/TemplateBase/ObjectbaseTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,9 @@ public function testCreate()
'' => '',
#postParams
];
$app = $this->getAppInstance();
$req = $this->createRequest('POST', '/objectbase');
$request = $req->withParsedBody($params);
$response = $app->handle($request);
$response = $this->getAppInstance()->handle($request);

$result = (string) $response->getBody();

Expand All @@ -30,9 +29,8 @@ public function testCreate()

public function testGetAll()
{
$app = $this->getAppInstance();
$request = $this->createRequest('GET', '/objectbase');
$response = $app->handle($request);
$response = $this->getAppInstance()->handle($request);

$result = (string) $response->getBody();

Expand All @@ -43,9 +41,8 @@ public function testGetAll()

public function testGetOne()
{
$app = $this->getAppInstance();
$request = $this->createRequest('GET', '/objectbase/' . self::$id);
$response = $app->handle($request);
$response = $this->getAppInstance()->handle($request);

$result = (string) $response->getBody();

Expand All @@ -56,9 +53,8 @@ public function testGetOne()

public function testGetOneNotFound()
{
$app = $this->getAppInstance();
$request = $this->createRequest('GET', '/objectbase/123456789');
$response = $app->handle($request);
$response = $this->getAppInstance()->handle($request);

$result = (string) $response->getBody();

Expand All @@ -68,10 +64,9 @@ public function testGetOneNotFound()

public function testUpdate()
{
$app = $this->getAppInstance();
$req = $this->createRequest('PUT', '/objectbase/' . self::$id);
$request = $req->withParsedBody(['' => '']);
$response = $app->handle($request);
$response = $this->getAppInstance()->handle($request);

$result = (string) $response->getBody();

Expand All @@ -82,9 +77,8 @@ public function testUpdate()

public function testDelete()
{
$app = $this->getAppInstance();
$request = $this->createRequest('DELETE', '/objectbase/' . self::$id);
$response = $app->handle($request);
$response = $this->getAppInstance()->handle($request);

$result = (string) $response->getBody();

Expand Down

0 comments on commit 809632c

Please sign in to comment.