Skip to content
This repository has been archived by the owner on Nov 16, 2020. It is now read-only.

Commit

Permalink
Merge a762b6c into 26e06e7
Browse files Browse the repository at this point in the history
  • Loading branch information
kunicmarko20 committed Feb 2, 2019
2 parents 26e06e7 + a762b6c commit 8fc15ef
Show file tree
Hide file tree
Showing 28 changed files with 468 additions and 8 deletions.
8 changes: 4 additions & 4 deletions .travis.yml
Expand Up @@ -3,6 +3,7 @@ language: php
php:
- '7.1'
- '7.2'
- '7.3'
- nightly

env:
Expand All @@ -12,16 +13,15 @@ env:
matrix:
fast_finish: true
include:
- php: '7.1'
env: SYMFONY=3.4.*
- php: '7.1'
env: SYMFONY=4.0.*
- php: '7.2'
env: TARGET=behat

allow_failures:
- php: nightly

install:
- if [ -x .travis/install_${TARGET}.sh ]; then .travis/install_${TARGET}.sh; fi;
- composer install

script:
- if [ -x .travis/script_${TARGET}.sh ]; then .travis/script_${TARGET}.sh; fi;
Expand Down
4 changes: 1 addition & 3 deletions .travis/install_test.sh
@@ -1,4 +1,5 @@
#!/usr/bin/env sh

set -ev

mkdir --parents "${HOME}/bin"
Expand All @@ -10,6 +11,3 @@ chmod u+x "${HOME}/bin/phpunit"
# Coveralls client install
wget https://github.com/satooshi/php-coveralls/releases/download/v1.0.1/coveralls.phar --output-document="${HOME}/bin/coveralls"
chmod u+x "${HOME}/bin/coveralls"

if [ "$SYMFONY" != "" ]; then composer require "symfony/symfony:$SYMFONY" --no-update; fi;
composer install --dev --prefer-dist
8 changes: 8 additions & 0 deletions .travis/script_behat.sh
@@ -0,0 +1,8 @@
#!/usr/bin/env sh
set -ev

features/Fixtures/Project/bin/console --no-interaction cache:clear --env=test
features/Fixtures/Project/bin/console doctrine:schema:update --force --env=test
features/Fixtures/Project/bin/console assets:install
nohup php -S 127.0.0.1:8000 -t features/Fixtures/Project/public 2>&1 &
vendor/bin/behat
19 changes: 19 additions & 0 deletions behat.yml
@@ -0,0 +1,19 @@
default:
suites:
default:
contexts:
- KunicMarko\SonataAutoConfigureBundle\Features\Context\AdminContext:
entityManager: '@doctrine.orm.entity_manager'

extensions:
Behat\MinkExtension:
base_url: 'http://127.0.0.1:8000/'
goutte: ~
selenium2: ~
Behat\Symfony2Extension:
kernel:
env: test
debug: true
path: features/Fixtures/Project/src/Kernel.php
class: KunicMarko\SonataAutoConfigureBundle\Features\Fixtures\Project\Kernel
bootstrap: tests/bootstrap.php
13 changes: 12 additions & 1 deletion composer.json
Expand Up @@ -27,7 +27,16 @@
"symfony/http-kernel": "^3.4 || ^4.0 || ^4.1"
},
"require-dev": {
"behat/behat": "^3.5",
"behat/mink": "1.7.x-dev",
"behat/mink-browserkit-driver": "^1.3",
"behat/mink-extension": "^2.3",
"behat/mink-goutte-driver": "^1.2",
"behat/mink-selenium2-driver": "^1.3",
"behat/symfony2-extension": "^2.1",
"doctrine/doctrine-fixtures-bundle": "^3.0",
"matthiasnoback/symfony-dependency-injection-test": "^3.0",
"sonata-project/doctrine-orm-admin-bundle": "^3.6",
"symfony/phpunit-bridge": "^4.0"
},
"config": {
Expand All @@ -45,7 +54,9 @@
},
"autoload-dev": {
"psr-4": {
"KunicMarko\\SonataAutoConfigureBundle\\Tests\\": "tests/"
"KunicMarko\\SonataAutoConfigureBundle\\Tests\\": "tests/",
"KunicMarko\\SonataAutoConfigureBundle\\Features\\Fixtures\\Project\\": "features/Fixtures/Project/src",
"KunicMarko\\SonataAutoConfigureBundle\\Features\\": "features/"
}
}
}
67 changes: 67 additions & 0 deletions features/Context/AdminContext.php
@@ -0,0 +1,67 @@
<?php

namespace KunicMarko\SonataAutoConfigureBundle\Features\Context;

