diff --git a/.idea/php-docker-settings.xml b/.idea/php-docker-settings.xml index 8deeb20c..a6dae7a4 100644 --- a/.idea/php-docker-settings.xml +++ b/.idea/php-docker-settings.xml @@ -33,6 +33,21 @@ + + + + + + + diff --git a/.idea/php.xml b/.idea/php.xml index 0ed96551..ef27661c 100644 --- a/.idea/php.xml +++ b/.idea/php.xml @@ -1,11 +1,5 @@ - - - - - - @@ -15,7 +9,7 @@ - + @@ -23,6 +17,9 @@ + + + @@ -550,6 +547,202 @@ + + + /etc/php7/conf.d/00_ctype.ini, /etc/php7/conf.d/00_curl.ini, /etc/php7/conf.d/00_json.ini, /etc/php7/conf.d/00_mbstring.ini, /etc/php7/conf.d/00_mcrypt.ini, /etc/php7/conf.d/00_opcache.ini, /etc/php7/conf.d/00_openssl.ini, /etc/php7/conf.d/00_xml.ini, /etc/php7/conf.d/00_zip.ini, /etc/php7/conf.d/00_zlib.ini, /etc/php7/conf.d/01_dom.ini, /etc/php7/conf.d/01_phar.ini, /etc/php7/conf.d/01_xmlreader.ini + /etc/php7/php.ini + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + /usr/local/etc/php/conf.d/ext-bz2.ini @@ -1041,6 +1234,7 @@ + diff --git a/workshop/08_Testing/01_Behat_Testing/01_Initializing_Behat.php b/workshop/08_Testing/01_Behat_Testing/01_Initializing_Behat.php deleted file mode 100644 index e3ab1bde..00000000 --- a/workshop/08_Testing/01_Behat_Testing/01_Initializing_Behat.php +++ /dev/null @@ -1,27 +0,0 @@ - Create All Steps Definition > select previously generated FeatureContext.php file. -// -// 3. All previously missing steps are now defined and can be seen as methods added to your FeatureContext class. You can now edit them transforming into actual tests. -// -// Let's add some logic to get our tests working. Add the helper classes below to FeatureContext.php: -// -// final class Shelf -// { -// private $priceMap = array(); -// -// public function setProductPrice($product, $price) -// { -// $this->priceMap[$product] = $price; -// } -// -// public function getProductPrice($product) -// { -// return $this->priceMap[$product]; -// } -// } -// final class Basket implements \Countable -// { -// private $shelf; -// private $products; -// private $productsPrice = 0.0; -// -// public function __construct(Shelf $shelf) -// { -// $this->shelf = $shelf; -// } -// -// public function addProduct($product) -// { -// $this->products[] = $product; -// $this->productsPrice += $this->shelf->getProductPrice($product); -// } -// -// public function getTotalPrice() -// { -// return $this->productsPrice -// + ($this->productsPrice * 0.2) -// + ($this->productsPrice > 10 ? 2.0 : 3.0); -// } -// -// public function count() -// { -// return count($this->products); -// } -// } -// -// -// Then modify FeatureContext class itself to reflect actual test: -// -// class FeatureContext implements Context -// { -// private $shelf; -// private $basket; -// -// /** -// * Initializes context. -// * -// * Every scenario gets its own context instance. -// * You can also pass arbitrary arguments to the -// * context constructor through behat.yml. -// */ -// public function __construct() -// { -// $this->shelf = new Shelf(); -// $this->basket = new Basket($this->shelf); -// } -// -// /** -// * @Given /^there is a "([^"]*)", which costs (\d+) eur$/ -// */ -// public function thereIsAWhichCostsEur($product, $price) -// { -// $this->shelf->setProductPrice($product, floatval($price)); -// } -// -// /** -// * @When /^I add the "([^"]*)" to the basket$/ -// */ -// public function iAddTheToTheBasket($product) -// { -// $this->basket->addProduct($product); -// } -// -// /** -// * @Then /^I should have (\d+) product in the basket$/ -// */ -// public function iShouldHaveProductInTheBasket($count) -// { -// PHPUnit_Framework_Assert::assertCount( -// intval($count), -// $this->basket -// ); -// } -// -// /** -// * @Given /^the overall basket price should be (\d+) eur$/ -// */ -// public function theOverallBasketPriceShouldBeEur($price) -// { -// PHPUnit_Framework_Assert::assertSame( -// floatval($price), -// $this->basket->getTotalPrice() -// ); -// } -// -// -// } -// -// A side note: if you're getting "Fatal error: Class 'PHPUnit_Framework_Assert' not found" when trying to run the test afterwards - try adding -// -// require_once('path to workshop project\vendor\autoload.php'); -// -// above FeatureContext class declaration. See more at https://youtrack.jetbrains.com/issue/WI-26852 -// Another note: you would most likely face "Multiple definitions exist" warning for PHPUnit_Framework_Assert here. -// That's because we have this class both in /vendor/ and in phpunit-5.2.5.phar. You can right click that phar file and select "Exclude phar from project" diff --git a/workshop/08_Testing/01_Behat_Testing/03_Running_Behat_Tests.php b/workshop/08_Testing/01_Behat_Testing/03_Running_Behat_Tests.php deleted file mode 100644 index 7a947f8c..00000000 --- a/workshop/08_Testing/01_Behat_Testing/03_Running_Behat_Tests.php +++ /dev/null @@ -1,27 +0,0 @@ - select "Create basket.feature" with a "B" (for Behat) logo against it. -// -// IDE would fill out all the necessary settings for us. -// In case you want to fine tune those settings - feel free to either edit automatically created configuration -// or create a Behat run configuration anew using Run > Edit Configurations > "+" sign > Behat. See more -// about available options at https://www.jetbrains.com/help/phpstorm/run-debug-configuration-behat.html -// -// Let's stick to default for now. Click "Ok" and a "Run" tool window would appear with test results! -// -// You should receive a result similar to the one below: -// -// 1 scenario (1 passed) -// 4 steps (4 passed) -// 0m0.04s (7.97Mb) -// -// Process finished with exit code 0 -// -// You can verify this running `vendor\bin\behat` in terminal. \ No newline at end of file diff --git a/workshop/08_Testing/Behat/Behat_Testing.md b/workshop/08_Testing/Behat/Behat_Testing.md new file mode 100644 index 00000000..36476b5b --- /dev/null +++ b/workshop/08_Testing/Behat/Behat_Testing.md @@ -0,0 +1,12 @@ +# Behat testing + +The project has a simple Behat testing scenario included, you can find it at `workshop/08_Testing/Behat/features/my_feature.feature` + +--- +To be able to use it please: +1. Select **PHP Behat** Interpreter at _Settings(Preferences) | Languages & Frameworks | PHP_ +2. Open _Settings(Preferences) | Languages & Frameworks | PHP | Test Frameworks_ and make sure you have a remote Behat configuration called **PHP Behat**. +Open it and check that the path to Behat executable is `/opt/project/workshop/99_Miscellaneous/libs/behat-3.3.phar` +--- +After this you can just right click `workshop/08_Testing/Behat/features/my_feature.feature` and select "Run my_feature.feature (Behat)" + diff --git a/workshop/08_Testing/Behat/features/bootstrap/FeatureContext.php b/workshop/08_Testing/Behat/features/bootstrap/FeatureContext.php new file mode 100644 index 00000000..3182162e --- /dev/null +++ b/workshop/08_Testing/Behat/features/bootstrap/FeatureContext.php @@ -0,0 +1,12 @@ +