From 795f0a77c963c2bbfa20836479971a96dd6f4f77 Mon Sep 17 00:00:00 2001 From: Thomas Zilio Date: Sat, 13 Oct 2018 14:21:35 +0200 Subject: [PATCH] Miglioramento controlli automatici --- tests/acceptance/AnagraficheCest.php | 28 +++++++++++++++++--- tests/acceptance/FattureCest.php | 39 ++++++++++++++++++++++++++-- 2 files changed, 61 insertions(+), 6 deletions(-) diff --git a/tests/acceptance/AnagraficheCest.php b/tests/acceptance/AnagraficheCest.php index 6b042190e..00be001e3 100644 --- a/tests/acceptance/AnagraficheCest.php +++ b/tests/acceptance/AnagraficheCest.php @@ -52,7 +52,7 @@ class AnagraficheCest } /** - * Crea una nuova anagrafica di tipo cliente. + * Crea una nuova anagrafica di tipo Cliente. * * @param AcceptanceTester $t */ @@ -62,7 +62,7 @@ class AnagraficheCest } /** - * Crea una nuova anagrafica di tipo cliente. + * Crea una nuova anagrafica di tipo Tecnico. * * @param AcceptanceTester $t */ @@ -72,12 +72,32 @@ class AnagraficheCest } /** - * Crea una nuova anagrafica di tipo cliente. + * Crea una nuova anagrafica di tipo Fornitore. * * @param AcceptanceTester $t */ public function testAnagraficaFornitore(AcceptanceTester $t) { - $this->addAnag($t, 'Fornitore', 3, '05024030289'); + $this->addAnag($t, 'Fornitore', 4, '05024030289'); + } + + /** + * Crea una nuova anagrafica di tipo Vettore. + * + * @param AcceptanceTester $t + */ + public function testAnagraficaVettore(AcceptanceTester $t) + { + $this->addAnag($t, 'Vettore', 5, '05024030289'); + } + + /** + * Crea una nuova anagrafica di tipo Agente. + * + * @param AcceptanceTester $t + */ + public function testAnagraficaAgente(AcceptanceTester $t) + { + $this->addAnag($t, 'Agente', 6, '05024030289'); } } diff --git a/tests/acceptance/FattureCest.php b/tests/acceptance/FattureCest.php index 3c14da2d3..b637a28d1 100644 --- a/tests/acceptance/FattureCest.php +++ b/tests/acceptance/FattureCest.php @@ -49,7 +49,7 @@ class FattureCest $t->see('Anagrafica eliminata!', '.alert-success'); } - protected function addRow(AcceptanceTester $t, $descrizione, $qta, $prezzo, $iva = null) + protected function addRow(AcceptanceTester $t, $descrizione, $qta, $prezzo, $sconto = 0, $tipo_sconto = 'UNT', $id_iva = null, $id_rivalsa_inps = null, $id_ritenuta_acconto = null) { // Apre il modal $t->clickAndWaitModal('Riga', '#tab_0'); @@ -59,6 +59,25 @@ class FattureCest $t->fillField('Q.tà', $qta); $t->fillField('Costo unitario', $prezzo); + if (!empty($sconto)) { + $t->fillField('Sconto unitario', $sconto); + + if (in_array($tipo_sconto, ['PRC', 'UNT'])) { + $t->select2ajax('#tipo_sconto', $tipo_sconto); + } + } + + if ($id_iva) { + $t->select2('#idiva', $id_iva); + } + + if ($id_rivalsa_inps) { + $t->select2('#id_rivalsa_inps', $id_rivalsa_inps); + } + if ($id_ritenuta_acconto) { + $t->select2('#id_ritenuta_acconto', $id_ritenuta_acconto); + } + // Effettua il submit $t->clickAndWait('Aggiungi', '.modal'); @@ -66,6 +85,11 @@ class FattureCest $t->see('Riga aggiunta'); } + protected function getFinalValue($type) + { + return "//div[@class='panel-heading' and contains(string(), 'Righe')]/parent::*//table//tr[contains(string(), '".strtoupper($type)."')]//td[2]"; + } + protected function checkImporti(AcceptanceTester $t) { $this->addRow($t, 'Riga 1', 1, 34); @@ -75,7 +99,18 @@ class FattureCest $this->addRow($t, 'Riga 5', 1, 104.90); $this->addRow($t, 'Riga 6', 1, 2); - $t->seeInSource('259,05'); + $t->see("212,34", $this->getFinalValue('Imponibile')); + $t->see("46,71", $this->getFinalValue('IVA')); + $t->see("259,05", $this->getFinalValue('Totale')); + + $this->addRow($t, 'Riga 7 con sconto in euro', 15, 12, 2); + $this->addRow($t, 'Riga 8 con sconto percentuale', 15, 10, 20, 'PRC'); + + $t->see("542,34", $this->getFinalValue('Imponibile')); + $t->see("60,00", $this->getFinalValue('Sconto')); + $t->see("482,34", $this->getFinalValue('Imponibile scontato')); + $t->see("106,11", $this->getFinalValue('IVA')); + $t->see("588,45", $this->getFinalValue('Totale')); } /**