use Behat\MinkExtension\Context\MinkContext;
use Doctrine\Common\DataFixtures\Executor\ORMExecutor;
use Doctrine\Common\DataFixtures\Purger\ORMPurger;
use Doctrine\ORM\EntityManagerInterface;
use Behat\Symfony2Extension\Context\KernelDictionary;
use KunicMarko\SonataAutoConfigureBundle\Features\Fixtures\CategoryFixtures;
use Doctrine\Common\DataFixtures\Loader;

class AdminContext extends MinkContext
{
use KernelDictionary;

/**
* @var EntityManagerInterface
*/
private $entityManager;

public function __construct(EntityManagerInterface $entityManager)
{
$this->entityManager = $entityManager;
}

/**
* @BeforeScenario
*/
public function clearData(): void
{
$this->getPurger()->purge();
}

private function getPurger(): ORMPurger
{
return new ORMPurger($this->entityManager);
}

/**
* @Given I am on the dashboard
*/
public function iAmOnTheDashboard(): void
{
$this->visitPath('/admin/dashboard');
}

/**
* @Given I have items in the database
*/
public function iHaveItemsInTheDatabase(): void
{
$loader = new Loader();
$loader->addFixture(new CategoryFixtures());

$executor = new ORMExecutor($this->entityManager, $this->getPurger());
$executor->execute($loader->getFixtures());
}

/**
* @Then I should see :button button
*/
public function iShouldSeeAButton(string $button): void
{
$this->getSession()->getPage()->find('xpath', "//a[contains(text(), $button)]");
}
}
18 changes: 18 additions & 0 deletions features/Fixtures/CategoryFixtures.php
@@ -0,0 +1,18 @@
<?php

namespace KunicMarko\SonataAutoConfigureBundle\Features\Fixtures;

use KunicMarko\SonataAutoConfigureBundle\Features\Fixtures\Project\Entity\Category;
use Doctrine\Bundle\FixturesBundle\Fixture;
use Doctrine\Common\Persistence\ObjectManager;

class CategoryFixtures extends Fixture
{
public function load(ObjectManager $manager)
{
$category = new Category('Dummy Category');

$manager->persist($category);
$manager->flush();
}
}
10 changes: 10 additions & 0 deletions features/Fixtures/Project/.gitignore
@@ -0,0 +1,10 @@
###> symfony/framework-bundle ###
/.env
/public/bundles/
/var/
/vendor/
###< symfony/framework-bundle ###

###> symfony/web-server-bundle ###
/.web-server-pid
###< symfony/web-server-bundle ###
17 changes: 17 additions & 0 deletions features/Fixtures/Project/bin/console
@@ -0,0 +1,17 @@
#!/usr/bin/env php
<?php

use KunicMarko\SonataAutoConfigureBundle\Features\Fixtures\Project\Kernel;
use Symfony\Bundle\FrameworkBundle\Console\Application;
use Symfony\Component\Console\Input\ArgvInput;

set_time_limit(0);

require __DIR__.'../../../../../vendor/autoload.php';

umask(0000);

$input = new ArgvInput();
$kernel = new Kernel('test', true);
$application = new Application($kernel);
$application->run($input);
16 changes: 16 additions & 0 deletions features/Fixtures/Project/config/bundles.php
@@ -0,0 +1,16 @@
<?php

return [
Symfony\Bundle\FrameworkBundle\FrameworkBundle::class => ['all' => true],
Doctrine\Bundle\DoctrineCacheBundle\DoctrineCacheBundle::class => ['all' => true],
Doctrine\Bundle\DoctrineBundle\DoctrineBundle::class => ['all' => true],
Symfony\Bundle\SecurityBundle\SecurityBundle::class => ['all' => true],
Symfony\Bundle\TwigBundle\TwigBundle::class => ['all' => true],
Sonata\DatagridBundle\SonataDatagridBundle::class => ['all' => true],
Sonata\CoreBundle\SonataCoreBundle::class => ['all' => true],
Sonata\BlockBundle\SonataBlockBundle::class => ['all' => true],
Knp\Bundle\MenuBundle\KnpMenuBundle::class => ['all' => true],
Sonata\AdminBundle\SonataAdminBundle::class => ['all' => true],
Sonata\DoctrineORMAdminBundle\SonataDoctrineORMAdminBundle::class => ['all' => true],
KunicMarko\SonataAutoConfigureBundle\SonataAutoConfigureBundle::class => ['all' => true],
];
21 changes: 21 additions & 0 deletions features/Fixtures/Project/config/packages/doctrine.yaml
@@ -0,0 +1,21 @@
doctrine:
dbal:
driver: 'pdo_mysql'
server_version: '5.7'
charset: utf8mb4
default_table_options:
charset: utf8mb4
collate: utf8mb4_unicode_ci

