From 637f2988189344daac91f0f4ff4457294775ab4f Mon Sep 17 00:00:00 2001 From: Hillel Coren Date: Mon, 4 Jul 2016 13:21:40 +0300 Subject: [PATCH] Fix for approving quote --- app/Services/InvoiceService.php | 21 +- .../_generated/AcceptanceTesterActions.php | 221 +++++++++--------- tests/acceptance.suite.yml | 4 +- 3 files changed, 120 insertions(+), 126 deletions(-) diff --git a/app/Services/InvoiceService.php b/app/Services/InvoiceService.php index 13c6f2e76708..7238d515536c 100644 --- a/app/Services/InvoiceService.php +++ b/app/Services/InvoiceService.php @@ -113,18 +113,9 @@ class InvoiceService extends BaseService * @param Invitation|null $invitation * @return mixed */ - public function convertQuote($quote, Invitation $invitation = null) + public function convertQuote($quote) { - $invoice = $this->invoiceRepo->cloneInvoice($quote, $quote->id); - if (!$invitation) { - return $invoice; - } - - foreach ($invoice->invitations as $invoiceInvitation) { - if ($invitation->contact_id == $invoiceInvitation->contact_id) { - return $invoiceInvitation->invitation_key; - } - } + return $this->invoiceRepo->cloneInvoice($quote, $quote->id); } /** @@ -141,7 +132,13 @@ class InvoiceService extends BaseService } if ($account->auto_convert_quote || ! $account->hasFeature(FEATURE_QUOTES)) { - $invoice = $this->convertQuote($quote, $invitation); + $invoice = $this->convertQuote($quote); + + foreach ($invoice->invitations as $invoiceInvitation) { + if ($invitation->contact_id == $invoiceInvitation->contact_id) { + $invitation = $invoiceInvitation; + } + } event(new QuoteInvitationWasApproved($quote, $invoice, $invitation)); diff --git a/tests/_support/_generated/AcceptanceTesterActions.php b/tests/_support/_generated/AcceptanceTesterActions.php index 82427d1e2a5e..1d0ad75ebbef 100644 --- a/tests/_support/_generated/AcceptanceTesterActions.php +++ b/tests/_support/_generated/AcceptanceTesterActions.php @@ -1,4 +1,4 @@ -see('Sign Up', 'h1'); // I can suppose it's a signup page * $I->see('Sign Up', '//body/h1'); // with XPath * ``` - * + * * Note that the search is done after stripping all HTML tags from the body, * so `$I->see('strong')` will return true for strings like: - * + * * - `

I am Stronger than thou

` * - `` - * + * * But will *not* be true for strings like: - * + * * - `Home` * - `
Home` * - `` - * + * * For checking the raw source code, use `seeInSource()`. * * @param $text @@ -311,8 +311,8 @@ trait AcceptanceTesterActions * [!] Method is generated. Documentation taken from corresponding module. * * Checks that the current page contains the given string (case insensitive). - * - * You can specify a specific HTML element (via CSS or XPath) as the second + * + * You can specify a specific HTML element (via CSS or XPath) as the second * parameter to only search within that element. * * ``` php @@ -321,19 +321,19 @@ trait AcceptanceTesterActions * $I->see('Sign Up', 'h1'); // I can suppose it's a signup page * $I->see('Sign Up', '//body/h1'); // with XPath * ``` - * + * * Note that the search is done after stripping all HTML tags from the body, * so `$I->see('strong')` will return true for strings like: - * + * * - `

I am Stronger than thou

` * - `` - * + * * But will *not* be true for strings like: - * + * * - `Home` * - `
Home` * - `` - * + * * For checking the raw source code, use `seeInSource()`. * * @param $text @@ -357,19 +357,19 @@ trait AcceptanceTesterActions * $I->dontSee('Sign Up','h1'); // I can suppose it's not a signup page * $I->dontSee('Sign Up','//body/h1'); // with XPath * ``` - * + * * Note that the search is done after stripping all HTML tags from the body, * so `$I->dontSee('strong')` will fail on strings like: - * + * * - `

I am Stronger than thou

` * - `` - * + * * But will ignore strings like: - * + * * - `Home` * - `
Home` * - `` - * + * * For checking the raw source code, use `seeInSource()`. * * @param $text @@ -392,19 +392,19 @@ trait AcceptanceTesterActions * $I->dontSee('Sign Up','h1'); // I can suppose it's not a signup page * $I->dontSee('Sign Up','//body/h1'); // with XPath * ``` - * + * * Note that the search is done after stripping all HTML tags from the body, * so `$I->dontSee('strong')` will fail on strings like: - * + * * - `

I am Stronger than thou

` * - `` - * + * * But will ignore strings like: - * + * * - `Home` * - `
Home` * - `` - * + * * For checking the raw source code, use `seeInSource()`. * * @param $text @@ -1125,7 +1125,7 @@ trait AcceptanceTesterActions * * Checks if the array of form parameters (name => value) are set on the form matched with the * passed selector. - * + * * ``` php * seeInFormFields('form[name=myform]', [ @@ -1134,10 +1134,10 @@ trait AcceptanceTesterActions * ]); * ?> * ``` - * + * * For multi-select elements, or to check values of multiple elements with the same name, an * array may be passed: - * + * * ``` php * seeInFormFields('.form-class', [ @@ -1154,7 +1154,7 @@ trait AcceptanceTesterActions * ``` * * Additionally, checkbox values can be checked with a boolean. - * + * * ``` php * seeInFormFields('#form-id', [ @@ -1163,9 +1163,9 @@ trait AcceptanceTesterActions * ]); * ?> * ``` - * + * * Pair this with submitForm for quick testing magic. - * + * * ``` php * seeInFormFields('//form[@id=my-form]', $form); * ?> * ``` - * + * * @param $formSelector * @param $params * Conditional Assertion: Test won't be stopped on fail @@ -1193,7 +1193,7 @@ trait AcceptanceTesterActions * * Checks if the array of form parameters (name => value) are set on the form matched with the * passed selector. - * + * * ``` php * seeInFormFields('form[name=myform]', [ @@ -1202,10 +1202,10 @@ trait AcceptanceTesterActions * ]); * ?> * ``` - * + * * For multi-select elements, or to check values of multiple elements with the same name, an * array may be passed: - * + * * ``` php * seeInFormFields('.form-class', [ @@ -1222,7 +1222,7 @@ trait AcceptanceTesterActions * ``` * * Additionally, checkbox values can be checked with a boolean. - * + * * ``` php * seeInFormFields('#form-id', [ @@ -1231,9 +1231,9 @@ trait AcceptanceTesterActions * ]); * ?> * ``` - * + * * Pair this with submitForm for quick testing magic. - * + * * ``` php * seeInFormFields('//form[@id=my-form]', $form); * ?> * ``` - * + * * @param $formSelector * @param $params * @see \Codeception\Module\WebDriver::seeInFormFields() @@ -1262,7 +1262,7 @@ trait AcceptanceTesterActions * * Checks if the array of form parameters (name => value) are not set on the form matched with * the passed selector. - * + * * ``` php * dontSeeInFormFields('form[name=myform]', [ @@ -1271,10 +1271,10 @@ trait AcceptanceTesterActions * ]); * ?> * ``` - * + * * To check that an element hasn't been assigned any one of many values, an array can be passed * as the value: - * + * * ``` php * dontSeeInFormFields('.form-class', [ @@ -1287,7 +1287,7 @@ trait AcceptanceTesterActions * ``` * * Additionally, checkbox values can be checked with a boolean. - * + * * ``` php * dontSeeInFormFields('#form-id', [ @@ -1296,7 +1296,7 @@ trait AcceptanceTesterActions * ]); * ?> * ``` - * + * * @param $formSelector * @param $params * Conditional Assertion: Test won't be stopped on fail @@ -1310,7 +1310,7 @@ trait AcceptanceTesterActions * * Checks if the array of form parameters (name => value) are not set on the form matched with * the passed selector. - * + * * ``` php * dontSeeInFormFields('form[name=myform]', [ @@ -1319,10 +1319,10 @@ trait AcceptanceTesterActions * ]); * ?> * ``` - * + * * To check that an element hasn't been assigned any one of many values, an array can be passed * as the value: - * + * * ``` php * dontSeeInFormFields('.form-class', [ @@ -1335,7 +1335,7 @@ trait AcceptanceTesterActions * ``` * * Additionally, checkbox values can be checked with a boolean. - * + * * ``` php * dontSeeInFormFields('#form-id', [ @@ -1344,7 +1344,7 @@ trait AcceptanceTesterActions * ]); * ?> * ``` - * + * * @param $formSelector * @param $params * @see \Codeception\Module\WebDriver::dontSeeInFormFields() @@ -1375,6 +1375,15 @@ trait AcceptanceTesterActions * ?> * ``` * + * Or provide an associative array for the second argument to specifically define which selection method should be used: + * + * ``` php + * selectOption('Which OS do you use?', array('text' => 'Windows')); // Only search by text 'Windows' + * $I->selectOption('Which OS do you use?', array('value' => 'windows')); // Only search by value 'windows' + * ?> + + ``` + * * @param $select * @param $option * @see \Codeception\Module\WebDriver::selectOption() @@ -1492,7 +1501,8 @@ trait AcceptanceTesterActions * [!] Method is generated. Documentation taken from corresponding module. * * Finds and returns the text contents of the given element. - * If a fuzzy locator is used, the element is found using CSS, XPath, and by matching the full page source by regular expression. + * If a fuzzy locator is used, the element is found using CSS, XPath, + * and by matching the full page source by regular expression. * * ``` php * First * Second * Third * ``` - * + * * ```php * grabMultiple('a'); - * + * * // would return ['#first', '#second', '#third'] * $aLinks = $I->grabMultiple('a', 'href'); * ?> * ``` - * + * * @param $cssOrXpath * @param $attribute * @return string[] @@ -1981,7 +1991,8 @@ trait AcceptanceTesterActions * [!] Method is generated. Documentation taken from corresponding module. * * Accepts the active JavaScript native popup window, as created by `window.alert`|`window.confirm`|`window.prompt`. - * Don't confuse popups with modal windows, as created by [various libraries](http://jster.net/category/windows-modals-popups). + * Don't confuse popups with modal windows, + * as created by [various libraries](http://jster.net/category/windows-modals-popups). * @see \Codeception\Module\WebDriver::acceptPopup() */ public function acceptPopup() { @@ -2003,7 +2014,8 @@ trait AcceptanceTesterActions /** * [!] Method is generated. Documentation taken from corresponding module. * - * Checks that the active JavaScript popup, as created by `window.alert`|`window.confirm`|`window.prompt`, contains the given string. + * Checks that the active JavaScript popup, + * as created by `window.alert`|`window.confirm`|`window.prompt`, contains the given string. * * @param $text * Conditional Assertion: Test won't be stopped on fail @@ -2015,7 +2027,8 @@ trait AcceptanceTesterActions /** * [!] Method is generated. Documentation taken from corresponding module. * - * Checks that the active JavaScript popup, as created by `window.alert`|`window.confirm`|`window.prompt`, contains the given string. + * Checks that the active JavaScript popup, + * as created by `window.alert`|`window.confirm`|`window.prompt`, contains the given string. * * @param $text * @see \Codeception\Module\WebDriver::seeInPopup() @@ -2224,7 +2237,8 @@ trait AcceptanceTesterActions * [!] Method is generated. Documentation taken from corresponding module. * * Waits up to $timeout seconds for the given element to change. - * Element "change" is determined by a callback function which is called repeatedly until the return value evaluates to true. + * Element "change" is determined by a callback function which is called repeatedly + * until the return value evaluates to true. * * ``` php * * ``` * - * @param $table + * @param string $table * @param array $data * * @return integer $id @@ -2714,21 +2732,13 @@ trait AcceptanceTesterActions * Asserts that a row with the given column values exists. * Provide table name and column values. * - * Example: - * * ``` php * seeInDatabase('users', array('name' => 'Davert', 'email' => 'davert@mail.com')); - * - * ``` - * Will generate: - * - * ``` sql - * SELECT COUNT(*) FROM `users` WHERE `name` = 'Davert' AND `email` = 'davert@mail.com' * ``` * Fails if no such user found. * - * @param $table + * @param string $table * @param array $criteria * Conditional Assertion: Test won't be stopped on fail * @see \Codeception\Module\Db::seeInDatabase() @@ -2742,21 +2752,13 @@ trait AcceptanceTesterActions * Asserts that a row with the given column values exists. * Provide table name and column values. * - * Example: - * * ``` php * seeInDatabase('users', array('name' => 'Davert', 'email' => 'davert@mail.com')); - * - * ``` - * Will generate: - * - * ``` sql - * SELECT COUNT(*) FROM `users` WHERE `name` = 'Davert' AND `email` = 'davert@mail.com' * ``` * Fails if no such user found. * - * @param $table + * @param string $table * @param array $criteria * @see \Codeception\Module\Db::seeInDatabase() */ @@ -2776,9 +2778,9 @@ trait AcceptanceTesterActions * ?> * ``` * - * @param int $expectedNumber Expected number - * @param string $table Table name - * @param array $criteria Search criteria [Optional] + * @param int $expectedNumber Expected number + * @param string $table Table name + * @param array $criteria Search criteria [Optional] * Conditional Assertion: Test won't be stopped on fail * @see \Codeception\Module\Db::seeNumRecords() */ @@ -2796,9 +2798,9 @@ trait AcceptanceTesterActions * ?> * ``` * - * @param int $expectedNumber Expected number - * @param string $table Table name - * @param array $criteria Search criteria [Optional] + * @param int $expectedNumber Expected number + * @param string $table Table name + * @param array $criteria Search criteria [Optional] * @see \Codeception\Module\Db::seeNumRecords() */ public function seeNumRecords($expectedNumber, $table, $criteria = null) { @@ -2814,21 +2816,13 @@ trait AcceptanceTesterActions * Asserts that there is no record with the given column values in a database. * Provide table name and column values. * - * Example: - * * ``` php * dontSeeInDatabase('users', array('name' => 'Davert', 'email' => 'davert@mail.com')); - * - * ``` - * Will generate: - * - * ``` sql - * SELECT COUNT(*) FROM `users` WHERE `name` = 'Davert' AND `email` = 'davert@mail.com' * ``` * Fails if such user was found. * - * @param $table + * @param string $table * @param array $criteria * Conditional Assertion: Test won't be stopped on fail * @see \Codeception\Module\Db::dontSeeInDatabase() @@ -2844,21 +2838,13 @@ trait AcceptanceTesterActions * Asserts that there is no record with the given column values in a database. * Provide table name and column values. * - * Example: - * * ``` php * dontSeeInDatabase('users', array('name' => 'Davert', 'email' => 'davert@mail.com')); - * - * ``` - * Will generate: - * - * ``` sql - * SELECT COUNT(*) FROM `users` WHERE `name` = 'Davert' AND `email` = 'davert@mail.com' * ``` * Fails if such user was found. * - * @param $table + * @param string $table * @param array $criteria * @see \Codeception\Module\Db::dontSeeInDatabase() */ @@ -2873,18 +2859,13 @@ trait AcceptanceTesterActions * Fetches a single column value from a database. * Provide table name, desired column and criteria. * - * Example: - * * ``` php * grabFromDatabase('users', 'email', array('name' => 'Davert')); - * * ``` * - * @version 1.1 - * - * @param $table - * @param $column + * @param string $table + * @param string $column * @param array $criteria * * @return mixed @@ -2893,4 +2874,20 @@ trait AcceptanceTesterActions public function grabFromDatabase($table, $column, $criteria = null) { return $this->getScenario()->runStep(new \Codeception\Step\Action('grabFromDatabase', func_get_args())); } + + + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Returns the number of rows in a database + * + * @param string $table Table name + * @param array $criteria Search criteria [Optional] + * + * @return int + * @see \Codeception\Module\Db::grabNumRecords() + */ + public function grabNumRecords($table, $criteria = null) { + return $this->getScenario()->runStep(new \Codeception\Step\Action('grabNumRecords', func_get_args())); + } } diff --git a/tests/acceptance.suite.yml b/tests/acceptance.suite.yml index 05dcbc71eca7..6925b0638321 100644 --- a/tests/acceptance.suite.yml +++ b/tests/acceptance.suite.yml @@ -8,7 +8,7 @@ class_name: AcceptanceTester modules: enabled: - WebDriver: - url: 'http://ninja.dev:8000/' + url: 'http://ninja.dev/' window_size: 1024x768 wait: 5 browser: firefox @@ -20,4 +20,4 @@ modules: user: 'ninja' password: 'ninja' dump: tests/_data/dump.sql - - \Helper\Acceptance \ No newline at end of file + - \Helper\Acceptance