Skip to content
This repository was archived by the owner on Mar 7, 2020. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
b0998e6
manage articles on backend
loic425 Dec 5, 2018
8c612b7
[Behat] browsing articles
loic425 Dec 5, 2018
45c0f12
adding a new article
loic425 Dec 5, 2018
24f6f6b
[Behat] Deleting an article
loic425 Dec 5, 2018
42f22f5
rename a method on managing articles context
loic425 Dec 5, 2018
5bff12e
fix behat article create page
loic425 Dec 14, 2018
0c3b9e7
renaming an article
loic425 Dec 17, 2018
18c97b4
Merge pull request #87 from loic425/example/managing-articles
loic425 Dec 17, 2018
8edf626
Trying to add a new article without title
loic425 Dec 17, 2018
673d056
Merge pull request #88 from loic425/article-validation
loic425 Dec 17, 2018
b996eed
Merge branch 'master' of github.com:Monofony/SymfonyStarter into exam…
loic425 Dec 17, 2018
b172ca8
Merge branch 'example/managing-articles' of github.com:Monofony/Symfo…
loic425 Dec 17, 2018
93026e3
Merge branch 'master' of github.com:Monofony/SymfonyStarter into exam…
loic425 Dec 18, 2018
6e23c89
Merge branch 'master' of github.com:Monofony/SymfonyStarter into exam…
loic425 Dec 18, 2018
db088f8
Merge branch 'master' of github.com:Monofony/SymfonyStarter into exam…
loic425 Dec 18, 2018
418d8a3
Merge branch 'master' of github.com:Monofony/SymfonyStarter into exam…
loic425 Dec 18, 2018
828ad38
Merge branch 'master' of github.com:Monofony/SymfonyStarter into exam…
loic425 Jan 5, 2019
7477a79
Remove multiple articles at once
loic425 Jan 5, 2019
a730819
Merge pull request #97 from loic425/features/remove-multiple-articles
loic425 Jan 7, 2019
648917e
fix conflicts with master branch
loic425 Jan 11, 2019
fd231ac
Merge branch 'master' of github.com:Monofony/SymfonyStarter into exam…
loic425 Jan 23, 2019
05f396d
fix after upgrading fob symfony extension
loic425 Jan 29, 2019
6664e81
fix managing articles suite
loic425 Jan 29, 2019
41cdb18
autowire article examples
loic425 Feb 13, 2019
18020c5
Merge pull request #106 from loic425/example/managing-articles
loic425 Feb 13, 2019
89c4039
improve autowiring
loic425 Feb 14, 2019
cc835c5
Merge pull request #113 from loic425/example/managing-articles
loic425 Feb 14, 2019
c0bdbc1
fix conflicts with base branch
loic425 Mar 7, 2019
e93c5a8
Merge pull request #134 from loic425/example/managing-articles
loic425 Mar 7, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions config/packages/grids/backend/article.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
sylius_grid:
grids:
app_backend_article:
driver:
name: doctrine/orm
options:
class: "%app.model.article.class%"
sorting:
title: asc
fields:
title:
type: string
label: sylius.ui.title
sortable: ~
filters:
search:
type: string
label: sylius.ui.search
options:
fields: [title]
actions:
main:
create:
type: create
item:
update:
type: update
delete:
type: delete
bulk:
delete:
type: delete
3 changes: 3 additions & 0 deletions config/packages/sylius_fixtures.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,6 @@ sylius_fixtures:
client:
random_id: 5rbhrb0iiukokcwk8gow0w4ocgww0oco8g8gsgokwc0wcssg4w
secret: 2rlxzhijcx448ow4c0gksw4wo8oo4k8kkwwg0osskk8g0k8kw8
article:
options:
random: 20
1 change: 1 addition & 0 deletions config/packages/sylius_grid.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
imports:
- { resource: 'grids/backend/article.yml' }
- { resource: 'grids/backend/admin_user.yml' }
- { resource: 'grids/backend/customer.yml' }

