Fix for approving quote

This commit is contained in:
Hillel Coren 2016-07-04 13:21:40 +03:00
parent 6217419a2f
commit 637f298818
3 changed files with 120 additions and 126 deletions

View File

@ -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));

View File

@ -1,4 +1,4 @@
<?php //[STAMP] a3cf36879dbbec28f15389e7d8d325a2
<?php //[STAMP] 37380042138360812111baed01969345
namespace _generated;
// This class was automatically generated by build task
@ -274,8 +274,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
@ -284,19 +284,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:
*
*
* - `<p>I am Stronger than thou</p>`
* - `<script>document.createElement('strong');</script>`
*
*
* But will *not* be true for strings like:
*
*
* - `<strong>Home</strong>`
* - `<div class="strong">Home</strong>`
* - `<!-- strong -->`
*
*
* 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:
*
*
* - `<p>I am Stronger than thou</p>`
* - `<script>document.createElement('strong');</script>`
*
*
* But will *not* be true for strings like:
*
*
* - `<strong>Home</strong>`
* - `<div class="strong">Home</strong>`
* - `<!-- strong -->`
*
*
* 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:
*
*
* - `<p>I am Stronger than thou</p>`
* - `<script>document.createElement('strong');</script>`
*
*
* But will ignore strings like:
*
*
* - `<strong>Home</strong>`
* - `<div class="strong">Home</strong>`
* - `<!-- strong -->`
*
*
* 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:
*
*
* - `<p>I am Stronger than thou</p>`
* - `<script>document.createElement('strong');</script>`
*
*
* But will ignore strings like:
*
*
* - `<strong>Home</strong>`
* - `<div class="strong">Home</strong>`
* - `<!-- strong -->`
*
*
* 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
* <?php
* $I->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
* <?php
* $I->seeInFormFields('.form-class', [
@ -1154,7 +1154,7 @@ trait AcceptanceTesterActions
* ```
*
* Additionally, checkbox values can be checked with a boolean.
*
*
* ``` php
* <?php
* $I->seeInFormFields('#form-id', [
@ -1163,9 +1163,9 @@ trait AcceptanceTesterActions
* ]);
* ?>
* ```
*
*
* Pair this with submitForm for quick testing magic.
*
*
* ``` php
* <?php
* $form = [
@ -1179,7 +1179,7 @@ trait AcceptanceTesterActions
* $I->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
* <?php
* $I->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
* <?php
* $I->seeInFormFields('.form-class', [
@ -1222,7 +1222,7 @@ trait AcceptanceTesterActions
* ```
*
* Additionally, checkbox values can be checked with a boolean.
*
*
* ``` php
* <?php
* $I->seeInFormFields('#form-id', [
@ -1231,9 +1231,9 @@ trait AcceptanceTesterActions
* ]);
* ?>
* ```
*
*
* Pair this with submitForm for quick testing magic.
*
*
* ``` php
* <?php
* $form = [
@ -1247,7 +1247,7 @@ trait AcceptanceTesterActions
* $I->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
* <?php
* $I->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
* <?php
* $I->dontSeeInFormFields('.form-class', [
@ -1287,7 +1287,7 @@ trait AcceptanceTesterActions
* ```
*
* Additionally, checkbox values can be checked with a boolean.
*
*
* ``` php
* <?php
* $I->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
* <?php
* $I->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
* <?php
* $I->dontSeeInFormFields('.form-class', [
@ -1335,7 +1335,7 @@ trait AcceptanceTesterActions
* ```
*
* Additionally, checkbox values can be checked with a boolean.
*
*
* ``` php
* <?php
* $I->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
* <?php
* $I->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
* <?php
@ -1566,23 +1576,23 @@ trait AcceptanceTesterActions
*
* Grabs either the text content, or attribute values, of nodes
* matched by $cssOrXpath and returns them as an array.
*
*
* ```html
* <a href="#first">First</a>
* <a href="#second">Second</a>
* <a href="#third">Third</a>
* ```
*
*
* ```php
* <?php
* // would return ['First', 'Second', 'Third']
* $aLinkText = $I->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
* <?php
@ -2365,7 +2379,8 @@ trait AcceptanceTesterActions
* });
* ```
*
* This runs in the context of the [RemoteWebDriver class](https://github.com/facebook/php-webdriver/blob/master/lib/remote/RemoteWebDriver.php).
* This runs in the context of the
* [RemoteWebDriver class](https://github.com/facebook/php-webdriver/blob/master/lib/remote/RemoteWebDriver.php).
* Try not to use this command on a regular basis.
* If Codeception lacks a feature you need, please implement it and submit a patch.
*
@ -2526,7 +2541,8 @@ trait AcceptanceTesterActions
* [!] Method is generated. Documentation taken from corresponding module.
*
* Move mouse over the first element matched by the given locator.
* If the second and third parameters are given, then the mouse is moved to an offset of the element's top-left corner.
* If the second and third parameters are given,
* then the mouse is moved to an offset of the element's top-left corner.
* Otherwise, the mouse is moved to the center of the element.
*
* ``` php
@ -2567,7 +2583,8 @@ trait AcceptanceTesterActions
* Pauses test execution in debug mode.
* To proceed test press "ENTER" in console.
*
* This method is useful while writing tests, since it allows you to inspect the current page in the middle of a test case.
* This method is useful while writing tests,
* since it allows you to inspect the current page in the middle of a test case.
* @see \Codeception\Module\WebDriver::pauseExecution()
*/
public function pauseExecution() {
@ -2668,7 +2685,8 @@ trait AcceptanceTesterActions
* [!] Method is generated. Documentation taken from corresponding module.
*
* Move to the middle of the given element matched by the given locator.
* Extra shift, calculated from the top-left corner of the element, can be set by passing $offsetX and $offsetY parameters.
* Extra shift, calculated from the top-left corner of the element,
* can be set by passing $offsetX and $offsetY parameters.
*
* ``` php
* <?php
@ -2697,7 +2715,7 @@ trait AcceptanceTesterActions
* ?>
* ```
*
* @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
* <?php
* $I->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
* <?php
* $I->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
* <?php
* $I->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
* <?php
* $I->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
* <?php
* $mail = $I->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()));
}
}

View File

@ -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
- \Helper\Acceptance