url: 'sqlite:///%kernel.project_dir%/var/cache/app.db'
orm:
auto_generate_proxy_classes: '%kernel.debug%'
naming_strategy: doctrine.orm.naming_strategy.underscore
auto_mapping: true
mappings:
SonataAutoConfigureBundle:
is_bundle: false
type: annotation
dir: '%kernel.project_dir%/src/Entity'
prefix: 'KunicMarko\SonataAutoConfigureBundle\Features\Fixtures\Project\Entity'
alias: SonataAutoConfigureBundle
7 changes: 7 additions & 0 deletions features/Fixtures/Project/config/packages/framework.yaml
@@ -0,0 +1,7 @@
framework:
secret: '%env(APP_SECRET)%'
test: true
session:
storage_id: session.storage.mock_file
php_errors:
log: true
3 changes: 3 additions & 0 deletions features/Fixtures/Project/config/packages/routing.yaml
@@ -0,0 +1,3 @@
framework:
router:
strict_requirements: ~
9 changes: 9 additions & 0 deletions features/Fixtures/Project/config/packages/security.yaml
@@ -0,0 +1,9 @@
security:
providers:
in_memory: {memory: ~}
firewalls:
dev:
pattern: ^/(_(profiler|wdt)|css|images|js)/
security: false
main:
anonymous: true
10 changes: 10 additions & 0 deletions features/Fixtures/Project/config/packages/sonata_admin.yaml
@@ -0,0 +1,10 @@
sonata_admin:
title: 'Sonata Admin'
dashboard:
blocks:
- {type: sonata.admin.block.admin_list, position: left}

sonata_block:
blocks:
sonata.admin.block.admin_list:
contexts: [admin]
@@ -0,0 +1,4 @@
sonata_auto_configure:
entity:
namespaces:
- {namespace: KunicMarko\SonataAutoConfigureBundle\Features\Fixtures\Project\Entity, manager_type: orm}
4 changes: 4 additions & 0 deletions features/Fixtures/Project/config/packages/sonata_core.yaml
@@ -0,0 +1,4 @@
sonata_core:
form:
mapping:
enabled: false
3 changes: 3 additions & 0 deletions features/Fixtures/Project/config/packages/twig.yaml
@@ -0,0 +1,3 @@
twig:
debug: '%kernel.debug%'
strict_variables: '%kernel.debug%'
8 changes: 8 additions & 0 deletions features/Fixtures/Project/config/routes.yaml
@@ -0,0 +1,8 @@
admin_area:
resource: "@SonataAdminBundle/Resources/config/routing/sonata_admin.xml"
prefix: /admin

_sonata_admin:
resource: .
type: sonata_admin
prefix: /admin
12 changes: 12 additions & 0 deletions features/Fixtures/Project/config/services.yaml
@@ -0,0 +1,12 @@
parameters:
locale: 'en'

services:
_defaults:
autowire: true
autoconfigure: true
public: false

KunicMarko\SonataAutoConfigureBundle\Features\Fixtures\Project\:
resource: '../src/*'
exclude: '../src/{Entity,Kernel.php}'
14 changes: 14 additions & 0 deletions features/Fixtures/Project/public/index.php
@@ -0,0 +1,14 @@
<?php

use KunicMarko\SonataAutoConfigureBundle\Features\Fixtures\Project\Kernel;
use Symfony\Component\HttpFoundation\Request;

require __DIR__.'/../../../../vendor/autoload.php';

umask(0000);

$kernel = new Kernel('test', true);
$request = Request::createFromGlobals();
$response = $kernel->handle($request);
$response->send();
$kernel->terminate($request, $response);
35 changes: 35 additions & 0 deletions features/Fixtures/Project/src/Admin/CategoryAdmin.php
@@ -0,0 +1,35 @@
<?php

declare(strict_types=1);

namespace KunicMarko\SonataAutoConfigureBundle\Features\Fixtures\Project\Admin;

use Sonata\AdminBundle\Admin\AbstractAdmin;
use Sonata\AdminBundle\Datagrid\DatagridMapper;
use Sonata\AdminBundle\Datagrid\ListMapper;
use Sonata\AdminBundle\Form\FormMapper;

final class CategoryAdmin extends AbstractAdmin
{
protected function configureDatagridFilters(DatagridMapper $datagridMapper)
{
$datagridMapper->add('name');
}

protected function configureListFields(ListMapper $listMapper)
{
$listMapper
->addIdentifier('name')
->add('_action', 'actions', [
'actions' => [
'edit' => [],
'delete' => [],
]
]);
}

protected function configureFormFields(FormMapper $formMapper)
{
$formMapper->add('name');
}
}

0 comments on commit 8fc15ef

Please sign in to comment.