Skip to content

Commit 89f0992

Browse files
authored
Merge branch 'master' into feature/symfony3-compatibilty
2 parents 2168e31 + 95e3bdb commit 89f0992

8 files changed

Lines changed: 169 additions & 1 deletion

File tree

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
/vendor/*
2+
/composer.lock

.gitmodules

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[submodule "victoire-test-suite"]
2+
path = victoire-test-suite
3+
url = git@github.com:Victoire/test-suite.git

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
[![CircleCI](https://circleci.com/gh/Victoire/WidgetButtonBundle.svg?style=shield)](https://circleci.com/gh/Victoire/WidgetButtonBundle)
2+
13
Victoire Button Bundle
24
============
35

Tests/Context/WidgetContext.php

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
<?php
2+
3+
namespace Victoire\Widget\ButtonBundle\Tests\Context;
4+
5+
use Knp\FriendlyContexts\Context\RawMinkContext;
6+
7+
class WidgetContext extends RawMinkContext
8+
{
9+
/**
10+
* @Then /^I should see a button "(.+)" with class "(.+)"$/
11+
*/
12+
public function iShouldSeeButtonWithClass($text, $class)
13+
{
14+
$page = $this->getSession()->getPage();
15+
16+
$button = $page->find('xpath', sprintf(
17+
'descendant-or-self::a[contains(@class, "%s") and contains(normalize-space(.), "%s")]',
18+
$class,
19+
$text
20+
));
21+
if (null === $button) {
22+
$message = sprintf(
23+
'Button with text "%s" and class "%s" not found.',
24+
$text,
25+
$class
26+
);
27+
throw new \Behat\Mink\Exception\ResponseTextException($message, $this->getSession());
28+
}
29+
}
30+
31+
/**
32+
* @Then /^I should see a button "(.+)" with hover title "(.+)"$/
33+
*/
34+
public function iShouldSeeButtonWithHoverTitle($text, $hoverTitle)
35+
{
36+
$page = $this->getSession()->getPage();
37+
38+
$button = $page->find('xpath', sprintf(
39+
'descendant-or-self::a[contains(@title, "%s") and contains(normalize-space(.), "%s")]',
40+
$hoverTitle,
41+
$text
42+
));
43+
if (null === $button) {
44+
$message = sprintf(
45+
'Button with text "%s" and hover title "%s" not found.',
46+
$text,
47+
$hoverTitle
48+
);
49+
throw new \Behat\Mink\Exception\ResponseTextException($message, $this->getSession());
50+
}
51+
}
52+
53+
/**
54+
* @Then /^I should see a button "(.+)" with a "(.+)" icon$/
55+
*/
56+
public function iShouldSeeButtonWithIcon($text, $icon)
57+
{
58+
$page = $this->getSession()->getPage();
59+
60+
$button = $page->find('xpath', sprintf(
61+
'descendant-or-self::a[contains(normalize-space(.), "%s")]/i[contains(@class, "%s")]',
62+
$text,
63+
$icon
64+
));
65+
if (null === $button) {
66+
$message = sprintf(
67+
'Button with text "%s" and icon "%s" not found.',
68+
$text,
69+
$icon
70+
);
71+
throw new \Behat\Mink\Exception\ResponseTextException($message, $this->getSession());
72+
}
73+
}
74+
}

Tests/Features/manage.feature

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
@mink:selenium2 @alice(Page) @reset-schema
2+
Feature: Manage a Button widget
3+
4+
Background:
5+
Given I am on homepage
6+
7+
Scenario: I can create a new Button widget
8+
When I switch to "layout" mode
9+
Then I should see "New content"
10+
When I select "Button" from the "1" select of "main_content" slot
11+
Then I should see "Widget (Button)"
12+
And I should see "1" quantum
13+
When I fill in "_a_static_widget_button[title]" with "My Button Widget title"
14+
And I fill in "_a_static_widget_button[icon]" with "fa-calendar"
15+
And I fill in "_a_static_widget_button[hoverTitle]" with "My Button Widget hover"
16+
And I select "Large" from "_a_static_widget_button[size]"
17+
And I select "Warning" from "_a_static_widget_button[style]"
18+
And I submit the widget
19+
Then I should see the success message for Widget edit
20+
When I reload the page
21+
Then I should see "My Button Widget title"
22+
And I should see a button "My Button Widget title" with class "btn-lg"
23+
And I should see a button "My Button Widget title" with class "btn-warning"
24+
And I should see a button "My Button Widget title" with hover title "My Button Widget hover"
25+
And I should see a button "My Button Widget title" with a "fa-calendar" icon
26+
27+
Scenario: I can update a Button widget
28+
Given the following WidgetMap:
29+
| view | action | slot |
30+
| home | create | main_content |
31+
And the following WidgetButton:
32+
| widgetMap | title | icon | hoverTitle | size | style |
33+
| home | Button Widget to edit | fa-truck | Button Widget to edit hover | md | danger |
34+
When I reload the page
35+
Then I should see "Button Widget to edit"
36+
And I should see a button "Button Widget to edit" with class "btn-md"
37+
And I should see a button "Button Widget to edit" with class "btn-danger"
38+
And I should see a button "Button Widget to edit" with hover title "Button Widget to edit hover"
39+
And I should see a button "Button Widget to edit" with a "fa-truck" icon
40+
When I switch to "edit" mode
41+
And I edit the "Button" widget
42+
And I should see "1" quantum
43+
When I fill in "_a_static_widget_button[title]" with "Button Widget modified"
44+
And I fill in "_a_static_widget_button[icon]" with "fa-pencil"
45+
And I fill in "_a_static_widget_button[hoverTitle]" with "Button Widget modified hover"
46+
And I select "Tiny" from "_a_static_widget_button[size]"
47+
And I select "Success" from "_a_static_widget_button[style]"
48+
And I submit the widget
49+
Then I should see the success message for Widget edit
50+
When I reload the page
51+
Then I should see "Button Widget modified"
52+
And I should see a button "Button Widget modified" with class "btn-sm"
53+
And I should see a button "Button Widget modified" with class "btn-success"
54+
And I should see a button "Button Widget modified" with hover title "Button Widget modified hover"
55+
And I should see a button "Button Widget modified" with a "fa-pencil" icon

circle.yml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
machine:
2+
timezone:
3+
Europe/Paris
4+
hosts:
5+
fr.victoire.io: 127.0.0.1
6+
en.victoire.io: 127.0.0.1
7+
services:
8+
- redis
9+
php:
10+
version: 7.1.0
11+
12+
checkout:
13+
post:
14+
- git submodule sync
15+
- git submodule update --init
16+
17+
dependencies:
18+
override:
19+
- bash victoire-test-suite/dependencies.sh victoire/button-widget
20+
cache_directories:
21+
- ~/.composer/cache
22+
23+
test:
24+
override:
25+
- bash victoire-test-suite/circle.sh victoire/button-widget:
26+
parallel: true
27+
- bash victoire-test-suite/test.sh victoire/button-widget
28+
29+
general:
30+
artifacts:
31+
- "fails"

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
}
1616
],
1717
"require": {
18-
"victoire/victoire": "~2.3"
18+
"victoire/victoire": "~2.3 | ~3.0"
1919
},
2020
"autoload": {
2121
"psr-0": {

victoire-test-suite

Submodule victoire-test-suite added at 7d601a3

0 commit comments

Comments
 (0)