Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3f28328
commit e1e2593
Showing
14 changed files
with
280 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 46 additions & 0 deletions
46
tests/Fixtures/TestBundle/Controller/EloquentMapped/DummyValidationController.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the API Platform project. | ||
* | ||
* (c) Kévin Dunglas <dunglas@gmail.com> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace ApiPlatform\Core\Tests\Fixtures\TestBundle\Controller\EloquentMapped; | ||
|
||
use ApiPlatform\Core\Tests\Fixtures\TestBundle\Resource\DummyValidation; | ||
use Symfony\Component\Routing\Annotation\Route; | ||
|
||
class DummyValidationController | ||
{ | ||
/** | ||
* @Route( | ||
* methods={"POST"}, | ||
* name="post_validation_groups", | ||
* path="/dummy_validation/validation_groups", | ||
* defaults={"_api_resource_class"=DummyValidation::class, "_api_collection_operation_name"="post_validation_groups"} | ||
* ) | ||
*/ | ||
public function postValidationGroups($data) | ||
{ | ||
return $data; | ||
} | ||
|
||
/** | ||
* @Route( | ||
* methods={"POST"}, | ||
* name="post_validation_sequence", | ||
* path="/dummy_validation/validation_sequence", | ||
* defaults={"_api_resource_class"=DummyValidation::class, "_api_collection_operation_name"="post_validation_sequence"} | ||
* ) | ||
*/ | ||
public function postValidationSequence($data) | ||
{ | ||
return $data; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the API Platform project. | ||
* | ||
* (c) Kévin Dunglas <dunglas@gmail.com> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace ApiPlatform\Core\Tests\Fixtures\TestBundle\Models; | ||
|
||
use ApiPlatform\Core\Annotation\ApiResource; | ||
use Illuminate\Database\Eloquent\Model; | ||
|
||
/** | ||
* @ApiResource( | ||
* collectionOperations={ | ||
* "get"={"method"="GET"}, | ||
* "post"={"path"="dummy_validation.{_format}", "method"="POST"}, | ||
* "post_validation_groups"={"route_name"="post_validation_groups", "validation_groups"={"a"}, "method"="GET"}, | ||
* "post_validation_sequence"={"route_name"="post_validation_sequence", "validation_groups"="app.dummy_validation.group_generator", "method"="GET"} | ||
* } | ||
* ) | ||
*/ | ||
class DummyValidation extends Model | ||
{ | ||
public $timestamps = false; | ||
|
||
protected $apiProperties = [ | ||
'name', | ||
'title', | ||
'code', | ||
]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,137 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the API Platform project. | ||
* | ||
* (c) Kévin Dunglas <dunglas@gmail.com> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace ApiPlatform\Core\Tests\Fixtures\TestBundle\Resource; | ||
|
||
use ApiPlatform\Core\Annotation\ApiProperty; | ||
use ApiPlatform\Core\Annotation\ApiResource; | ||
use ApiPlatform\Core\Tests\Fixtures\TestBundle\Models\DummyValidation as DummyValidationModel; | ||
use Symfony\Component\Validator\Constraints as Assert; | ||
|
||
/** | ||
* @ApiResource( | ||
* dataModel=DummyValidationModel::class, | ||
* collectionOperations={ | ||
* "get"={"method"="GET"}, | ||
* "post"={"path"="dummy_validation.{_format}", "method"="POST"}, | ||
* "post_validation_groups"={"route_name"="post_validation_groups", "validation_groups"={"a"}, "method"="GET"}, | ||
* "post_validation_sequence"={"route_name"="post_validation_sequence", "validation_groups"="app.dummy_validation.group_generator", "method"="GET"} | ||
* } | ||
* ) | ||
*/ | ||
class DummyValidation | ||
{ | ||
/** | ||
* @var int The id | ||
* | ||
* @ApiProperty(identifier=true) | ||
*/ | ||
private $id; | ||
|
||
/** | ||
* @var string|null The dummy name | ||
* | ||
* @Assert\NotNull(groups={"a"}) | ||
*/ | ||
private $name; | ||
|
||
/** | ||
* @var string|null The dummy title | ||
* | ||
* @Assert\NotNull(groups={"b"}) | ||
*/ | ||
private $title; | ||
|
||
/** | ||
* @var string The dummy code | ||
*/ | ||
private $code; | ||
|
||
/** | ||
* @return int | ||
*/ | ||
public function getId() | ||
{ | ||
return $this->id; | ||
} | ||
|
||
/** | ||
* @return DummyValidation | ||
*/ | ||
public function setId(int $id) | ||
{ | ||
$this->id = $id; | ||
|
||
return $this; | ||
} | ||
|
||
/** | ||
* @return string|null | ||
*/ | ||
public function getName() | ||
{ | ||
return $this->name; | ||
} | ||
|
||
/** | ||
* @param string|null $name | ||
* | ||
* @return DummyValidation | ||
*/ | ||
public function setName($name) | ||
{ | ||
$this->name = $name; | ||
|
||
return $this; | ||
} | ||
|
||
/** | ||
* @return string|null | ||
*/ | ||
public function getTitle() | ||
{ | ||
return $this->title; | ||
} | ||
|
||
/** | ||
* @param string|null $title | ||
* | ||
* @return DummyValidation | ||
*/ | ||
public function setTitle($title) | ||
{ | ||
$this->title = $title; | ||
|
||
return $this; | ||
} | ||
|
||
/** | ||
* @return string | ||
*/ | ||
public function getCode() | ||
{ | ||
return $this->code; | ||
} | ||
|
||
/** | ||
* @param string $code | ||
* | ||
* @return DummyValidation | ||
*/ | ||
public function setCode($code) | ||
{ | ||
$this->code = $code; | ||
|
||
return $this; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,6 @@ | ||
_main: | ||
resource: routing.yml | ||
|
||
controller: | ||
resource: '@TestBundle/Controller/EloquentMapped' | ||
type: annotation |
34 changes: 34 additions & 0 deletions
34
tests/Fixtures/app/migrations/2021_01_24_121212_create_dummy_validation_table.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the API Platform project. | ||
* | ||
* (c) Kévin Dunglas <dunglas@gmail.com> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
use Illuminate\Database\Migrations\Migration; | ||
use Illuminate\Database\Schema\Blueprint; | ||
use WouterJ\EloquentBundle\Facade\Schema; | ||
|
||
class CreateDummyValidationTable extends Migration | ||
{ | ||
public function up(): void | ||
{ | ||
Schema::create('dummy_validations', function (Blueprint $table) { | ||
$table->id(); | ||
$table->string('name')->nullable(true); | ||
$table->string('title')->nullable(true); | ||
$table->string('code'); | ||
}); | ||
} | ||
|
||
public function down(): void | ||
{ | ||
Schema::drop('dummy_validations'); | ||
} | ||
} |