-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #200 from loic425/features/admin-dashboard
Admin dashboard with initial content
- Loading branch information
Showing
30 changed files
with
514 additions
and
19 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,3 +3,4 @@ sylius_customer: | |
customer: | ||
classes: | ||
model: App\Entity\Customer | ||
repository: App\Repository\CustomerRepository |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
sylius_backend_partial_customer: | ||
resource: partial/customer.yaml | ||
prefix: /customers |
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,10 @@ | ||
sylius_backend_partial_customer_latest: | ||
path: /latest/{count} | ||
methods: [GET] | ||
defaults: | ||
_controller: sylius.controller.customer::indexAction | ||
_sylius: | ||
repository: | ||
method: findLatest | ||
arguments: ['!!int $count'] | ||
template: $template |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
@admin_dashboard | ||
Feature: Statistics dashboard | ||
In order to have an overview of my database | ||
As an Administrator | ||
I want to see overall statistics on my admin dashboard | ||
|
||
Background: | ||
Given I am logged in as an administrator | ||
|
||
@ui | ||
Scenario: Seeing statistics | ||
Given there are 9 customers | ||
When I open administration dashboard | ||
Then I should see 9 new customers | ||
|
||
@ui | ||
Scenario: Seeing recent customers | ||
Given there are 4 customers | ||
When I open administration dashboard | ||
Then I should see 4 new customers in the list |
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 |
---|---|---|
|
@@ -7,6 +7,7 @@ | |
"excludes": [ | ||
"Behat", | ||
"Command", | ||
"Controller", | ||
"DependencyInjection", | ||
"Formatter", | ||
"Menu", | ||
|
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,31 @@ | ||
<?php | ||
|
||
namespace spec\App\Dashboard; | ||
|
||
use App\Dashboard\DashboardStatistics; | ||
use App\Dashboard\DashboardStatisticsProvider; | ||
use App\Repository\CustomerRepository; | ||
use PhpSpec\ObjectBehavior; | ||
|
||
class DashboardStatisticsProviderSpec extends ObjectBehavior | ||
{ | ||
function let(CustomerRepository $customerRepository): void | ||
{ | ||
$this->beConstructedWith($customerRepository); | ||
} | ||
|
||
function it_is_initializable() | ||
{ | ||
$this->shouldHaveType(DashboardStatisticsProvider::class); | ||
} | ||
|
||
function it_obtains_statistics( | ||
CustomerRepository $customerRepository | ||
): void { | ||
$expectedStats = new DashboardStatistics(6); | ||
|
||
$customerRepository->countCustomers()->willReturn(6); | ||
|
||
$this->getStatistics()->shouldBeLike($expectedStats); | ||
} | ||
} |
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,25 @@ | ||
<?php | ||
|
||
namespace spec\App\Dashboard; | ||
|
||
use App\Dashboard\DashboardStatistics; | ||
use PhpSpec\ObjectBehavior; | ||
use Prophecy\Argument; | ||
|
||
class DashboardStatisticsSpec extends ObjectBehavior | ||
{ | ||
function let(): void | ||
{ | ||
$this->beConstructedWith(10); | ||
} | ||
|
||
function it_is_initializable() | ||
{ | ||
$this->shouldHaveType(DashboardStatistics::class); | ||
} | ||
|
||
function it_has_new_customers_stat(): void | ||
{ | ||
$this->getNumberOfNewCustomers()->shouldReturn(10); | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of monofony. | ||
* | ||
* (c) Mobizel | ||
* | ||
* 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\Ui\Backend; | ||
|
||
use App\Behat\Page\Backend\DashboardPage; | ||
use Behat\Behat\Context\Context; | ||
use Webmozart\Assert\Assert; | ||
|
||
class DashboardContext implements Context | ||
{ | ||
/** @var DashboardPage */ | ||
private $dashboardPage; | ||
|
||
public function __construct(DashboardPage $dashboardPage) | ||
{ | ||
$this->dashboardPage = $dashboardPage; | ||
} | ||
|
||
/** | ||
* @When I open administration dashboard | ||
*/ | ||
public function iOpenAdministrationDashboard() | ||
{ | ||
$this->dashboardPage->open(); | ||
} | ||
|
||
/** | ||
* @Then I should see :number new customers in the list | ||
*/ | ||
public function iShouldSeeNewCustomersInTheList($number) | ||
{ | ||
Assert::same($this->dashboardPage->getNumberOfNewCustomersInTheList(), (int) $number); | ||
} | ||
|
||
/** | ||
* @Then I should see :number new customers | ||
*/ | ||
public function iShouldSeeNewCustomers($number) | ||
{ | ||
Assert::same($this->dashboardPage->getNumberOfNewCustomers(), (int) $number); | ||
} | ||
} |
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 monofony. | ||
* | ||
* (c) Mobizel | ||
* | ||
* 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\Page\Backend; | ||
|
||
use App\Behat\Service\Accessor\TableAccessorInterface; | ||
use Behat\Mink\Session; | ||
use FriendsOfBehat\PageObjectExtension\Page\SymfonyPage; | ||
use Symfony\Component\Routing\RouterInterface; | ||
|
||
class DashboardPage extends SymfonyPage | ||
{ | ||
/** @var TableAccessorInterface */ | ||
private $tableAccessor; | ||
|
||
public function __construct( | ||
Session $session, | ||
$minkParameters, | ||
RouterInterface $router, | ||
TableAccessorInterface $tableAccessor | ||
) { | ||
parent::__construct($session, $minkParameters, $router); | ||
|
||
$this->tableAccessor = $tableAccessor; | ||
} | ||
|
||
public function getRouteName(): string | ||
{ | ||
return 'app_backend_dashboard'; | ||
} | ||
|
||
public function getNumberOfNewCustomersInTheList(): int | ||
{ | ||
return $this->tableAccessor->countTableBodyRows($this->getElement('customer_list')); | ||
} | ||
|
||
public function getNumberOfNewCustomers(): int | ||
{ | ||
return (int) $this->getElement('new_customers')->getText(); | ||
} | ||
|
||
protected function getDefinedElements(): array | ||
{ | ||
return array_merge(parent::getDefinedElements(), [ | ||
'customer_list' => '#customers', | ||
'new_customers' => '#new-customers', | ||
]); | ||
} | ||
} |
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
5 changes: 5 additions & 0 deletions
5
src/Behat/Resources/config/services/pages/backend/dashboard.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,5 @@ | ||
services: | ||
App\Behat\Page\Backend\DashboardPage: | ||
parent: app.behat.symfony_page | ||
public: false | ||
autowire: true |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
default: | ||
suites: | ||
ui_dashboard: | ||
contexts: | ||
- App\Behat\Context\Hook\DoctrineORMContext | ||
|
||
- App\Behat\Context\Setup\CustomerContext | ||
- App\Behat\Context\Setup\AdminSecurityContext | ||
|
||
- App\Behat\Context\Ui\Backend\DashboardContext | ||
filters: | ||
tags: "@admin_dashboard && @ui" |
Oops, something went wrong.