Expand Down
4 changes: 4 additions & 0 deletions config/packages/sylius_resource.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
sylius_resource:
resources:
app.article:
classes:
model: App\Entity\Article
form: App\Form\Type\ArticleType
app.oauth_client:
classes:
model: App\Entity\OAuth\Client
3 changes: 3 additions & 0 deletions config/routes/backend.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ app_backend_dashboard:
sylius_backend_admin_user:
resource: "backend/admin_user.yml"

app_backend_article:
resource: "backend/article.yml"

sylius_backend_customer:
resource: "backend/customer.yml"

Expand Down
15 changes: 15 additions & 0 deletions config/routes/backend/article.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
app_backend_article:
resource: |
alias: app.article
section: backend
except: ['show']
redirect: update
grid: app_backend_article
vars:
all:
subheader: app.ui.manage_articles
index:
icon: newspaper
templates: backend/crud
type: sylius.resource

4 changes: 4 additions & 0 deletions config/services/fixtures.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ services:
arguments:
$exampleFactory: '@App\Fixture\Factory\AppUserExampleFactory'

App\Fixture\ArticleFixture:
arguments:
$exampleFactory: '@App\Fixture\Factory\ArticleExampleFactory'

App\Fixture\OAuthClientFixture:
arguments:
$exampleFactory: '@App\Fixture\Factory\OAuthClientExampleFactory'
16 changes: 16 additions & 0 deletions features/article/managing_articles/adding_article.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
@managing_articles
Feature: Adding a new article
In order to extend articles database
As an Administrator
I want to add a new article

Background:
Given I am logged in as an administrator

@ui
Scenario: Adding a new article
Given I want to create a new article
When I specify its title as "Star Wars"
And I add it
Then I should be notified that it has been successfully created
And the article "Star Wars" should appear in the website
16 changes: 16 additions & 0 deletions features/article/managing_articles/article_validation.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
@managing_articles
Feature: Articles validation
In order to avoid making mistakes when managing articles
As an Administrator
I want to be prevented from adding it without specifying required fields

Background:
Given I am logged in as an administrator

@ui
Scenario: Trying to add a new article without title
Given I want to create a new article
When I do not specify its title
And I try to add it
Then I should be notified that the title is required
And this article should not be added
19 changes: 19 additions & 0 deletions features/article/managing_articles/browsing_articles.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
@managing_articles
Feature: Browsing articles
In order to manage articles in the website
As an Administrator
I want to browse articles

Background:
Given there is an article titled "Star Wars"
And there is also an article titled "Game Of Thrones"
And there is also an article titled "Back To The Future"
And I am logged in as an administrator

@ui
Scenario: Browsing articles in the website
When I want to browse articles
Then there should be 3 articles in the list
And I should see the article "Star Wars" in the list
And I should see the article "Game Of Thrones" in the list
And I should see the article "Back To The Future" in the list
16 changes: 16 additions & 0 deletions features/article/managing_articles/deleting_articles.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
@managing_articles
Feature: Deleting an article
In order to get rid of deprecated articles
As an Administrator
I want to be able to delete articles

Background:
Given there is an article titled "Star Wars"
And I am logged in as an administrator

@ui
Scenario: Deleting an article
Given I want to browse articles
When I delete article with title "Star Wars"
Then I should be notified that it has been successfully deleted
And there should not be "Star Wars" article anymore
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
@managing_articles
Feature: Deleting multiple articles
In order to get rid of spam articles in an efficient way
As an Administrator
I want to be able to delete multiple articles at once

Background:
Given there is an article titled "Star Wars"
And there is also an article titled "Game Of Thrones"
And there is also an article titled "Back To The Future"
And I am logged in as an administrator

