of our customers tweet about the products they are buying from our website. Can you include a twitter widget on the productpage and we can configure a message via the admin section ? We think this will encourage more people to share the products on the timeline and increase our sales. Hope this is ok. Client
for this specific scenario, for example Given the customer is logged in. Event: What the feature should be doing, for example When the customer clicks add to cart. Outcome: The expected result from a given context and event. Example: “Then the product should be added to the shopping cart.”
allow visitors to share our products As a site owner I need to offer a way to share via twitter my products Scenario: Visitor can share a product via twitter Given I have twitter enabled with a username When I view a product page Then I should see a twitter block with my message configured
site will see a twitter widget on the product page In order to allow visitors to share our products As a site owner I need to offer a way to share via twitter my products Scenario: Visitor can share a product via twitter Given I have twitter enabled with a username TODO: write pending definition When I view a product page Then I should see a twitter block with my message configured # 1 scenario (1 pending) 3 steps (1 pending, 2 skipped) 0m0.03s (16.09Mb)
use MageTest\MagentoExtension\Context\MagentoContext; class VisitorBrowsingContext extends MagentoContext implements Context, SnippetAcceptingContext { /* * @Given I have twitter enabled with a username */ public function iHaveTwitterEnabledWithAUsername() { $configValue = Mage::getStoreConfig('jcowie/twitter/ active_username'); if (isset($configValue)) { return true; } else { throw new RuntimeException('System configuration value not found'); } }
In order to allow visitors to share our products As a site owner I need to offer a way to share via twitter my products Scenario: Visitor can share a product via twitter6 Given I have twitter enabled with a username System configuration value not found (RuntimeException) When I view a product page Then I should see a twitter block with my message configured --- Failed scenarios: features/visitor/twitter-integration.feature:6 1 scenario (1 failed) 3 steps (1 failed, 2 skipped) 0m0.02s (16.08Mb)
created in /vagrant/spec/ public/app/code/local/Jcowie/Twitter/Block/TwitterSpec.php. ./bin/phpspec r Jcowie_Twitter_Block_Twitter 10 ! it is initializable class Jcowie_Twitter_Block_Twitter does not exist. 94% 16 4 specs 16 examples (15 passed, 1 broken) 308ms Do you want me to create `Jcowie_Twitter_Block_Twitter` for you? [Y/n] Y Magento block Jcowie_Twitter_Block_Twitter created in '/vagrant/public/ app/code/local/Jcowie/Twitter/Block/Twitter.php'.
PhpSpec\ObjectBehavior; use Prophecy\Argument; class Jcowie_Twitter_Block_TwitterSpec extends ObjectBehavior { function it_should_return_the_twitter_username_and_url() { $this->getTwitterShareUrl() ->shouldReturn('http://twitter.com/jcowie'); } }
twitter username and tweet url method Jcowie_Twitter_Block_Twitter::getTwitterShareUrl not found. 50% 50% 2 1 specs 2 examples (1 passed, 1 broken) 36ms Do you want me to create `Jcowie_Twitter_Block_Twitter::getTwitterShareUrl()` for you? [Y/n] Y Method Jcowie_Twitter_Block_Twitter::getTwitterShareUrl() has been created. ./bin/phpspec r Jcowie_Twitter_Block_Twitter 15 ✘ it should return the configured twitter username and tweet url expected "http://twitter.com/jcowie"..., but got null. 50% 50% 2
the class being tested • PHPSpec created the method for us <?php class Jcowie_Twitter_Block_Twitter { public function getTwitterShareUrl() { // TODO: write logic here } }
see a twitter widget on the product page In order to allow visitors to share our products As a site owner I need to offer a way to share via twitter my products Scenario: Visitor can share a product via twitter Given I have twitter enabled with a username When I view a product page Then I should see a twitter block with my message configured 1 scenario (1 passed) 3 steps (3 passed) 0m1.47s (23.14Mb) Time to stop writing code!