{"action":"created","comment":{"url":"https://api.github.com/repos/pagarme/pagarme-magento/pulls/comments/112038234","pull_request_review_id":33318316,"id":112038234,"diff_hunk":"@@ -370,12 +371,133 @@ public function aLinkToBoletoMustBeProvided()\n     }\n \n     /**\n+     * @Given a :discountMode discount of :discount\n+     */\n+    public function discountOf(\n+        $discountMode,\n+        $discount\n+    ) {\n+        $this->configuredDiscountMode = $discountMode;\n+        $this->configuredDiscount = $discount;\n+\n+        Mage::getModel('core/config')\n+            ->saveConfig(\n+                'payment/pagarme_settings/boleto_discount_mode',\n+                $this->configuredDiscountMode\n+            );\n+\n+        Mage::getModel('core/config')\n+            ->saveConfig(\n+                'payment/pagarme_settings/boleto_discount',\n+                $this->configuredDiscount\n+            );\n+    }\n+\n+    /**\n+     * @Then the discount must be described in checkout\n+     */\n+    public function theDiscountMustBeDescribedInCheckout()\n+    {\n+        \\PHPUnit_Framework_TestCase::assertContains(\n+            Mage::helper('pagarme_checkout')->__('Discount'),\n+            $this->getSession()->getPage()->getText()\n+        );\n+    }\n+\n+    private function getGrandTotal()\n+    {\n+        $grandTotalCell = $this->session->getPage()->find(\n+            'css',\n+            'tfoot tr.last strong span.price'\n+        );\n+        \n+        $grandTotal = filter_var(\n+            $grandTotalCell->getHtml(),\n+            FILTER_SANITIZE_NUMBER_FLOAT\n+        );\n+\n+        return $grandTotal;\n+    }\n+\n+    private function getSubtotal($ignoredValues = array())\n+    {\n+        $subtotal = 0;\n+        $prices = $this->session->getPage()->findAll('css', 'tfoot tr');\n+\n+        foreach ($prices as $price) {\n+            $label = trim($price->find('css', ':first-child')->getText());\n+            $value = filter_var(\n+                $price->find('css', 'td.last')->getHtml(),\n+                FILTER_SANITIZE_NUMBER_FLOAT\n+            );\n+\n+            if (in_array($label, $ignoredValues)\n+                || $label == \\Mage::helper('core')->__('Grand Total')) {\n+                continue;\n+            }\n+\n+            $subtotal += $value;\n+        }\n+\n+        return $subtotal;\n+    }\n+\n+    private function getItemValue($item)\n+    {\n+        $itemLabelElement = $this->session->getPage()->find(\n+            'css',\n+            'tfoot tr td:contains(\"'. $item .'\"), tfoot tr th:contains(\"'. $item . '\")'\n+        );\n+\n+        $itemRowElement = $itemLabelElement->getParent();\n+        $itemValue = $itemRowElement->find('css', '.last .price');\n+\n+        return filter_var(\n+            $itemValue->getHtml(),\n+            FILTER_SANITIZE_NUMBER_FLOAT\n+        );\n+    }\n+\n+    /**\n+     * @Then the discount must be applied\n+     */\n+    public function theDiscountMustBeApplied()\n+    {\n+        $discountLabel = \\Mage::helper('pagarme_core')->__('Discount');\n+\n+        $subtotal = $this->getSubtotal([ $discountLabel ]);\n+        $discount = (int) $this->getItemValue($discountLabel);\n+        $grandTotal = $this->getGrandTotal();\n+\n+        if ($this->configuredDiscountMode ==\n+            PagarMe_Core_Model_System_Config_Source_BoletoDiscountMode::FIXED_VALUE) {","path":"tests/acceptance/CheckoutContext.php","position":124,"original_position":124,"commit_id":"758f7c6dbb63d84b761ce7133c2ca7ea73367bb4","original_commit_id":"758f7c6dbb63d84b761ce7133c2ca7ea73367bb4","user":{"login":"devdrops","id":1259313,"avatar_url":"https://avatars1.githubusercontent.com/u/1259313?v=3","gravatar_id":"","url":"https://api.github.com/users/devdrops","html_url":"https://github.com/devdrops","followers_url":"https://api.github.com/users/devdrops/followers","following_url":"https://api.github.com/users/devdrops/following{/other_user}","gists_url":"https://api.github.com/users/devdrops/gists{/gist_id}","starred_url":"https://api.github.com/users/devdrops/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/devdrops/subscriptions","organizations_url":"https://api.github.com/users/devdrops/orgs","repos_url":"https://api.github.com/users/devdrops/repos","events_url":"https://api.github.com/users/devdrops/events{/privacy}","received_events_url":"https://api.github.com/users/devdrops/received_events","type":"User","site_admin":false},"body":"@ricardotulio linha extra, favor verificar.","created_at":"2017-04-18T19:06:59Z","updated_at":"2017-04-18T19:08:08Z","html_url":"https://github.com/pagarme/pagarme-magento/pull/171#discussion_r112038234","pull_request_url":"https://api.github.com/repos/pagarme/pagarme-magento/pulls/171","_links":{"self":{"href":"https://api.github.com/repos/pagarme/pagarme-magento/pulls/comments/112038234"},"html":{"href":"https://github.com/pagarme/pagarme-magento/pull/171#discussion_r112038234"},"pull_request":{"href":"https://api.github.com/repos/pagarme/pagarme-magento/pulls/171"}}},"pull_request":{"url":"https://api.github.com/repos/pagarme/pagarme-magento/pulls/171","id":115220470,"html_url":"https://github.com/pagarme/pagarme-magento/pull/171","diff_url":"https://github.com/pagarme/pagarme-magento/pull/171.diff","patch_url":"https://github.com/pagarme/pagarme-magento/pull/171.patch","issue_url":"https://api.github.com/repos/pagarme/pagarme-magento/issues/171","number":171,"state":"open","locked":false,"title":"Story/boleto discount","user":{"login":"ricardotulio","id":5113666,"avatar_url":"https://avatars3.githubusercontent.com/u/5113666?v=3","gravatar_id":"","url":"https://api.github.com/users/ricardotulio","html_url":"https://github.com/ricardotulio","followers_url":"https://api.github.com/users/ricardotulio/followers","following_url":"https://api.github.com/users/ricardotulio/following{/other_user}","gists_url":"https://api.github.com/users/ricardotulio/gists{/gist_id}","starred_url":"https://api.github.com/users/ricardotulio/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ricardotulio/subscriptions","organizations_url":"https://api.github.com/users/ricardotulio/orgs","repos_url":"https://api.github.com/users/ricardotulio/repos","events_url":"https://api.github.com/users/ricardotulio/events{/privacy}","received_events_url":"https://api.github.com/users/ricardotulio/received_events","type":"User","site_admin":false},"body":"## Contexto\r\n\r\nImplementa desconto no boleto no PagarMe Checkout.\r\n\r\n## Ambiente\r\n\r\n* Magento Community 1.8.1.0\r\n* Módulo Pagar.me 0.1.6\r\n* Servidor Linux\r\n* PHP 5.4\r\n* Apache 2.2\r\n* MySQL 5.6\r\n\r\n## Passos para reproduzir\r\n\r\n1. Configure o desconto no Painel Administrativo do Magento\r\n2. Efetue uma compra via boleto\r\n\r\n## Resultado esperado\r\n\r\nO desconto deveria ser aplicado ao valor total da compra.\r\n\r\n## Resultado atual\r\n\r\nO desconto não é aplicado.","created_at":"2017-04-11T00:48:49Z","updated_at":"2017-04-18T19:08:08Z","closed_at":null,"merged_at":null,"merge_commit_sha":"b0099474b29af589d6861e4769ccb4f9a66c4a88","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/pagarme/pagarme-magento/pulls/171/commits","review_comments_url":"https://api.github.com/repos/pagarme/pagarme-magento/pulls/171/comments","review_comment_url":"https://api.github.com/repos/pagarme/pagarme-magento/pulls/comments{/number}","comments_url":"https://api.github.com/repos/pagarme/pagarme-magento/issues/171/comments","statuses_url":"https://api.github.com/repos/pagarme/pagarme-magento/statuses/758f7c6dbb63d84b761ce7133c2ca7ea73367bb4","head":{"label":"pagarme:story/boleto-discount","ref":"story/boleto-discount","sha":"758f7c6dbb63d84b761ce7133c2ca7ea73367bb4","user":{"login":"pagarme","id":3846050,"avatar_url":"https://avatars1.githubusercontent.com/u/3846050?v=3","gravatar_id":"","url":"https://api.github.com/users/pagarme","html_url":"https://github.com/pagarme","followers_url":"https://api.github.com/users/pagarme/followers","following_url":"https://api.github.com/users/pagarme/following{/other_user}","gists_url":"https://api.github.com/users/pagarme/gists{/gist_id}","starred_url":"https://api.github.com/users/pagarme/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pagarme/subscriptions","organizations_url":"https://api.github.com/users/pagarme/orgs","repos_url":"https://api.github.com/users/pagarme/repos","events_url":"https://api.github.com/users/pagarme/events{/privacy}","received_events_url":"https://api.github.com/users/pagarme/received_events","type":"Organization","site_admin":false},"repo":{"id":16109770,"name":"pagarme-magento","full_name":"pagarme/pagarme-magento","owner":{"login":"pagarme","id":3846050,"avatar_url":"https://avatars1.githubusercontent.com/u/3846050?v=3","gravatar_id":"","url":"https://api.github.com/users/pagarme","html_url":"https://github.com/pagarme","followers_url":"https://api.github.com/users/pagarme/followers","following_url":"https://api.github.com/users/pagarme/following{/other_user}","gists_url":"https://api.github.com/users/pagarme/gists{/gist_id}","starred_url":"https://api.github.com/users/pagarme/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pagarme/subscriptions","organizations_url":"https://api.github.com/users/pagarme/orgs","repos_url":"https://api.github.com/users/pagarme/repos","events_url":"https://api.github.com/users/pagarme/events{/privacy}","received_events_url":"https://api.github.com/users/pagarme/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/pagarme/pagarme-magento","description":"Pagar.me's Magento plugin","fork":false,"url":"https://api.github.com/repos/pagarme/pagarme-magento","forks_url":"https://api.github.com/repos/pagarme/pagarme-magento/forks","keys_url":"https://api.github.com/repos/pagarme/pagarme-magento/keys{/key_id}","collaborators_url":"https://api.github.com/repos/pagarme/pagarme-magento/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/pagarme/pagarme-magento/teams","hooks_url":"https://api.github.com/repos/pagarme/pagarme-magento/hooks","issue_events_url":"https://api.github.com/repos/pagarme/pagarme-magento/issues/events{/number}","events_url":"https://api.github.com/repos/pagarme/pagarme-magento/events","assignees_url":"https://api.github.com/repos/pagarme/pagarme-magento/assignees{/user}","branches_url":"https://api.github.com/repos/pagarme/pagarme-magento/branches{/branch}","tags_url":"https://api.github.com/repos/pagarme/pagarme-magento/tags","blobs_url":"https://api.github.com/repos/pagarme/pagarme-magento/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/pagarme/pagarme-magento/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/pagarme/pagarme-magento/git/refs{/sha}","trees_url":"https://api.github.com/repos/pagarme/pagarme-magento/git/trees{/sha}","statuses_url":"https://api.github.com/repos/pagarme/pagarme-magento/statuses/{sha}","languages_url":"https://api.github.com/repos/pagarme/pagarme-magento/languages","stargazers_url":"https://api.github.com/repos/pagarme/pagarme-magento/stargazers","contributors_url":"https://api.github.com/repos/pagarme/pagarme-magento/contributors","subscribers_url":"https://api.github.com/repos/pagarme/pagarme-magento/subscribers","subscription_url":"https://api.github.com/repos/pagarme/pagarme-magento/subscription","commits_url":"https://api.github.com/repos/pagarme/pagarme-magento/commits{/sha}","git_commits_url":"https://api.github.com/repos/pagarme/pagarme-magento/git/commits{/sha}","comments_url":"https://api.github.com/repos/pagarme/pagarme-magento/comments{/number}","issue_comment_url":"https://api.github.com/repos/pagarme/pagarme-magento/issues/comments{/number}","contents_url":"https://api.github.com/repos/pagarme/pagarme-magento/contents/{+path}","compare_url":"https://api.github.com/repos/pagarme/pagarme-magento/compare/{base}...{head}","merges_url":"https://api.github.com/repos/pagarme/pagarme-magento/merges","archive_url":"https://api.github.com/repos/pagarme/pagarme-magento/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/pagarme/pagarme-magento/downloads","issues_url":"https://api.github.com/repos/pagarme/pagarme-magento/issues{/number}","pulls_url":"https://api.github.com/repos/pagarme/pagarme-magento/pulls{/number}","milestones_url":"https://api.github.com/repos/pagarme/pagarme-magento/milestones{/number}","notifications_url":"https://api.github.com/repos/pagarme/pagarme-magento/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/pagarme/pagarme-magento/labels{/name}","releases_url":"https://api.github.com/repos/pagarme/pagarme-magento/releases{/id}","deployments_url":"https://api.github.com/repos/pagarme/pagarme-magento/deployments","created_at":"2014-01-21T16:56:55Z","updated_at":"2017-02-10T21:31:58Z","pushed_at":"2017-04-18T17:56:51Z","git_url":"git://github.com/pagarme/pagarme-magento.git","ssh_url":"git@github.com:pagarme/pagarme-magento.git","clone_url":"https://github.com/pagarme/pagarme-magento.git","svn_url":"https://github.com/pagarme/pagarme-magento","homepage":null,"size":1744,"stargazers_count":18,"watchers_count":18,"language":"PHP","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":18,"mirror_url":null,"open_issues_count":31,"forks":18,"open_issues":31,"watchers":18,"default_branch":"master"}},"base":{"label":"pagarme:v2","ref":"v2","sha":"fb4686f1257cff0cac31f1838f5883d4f8225f4d","user":{"login":"pagarme","id":3846050,"avatar_url":"https://avatars1.githubusercontent.com/u/3846050?v=3","gravatar_id":"","url":"https://api.github.com/users/pagarme","html_url":"https://github.com/pagarme","followers_url":"https://api.github.com/users/pagarme/followers","following_url":"https://api.github.com/users/pagarme/following{/other_user}","gists_url":"https://api.github.com/users/pagarme/gists{/gist_id}","starred_url":"https://api.github.com/users/pagarme/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pagarme/subscriptions","organizations_url":"https://api.github.com/users/pagarme/orgs","repos_url":"https://api.github.com/users/pagarme/repos","events_url":"https://api.github.com/users/pagarme/events{/privacy}","received_events_url":"https://api.github.com/users/pagarme/received_events","type":"Organization","site_admin":false},"repo":{"id":16109770,"name":"pagarme-magento","full_name":"pagarme/pagarme-magento","owner":{"login":"pagarme","id":3846050,"avatar_url":"https://avatars1.githubusercontent.com/u/3846050?v=3","gravatar_id":"","url":"https://api.github.com/users/pagarme","html_url":"https://github.com/pagarme","followers_url":"https://api.github.com/users/pagarme/followers","following_url":"https://api.github.com/users/pagarme/following{/other_user}","gists_url":"https://api.github.com/users/pagarme/gists{/gist_id}","starred_url":"https://api.github.com/users/pagarme/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pagarme/subscriptions","organizations_url":"https://api.github.com/users/pagarme/orgs","repos_url":"https://api.github.com/users/pagarme/repos","events_url":"https://api.github.com/users/pagarme/events{/privacy}","received_events_url":"https://api.github.com/users/pagarme/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/pagarme/pagarme-magento","description":"Pagar.me's Magento plugin","fork":false,"url":"https://api.github.com/repos/pagarme/pagarme-magento","forks_url":"https://api.github.com/repos/pagarme/pagarme-magento/forks","keys_url":"https://api.github.com/repos/pagarme/pagarme-magento/keys{/key_id}","collaborators_url":"https://api.github.com/repos/pagarme/pagarme-magento/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/pagarme/pagarme-magento/teams","hooks_url":"https://api.github.com/repos/pagarme/pagarme-magento/hooks","issue_events_url":"https://api.github.com/repos/pagarme/pagarme-magento/issues/events{/number}","events_url":"https://api.github.com/repos/pagarme/pagarme-magento/events","assignees_url":"https://api.github.com/repos/pagarme/pagarme-magento/assignees{/user}","branches_url":"https://api.github.com/repos/pagarme/pagarme-magento/branches{/branch}","tags_url":"https://api.github.com/repos/pagarme/pagarme-magento/tags","blobs_url":"https://api.github.com/repos/pagarme/pagarme-magento/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/pagarme/pagarme-magento/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/pagarme/pagarme-magento/git/refs{/sha}","trees_url":"https://api.github.com/repos/pagarme/pagarme-magento/git/trees{/sha}","statuses_url":"https://api.github.com/repos/pagarme/pagarme-magento/statuses/{sha}","languages_url":"https://api.github.com/repos/pagarme/pagarme-magento/languages","stargazers_url":"https://api.github.com/repos/pagarme/pagarme-magento/stargazers","contributors_url":"https://api.github.com/repos/pagarme/pagarme-magento/contributors","subscribers_url":"https://api.github.com/repos/pagarme/pagarme-magento/subscribers","subscription_url":"https://api.github.com/repos/pagarme/pagarme-magento/subscription","commits_url":"https://api.github.com/repos/pagarme/pagarme-magento/commits{/sha}","git_commits_url":"https://api.github.com/repos/pagarme/pagarme-magento/git/commits{/sha}","comments_url":"https://api.github.com/repos/pagarme/pagarme-magento/comments{/number}","issue_comment_url":"https://api.github.com/repos/pagarme/pagarme-magento/issues/comments{/number}","contents_url":"https://api.github.com/repos/pagarme/pagarme-magento/contents/{+path}","compare_url":"https://api.github.com/repos/pagarme/pagarme-magento/compare/{base}...{head}","merges_url":"https://api.github.com/repos/pagarme/pagarme-magento/merges","archive_url":"https://api.github.com/repos/pagarme/pagarme-magento/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/pagarme/pagarme-magento/downloads","issues_url":"https://api.github.com/repos/pagarme/pagarme-magento/issues{/number}","pulls_url":"https://api.github.com/repos/pagarme/pagarme-magento/pulls{/number}","milestones_url":"https://api.github.com/repos/pagarme/pagarme-magento/milestones{/number}","notifications_url":"https://api.github.com/repos/pagarme/pagarme-magento/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/pagarme/pagarme-magento/labels{/name}","releases_url":"https://api.github.com/repos/pagarme/pagarme-magento/releases{/id}","deployments_url":"https://api.github.com/repos/pagarme/pagarme-magento/deployments","created_at":"2014-01-21T16:56:55Z","updated_at":"2017-02-10T21:31:58Z","pushed_at":"2017-04-18T17:56:51Z","git_url":"git://github.com/pagarme/pagarme-magento.git","ssh_url":"git@github.com:pagarme/pagarme-magento.git","clone_url":"https://github.com/pagarme/pagarme-magento.git","svn_url":"https://github.com/pagarme/pagarme-magento","homepage":null,"size":1744,"stargazers_count":18,"watchers_count":18,"language":"PHP","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":18,"mirror_url":null,"open_issues_count":31,"forks":18,"open_issues":31,"watchers":18,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/pagarme/pagarme-magento/pulls/171"},"html":{"href":"https://github.com/pagarme/pagarme-magento/pull/171"},"issue":{"href":"https://api.github.com/repos/pagarme/pagarme-magento/issues/171"},"comments":{"href":"https://api.github.com/repos/pagarme/pagarme-magento/issues/171/comments"},"review_comments":{"href":"https://api.github.com/repos/pagarme/pagarme-magento/pulls/171/comments"},"review_comment":{"href":"https://api.github.com/repos/pagarme/pagarme-magento/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/pagarme/pagarme-magento/pulls/171/commits"},"statuses":{"href":"https://api.github.com/repos/pagarme/pagarme-magento/statuses/758f7c6dbb63d84b761ce7133c2ca7ea73367bb4"}}}}
{"actor":{"display_login":"devdrops"}}