@ui @javascript
Scenario: Deleting multiple articles at once
Given I browse articles
And I check the "Star Wars" article
And I also check the "Game Of Thrones" article
And I delete them
Then I should be notified that they have been successfully deleted
And I should see a single article in the list
And I should see the article "Back To The Future" in the list
18 changes: 18 additions & 0 deletions features/article/managing_articles/editing_article.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
@managing_articles
Feature: Editing article
In order to change article details
As an Administrator
I want to be able to edit an article

Background:
Given there is an article titled "Star Wars"
And I am logged in as an administrator

@ui
Scenario: Renaming the article
Given I want to modify the "Star Wars" article
When I rename it to "Game Of Thrones"
And I save my changes
Then I should be notified that it has been successfully edited
And I should see the article "Game Of Thrones" in the list
But there should not be "Star Wars" article anymore
25 changes: 25 additions & 0 deletions spec/App/Entity/ArticleSpec.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?php

namespace spec\App\Entity;

use PhpSpec\ObjectBehavior;
use Sylius\Component\Resource\Model\ResourceInterface;

class ArticleSpec extends ObjectBehavior
{
function it_implements_resource_interface()
{
$this->shouldImplement(ResourceInterface::class);
}

function it_has_no_title_by_default()
{
$this->getTitle()->shouldReturn(null);
}

function its_title_is_mutable()
{
$this->setTitle('Awesome title');
$this->getTitle()->shouldReturn('Awesome title');
}
}
70 changes: 70 additions & 0 deletions src/Behat/Context/Setup/ArticleContext.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
<?php

/*
* This file is part of AppName.
*
* (c) Monofony
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace App\Behat\Context\Setup;

use App\Behat\Service\SharedStorageInterface;
use App\Entity\Article;
use App\Fixture\Factory\ArticleExampleFactory;
use Behat\Behat\Context\Context;
use Sylius\Component\Resource\Repository\RepositoryInterface;

class ArticleContext implements Context
{
/**
* @var SharedStorageInterface
*/
private $sharedStorage;

/**
* @var ArticleExampleFactory
*/
private $articleFactory;

/**
* @var RepositoryInterface
*/
private $articleRepository;

/**
* @param SharedStorageInterface $sharedStorage
* @param ArticleExampleFactory $articleFactory
* @param RepositoryInterface $articleRepository
*/
public function __construct(
SharedStorageInterface $sharedStorage,
ArticleExampleFactory $articleFactory,
RepositoryInterface $articleRepository
) {
$this->sharedStorage = $sharedStorage;
$this->articleFactory = $articleFactory;
$this->articleRepository = $articleRepository;
}

/**
* @Given there is (also )an article titled :title
*/
public function thereIsAnAdministratorIdentifiedBy(string $title): void
{
$this->createArticle(['title' => $title]);
}

/**
* @param array $options
*/
private function createArticle(array $options): void
{
/** @var Article $article */
$article = $this->articleFactory->create($options);
$this->articleRepository->add($article);
$this->sharedStorage->set('article', $article);
}
}
58 changes: 58 additions & 0 deletions src/Behat/Context/Transform/ArticleContext.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
<?php

/*
* This file is part of AppName.
*
* (c) Monofony
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

declare(strict_types=1);

namespace App\Behat\Context\Transform;

use App\Entity\Article;
use Behat\Behat\Context\Context;
use Sylius\Component\Resource\Repository\RepositoryInterface;
use Webmozart\Assert\Assert;

class ArticleContext implements Context
{
/**
* @var RepositoryInterface
*/
private $articleRepository;

/**
* ArticleContext constructor.
*
* @param RepositoryInterface $articleRepository
*/
public function __construct(RepositoryInterface $articleRepository)
{
$this->articleRepository = $articleRepository;
}

/**
* @Transform /^article "([^"]+)"$/
* @Transform :article
*
* @param string $title
*
* @return Article
*/
public function getArticleTitle($title)
{
/** @var Article $article */
$article = $this->articleRepository->findOneBy(['title' => $title]);

Assert::notNull(
$article,
sprintf('Article with title "%s" does not exist', $title)
);

return $article;
}
}
Loading