belongs to the TYPO3 Flow package "TYPO3.Neos". * * * * It is free software; you can redistribute it and/or modify it under * * the terms of the GNU General Public License, either version 3 of the * * License, or (at your option) any later version. * * * * The TYPO3 project - inspiring people to share! * * */ /** * Testcase for the Content Service * */ class DomainMatchingStrategyTest extends \TYPO3\Flow\Tests\UnitTestCase { /** * @test */ public function getSortedMatchesReturnsOneGivenDomainIfItMatchesExactly() { $mockDomains = array($this->getMock('TYPO3\Neos\Domain\Model\Domain', array(), array(), '', FALSE)); $mockDomains[0]->expects($this->any())->method('getHostPattern')->will($this->returnValue('www.typo3.org')) $expectedDomains = array($mockDomains[0]); $strategy = new \TYPO3\Neos\Domain\Service\DomainMatchingStrategy(); $actualDomains = $strategy->getSortedMatches('www.typo3.org', $mockDomains); $this->assertSame($expectedDomains, $actualDomains); } /** * @test */ public function getSortedMatchesFiltersTheGivenDomainsByTheSpecifiedHostAndReturnsThemSortedWithBestMatchesFirst( $mockDomains = array( $this->getMock('TYPO3\Neos\Domain\Model\Domain', array('dummy'), array(), '', FALSE), $this->getMock('TYPO3\Neos\Domain\Model\Domain', array('dummy'), array(), '', FALSE), $this->getMock('TYPO3\Neos\Domain\Model\Domain', array('dummy'), array(), '', FALSE), $this->getMock('TYPO3\Neos\Domain\Model\Domain', array('dummy'), array(), '', FALSE), ); $mockDomains[0]->setHostPattern('*.typo3.org'); $mockDomains[1]->setHostPattern('flow.typo3.org'); $mockDomains[2]->setHostPattern('*'); $mockDomains[3]->setHostPattern('yacumboolu.typo3.org'); $expectedDomains = array( $mockDomains[1], $mockDomains[0], $mockDomains[2] ); $strategy = new \TYPO3\Neos\Domain\Service\DomainMatchingStrategy(); $actualDomains = $strategy->getSortedMatches('flow.typo3.org', $mockDomains); $this->assertSame($expectedDomains, $actualDomains); } /** * @test */ public function getSortedMatchesReturnsNoMatchIfDomainIsLongerThanHostname() { $mockDomains = array( $this->getMock('TYPO3\Neos\Domain\Model\Domain', array('dummy'), array(), '', FALSE), ); $mockDomains[0]->setHostPattern('flow.typo3.org'); $expectedDomains = array(); $strategy = new \TYPO3\Neos\Domain\Service\DomainMatchingStrategy(); $actualDomains = $strategy->getSortedMatches('typo3.org', $mockDomains); $this->assertSame($expectedDomains, $actualDomains); } }
agile methodology. It describes a cycle of interactions with well- defined outputs, resulting in the delivery of working, tested software that matters. wikipedia.org
software As a listener of this talk I want to learn about BDD Scenario: Developer with TDD knowledge Given I already heard or used TDD And I am a developer When I watch the next slides And I listen carefully Then I should know what BDD is about And I should see how it can help me in my projects And I should be excited to see how I can apply it
software As a listener of this talk I want to learn about BDD Scenario: Developer with TDD knowledge Given I already heard or used TDD And I am a developer When I watch the next slides And I listen carefully Then I should know what BDD is about And I should see how it can help me in my projects And I should be excited to see how I can apply it Clear, explicit title Motivation and context
software As a listener of this talk I want to learn about BDD Scenario: Developer with TDD knowledge Given I already heard or used TDD And I am a developer When I watch the next slides And I listen carefully Then I should know what BDD is about And I should see how it can help me in my projects And I should be excited to see how I can apply it Steps Scenario title
software As a listener of this talk I want to learn about BDD Scenario: Developer with TDD knowledge Given I already heard or used TDD And I am a developer When I watch the next slides And I listen carefully Then I should know what BDD is about And I should see how it can help me in my projects And I should be excited to see how I can apply it Precondition Trigger Expected outcome
of items in my basket As a buyer in the roebooks store I need a detailed view of the basket Scenario: Empty basket Given I have an empty shopping basket When I go to the Basket page Then I should see "Your shopping basket is empty."
get an overview of items in my basket As a buyer in the roebooks store I need a detailed view of the basket Scenario: Empty basket # Features/Basket.feature:7 Given I have an empty shopping basket When I go to the Basket page Then I should see "Your shopping basket is empty." # FeatureContext::assertPageContainsText() 1 scenario (1 undefined) 3 steps (1 skipped, 2 undefined) 0m0.031s You can implement step definitions for undefined steps with these snippets: /** * @Given /^I have an empty shopping basket$/ */ public function iHaveAnEmptyShoppingBasket() { throw new PendingException(); } /** * @When /^I go to the Basket page$/ */ public function iGoToTheBasketPage() { throw new PendingException(); } Run it!
FeatureContext extends MinkContext { ! public function __construct(array $parameters) { ! ! $this->useContext('flow', new \Flowpack\Behat\Tests\Behat\FlowContext($parameters)); ! } ! /** ! * @Given /^I have an empty shopping basket$/ ! */ ! public function iHaveAnEmptyShoppingBasket() { ! ! throw new PendingException(); ! } ! /** ! * @When /^I go to the Basket page$/ ! */ ! public function iGoToTheBasketPage() { ! ! throw new PendingException(); ! } }
FeatureContext extends MinkContext { ! public function __construct(array $parameters) { ! ! $this->useContext('flow', new \Flowpack\Behat\Tests\Behat\FlowContext($parameters)); ! } ! /** ! * @Given /^I have an empty shopping basket$/ ! */ ! public function iHaveAnEmptyShoppingBasket() { ! ! // Don't do anything, the session will be clean ! } ! /** ! * @When /^I go to the Basket page$/ ! */ ! public function iGoToTheBasketPage() { ! ! $this->visit('/robertlemke.example.bookshop/basket/index'); ! } } This is a Mink function
get an overview of items in my basket As a buyer in the roebooks store I need a detailed view of the basket Scenario: Empty basket # Features/Basket.feature:7 Given I have an empty shopping basket # FeatureContext::iHaveAn[...]ppingBasket() When I go to the Basket page # FeatureContext::iGoToTheBasketPage() Then I should see "Your shopping basket is empty." # FeatureContext::assertPageContainsText() 1 scenario (1 passed) 3 steps (3 passed) 0m3.834s Run again
Given I have a book in my basket When I go to the Basket page Then I should see "These books are in my basket:" And I should see a book Not very specific Which book?
basket Given the following books exist: | Title | | TYPO3 Neos | And I have the book "TYPO3 Neos" in my basket When I go to the Basket page Then I should see "These books are in my basket:" And I should see the book "TYPO3 Neos" This is a table
for undefined steps with these snippets: /** * @Given /^the following books exist:$/ */ public function theFollowingBooksExist(TableNode $table) { throw new PendingException(); } /** * @Given /^I have the book "([^"]*)" in my basket$/ */ public function iHaveTheBookInMyBasket($arg1) { throw new PendingException(); } /** * @Given /^I should see the book "([^"]*)"$/ */ public function iShouldSeeTheBook($arg1) { throw new PendingException(); } Run it!
get an overview of items in my basket As a buyer in the roebooks store I need a detailed view of the basket Scenario: Empty basket # Features/Basket.feature:7 Given I have an empty shopping basket # FeatureContext::iHaveAn[...]Basket() When I go to the Basket page # FeatureContext::iGoToTheBasketPage() Then I should see "Your shopping basket is empty." # FeatureContext::assertPageContainsText() Scenario: A book in the basket # Features/Basket[...] Given the following books exist: # FeatureContext::[...] | Title | | TYPO3 Neos | And I have the book "TYPO3 Neos" in my basket # FeatureContext::[...] When I go to the Basket page # FeatureContext::[...] Then I should see "These books are currently in your shopping basket:" # FeatureContext::[...] And I should see the book "TYPO3 Neos" # FeatureContext::[...] 2 scenarios (2 passed) 8 steps (8 passed) 0m9.222s Run again
the basket Given the following books exist: | Title | | TYPO3 Neos | And I have the book "TYPO3 Neos" in my basket When I go to the Basket page Then I should see "These books are [...] basket:" And I should see the book "TYPO3 Neos" That will use Selenium2
case of forgotten password As a user of the system I need a way to reset my password safely with email confirmation @fixtures @email Scenario: Perform password reset from confirmation email Given an administrator "admin" with email "admin@example.com" And I am not authenticated And I am on the Homepage page And I follow "Passwort vergessen?" And I fill in "E-Mail" with "admin@example.com" And I press "Link zusenden" When I follow the reset password link in the email to "admin@example.com" Then I should see a form to reset the password When I fill in "Neues Passwort" with "test1234" And I fill in "Passwort (Bestätigung)" with "test1234" And I press "Passwort zurücksetzen" Then I should be able to log in with "admin" and "test1234"
edit content easily As an editor I need a way to edit content inline @fixtures @javascript Scenario: Edit text of a content element with automatic save Given I imported the site "TYPO3.NeosDemoTypo3Org" And the following users exist: | username | password | firstname | lastname | roles | | jdoe | password | John | Doe | Editor | And I am authenticated with "jdoe" and "password" for the backend Then I should be in the "Content" module When I select the first headline content element And I set the content to "NewContent" And I wait for the changes to be saved And I reload the page Then I should see "NewContent"
an API user of the content repository I need support to remove nodes and child nodes Background: Given I have the following nodes: | Identifier | Path | Node Type | Properties | | ecf40ad1-... | /sites | unstructured | | | fd5ba6e1-... | /sites/neosdemotypo3 | TYPO3.Neos.NodeTypes:Page | {"title": "Home"} | | 68ca0dcd-... | /sites/neosdemotypo3/company | TYPO3.Neos.NodeTypes:Page | {"title": "Company"} | | 52540602-... | /sites/neosdemotypo3/company/about | TYPO3.Neos.NodeTypes:Page | {"title": "About"} | @fixtures Scenario: Remove a node in user workspace and publish removes the node itself When I get a node by path "/sites/neosdemotypo3/company" with the following context: | Workspace | | user-admin | And I remove the node And I publish the workspace "user-admin" And I get a node by path "/sites/neosdemotypo3/company" with the following context: | Workspace | | live | Then I should have 0 nodes