-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[BootstrapAdminUi] Add functional tests & fix requirements (#61)
- Loading branch information
Showing
17 changed files
with
352 additions
and
9 deletions.
There are no files selected for viewing
File renamed without changes.
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
50 changes: 50 additions & 0 deletions
50
src/BootstrapAdminUi/tests/Functional/.application/config/packages/doctrine.yaml
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,50 @@ | ||
doctrine: | ||
dbal: | ||
url: '%env(resolve:DATABASE_URL)%' | ||
|
||
# IMPORTANT: You MUST configure your server version, | ||
# either here or in the DATABASE_URL env var (see .env file) | ||
#server_version: '16' | ||
|
||
profiling_collect_backtrace: '%kernel.debug%' | ||
use_savepoints: true | ||
orm: | ||
auto_generate_proxy_classes: true | ||
enable_lazy_ghost_objects: true | ||
report_fields_where_declared: true | ||
validate_xml_mapping: true | ||
naming_strategy: doctrine.orm.naming_strategy.underscore_number_aware | ||
auto_mapping: true | ||
mappings: | ||
App: | ||
type: attribute | ||
is_bundle: false | ||
dir: '%kernel.project_dir%/src/Entity' | ||
prefix: 'App\Entity' | ||
alias: App | ||
|
||
when@test: | ||
doctrine: | ||
dbal: | ||
# "TEST_TOKEN" is typically set by ParaTest | ||
dbname_suffix: '_test%env(default::TEST_TOKEN)%' | ||
|
||
when@prod: | ||
doctrine: | ||
orm: | ||
auto_generate_proxy_classes: false | ||
proxy_dir: '%kernel.build_dir%/doctrine/orm/Proxies' | ||
query_cache_driver: | ||
type: pool | ||
pool: doctrine.system_cache_pool | ||
result_cache_driver: | ||
type: pool | ||
pool: doctrine.result_cache_pool | ||
|
||
framework: | ||
cache: | ||
pools: | ||
doctrine.result_cache_pool: | ||
adapter: cache.app | ||
doctrine.system_cache_pool: | ||
adapter: cache.system |
2 changes: 2 additions & 0 deletions
2
...strapAdminUi/tests/Functional/.application/config/packages/sylius_bootstrap_admin_ui.yaml
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,2 @@ | ||
imports: | ||
- { resource: '../../../../../config/app.php' } |
17 changes: 17 additions & 0 deletions
17
src/BootstrapAdminUi/tests/Functional/.application/config/packages/sylius_resource.yaml
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,17 @@ | ||
# @see https://github.com/Sylius/SyliusResourceBundle/blob/master/docs/index.md | ||
sylius_resource: | ||
drivers: [] | ||
|
||
# Override default settings | ||
#settings: | ||
|
||
# Configure the mapping for your resources | ||
mapping: | ||
paths: | ||
- '%kernel.project_dir%/src/Resource' | ||
|
||
# Configure your resources | ||
resources: | ||
#app.book: | ||
#classes: | ||
#model: App\Entity\Book |
7 changes: 7 additions & 0 deletions
7
src/BootstrapAdminUi/tests/Functional/.application/config/routes/sylius_resource.yaml
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,7 @@ | ||
sylius_crud_routes: | ||
resource: 'sylius.routing.loader.crud_routes_attributes' | ||
type: service | ||
|
||
sylius_routes: | ||
resource: 'sylius.routing.loader.routes_attributes' | ||
type: service |
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
Empty file.
36 changes: 36 additions & 0 deletions
36
src/BootstrapAdminUi/tests/Functional/.application/src/Form/BookResourceType.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,36 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the Sylius package. | ||
* | ||
* (c) Sylius Sp. z o.o. | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace TestApplication\Sylius\BootstrapAdminUi\Form; | ||
|
||
use Symfony\Component\Form\AbstractType; | ||
use Symfony\Component\Form\FormBuilderInterface; | ||
use Symfony\Component\OptionsResolver\OptionsResolver; | ||
use TestApplication\Sylius\BootstrapAdminUi\Resource\BookResource; | ||
|
||
final class BookResourceType extends AbstractType | ||
{ | ||
public function buildForm(FormBuilderInterface $builder, array $options): void | ||
{ | ||
$builder | ||
->add('name') | ||
; | ||
} | ||
|
||
public function configureOptions(OptionsResolver $resolver): void | ||
{ | ||
$resolver->setDefaults([ | ||
'data_class' => BookResource::class, | ||
]); | ||
} | ||
} |
59 changes: 59 additions & 0 deletions
59
src/BootstrapAdminUi/tests/Functional/.application/src/Grid/BookGrid.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,59 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the Sylius package. | ||
* | ||
* (c) Sylius Sp. z o.o. | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace TestApplication\Sylius\BootstrapAdminUi\Grid; | ||
|
||
use Sylius\Bundle\GridBundle\Builder\Action\CreateAction; | ||
use Sylius\Bundle\GridBundle\Builder\Action\UpdateAction; | ||
use Sylius\Bundle\GridBundle\Builder\ActionGroup\ItemActionGroup; | ||
use Sylius\Bundle\GridBundle\Builder\ActionGroup\MainActionGroup; | ||
use Sylius\Bundle\GridBundle\Builder\Field\StringField; | ||
use Sylius\Bundle\GridBundle\Builder\GridBuilderInterface; | ||
use Sylius\Bundle\GridBundle\Grid\AbstractGrid; | ||
use Sylius\Bundle\GridBundle\Grid\ResourceAwareGridInterface; | ||
use TestApplication\Sylius\BootstrapAdminUi\Grid\Provider\BookGridProvider; | ||
use TestApplication\Sylius\BootstrapAdminUi\Resource\BookResource; | ||
|
||
final class BookGrid extends AbstractGrid implements ResourceAwareGridInterface | ||
{ | ||
public static function getName(): string | ||
{ | ||
return 'app_book'; | ||
} | ||
|
||
public function buildGrid(GridBuilderInterface $gridBuilder): void | ||
{ | ||
$gridBuilder | ||
->setProvider(BookGridProvider::class) | ||
->addField( | ||
StringField::create('name') | ||
->setLabel('Name'), | ||
) | ||
->addActionGroup( | ||
MainActionGroup::create( | ||
CreateAction::create(), | ||
), | ||
) | ||
->addActionGroup( | ||
ItemActionGroup::create( | ||
UpdateAction::create(), | ||
), | ||
) | ||
; | ||
} | ||
|
||
public function getResourceClass(): string | ||
{ | ||
return BookResource::class; | ||
} | ||
} |
32 changes: 32 additions & 0 deletions
32
src/BootstrapAdminUi/tests/Functional/.application/src/Grid/Provider/BookGridProvider.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,32 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the Sylius package. | ||
* | ||
* (c) Sylius Sp. z o.o. | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace TestApplication\Sylius\BootstrapAdminUi\Grid\Provider; | ||
|
||
use Pagerfanta\Adapter\ArrayAdapter; | ||
use Pagerfanta\Pagerfanta; | ||
use Sylius\Component\Grid\Data\DataProviderInterface; | ||
use Sylius\Component\Grid\Definition\Grid; | ||
use Sylius\Component\Grid\Parameters; | ||
use TestApplication\Sylius\BootstrapAdminUi\Resource\BookResource; | ||
|
||
class BookGridProvider implements DataProviderInterface | ||
{ | ||
public function getData(Grid $grid, Parameters $parameters): Pagerfanta | ||
{ | ||
return new Pagerfanta(new ArrayAdapter([ | ||
new BookResource('shinning', 'Shinning'), | ||
new BookResource('carrie', 'Carrie'), | ||
])); | ||
} | ||
} |
47 changes: 47 additions & 0 deletions
47
src/BootstrapAdminUi/tests/Functional/.application/src/Resource/BookResource.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,47 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the Sylius package. | ||
* | ||
* (c) Sylius Sp. z o.o. | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace TestApplication\Sylius\BootstrapAdminUi\Resource; | ||
|
||
use Sylius\Resource\Metadata\AsResource; | ||
use Sylius\Resource\Metadata\Create; | ||
use Sylius\Resource\Metadata\Index; | ||
use Sylius\Resource\Metadata\Update; | ||
use Sylius\Resource\Model\ResourceInterface; | ||
use TestApplication\Sylius\BootstrapAdminUi\Form\BookResourceType; | ||
use TestApplication\Sylius\BootstrapAdminUi\Grid\BookGrid; | ||
use TestApplication\Sylius\BootstrapAdminUi\State\Provider\BookItemProvider; | ||
|
||
#[AsResource( | ||
formType: BookResourceType::class, | ||
templatesDir: '@SyliusAdminUi/crud', | ||
driver: false, | ||
operations: [ | ||
new Index(grid: BookGrid::class), | ||
new Create(), | ||
new Update(provider: BookItemProvider::class), | ||
], | ||
)] | ||
final class BookResource implements ResourceInterface | ||
{ | ||
public function __construct( | ||
public ?string $id = null, | ||
public ?string $name = null, | ||
) { | ||
} | ||
|
||
public function getId(): ?string | ||
{ | ||
return $this->id; | ||
} | ||
} |
27 changes: 27 additions & 0 deletions
27
src/BootstrapAdminUi/tests/Functional/.application/src/State/Provider/BookItemProvider.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,27 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the Sylius package. | ||
* | ||
* (c) Sylius Sp. z o.o. | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace TestApplication\Sylius\BootstrapAdminUi\State\Provider; | ||
|
||
use Sylius\Resource\Context\Context; | ||
use Sylius\Resource\Metadata\Operation; | ||
use Sylius\Resource\State\ProviderInterface; | ||
use TestApplication\Sylius\BootstrapAdminUi\Resource\BookResource; | ||
|
||
class BookItemProvider implements ProviderInterface | ||
{ | ||
public function provide(Operation $operation, Context $context): BookResource | ||
{ | ||
return new BookResource('shinning', 'Shinning'); | ||
} | ||
} |
Oops, something went wrong.