diff --git a/VERSIONS_HOTLINE/199136 b/VERSIONS_HOTLINE/199136 new file mode 100644 index 0000000000000000000000000000000000000000..a9c42988cbd901065cea7f9e6e7e84353c9d4623 --- /dev/null +++ b/VERSIONS_HOTLINE/199136 @@ -0,0 +1 @@ + - correctif #199136 : Payfip : Tableau de bord : Les transactions qui n'ont plus d'identifiants SIGB ne sont plus considérées comme non synchronisées -> plus d'alerte mail, le journal des transactions est affiché par date de création. \ No newline at end of file diff --git a/application/modules/admin/controllers/PayfipController.php b/application/modules/admin/controllers/PayfipController.php index a78cb6a6b2f6247c4227fa9b9d9ca222b41e7b79..dead9336c2b49fe3efa5c68dbef26c24b20db5cc 100644 --- a/application/modules/admin/controllers/PayfipController.php +++ b/application/modules/admin/controllers/PayfipController.php @@ -34,7 +34,7 @@ class Admin_PayfipController extends ZendAfi_Controller_Action { protected function _getSearch() : ZendAfi_Controller_Action_Helper_Search{ $params = $this->_request->getParams(); - $params['search_order'] = $this->_request->getParam('search_order', 'result,created_at desc'); + $params['search_order'] = $this->_request->getParam('search_order', 'created_at desc'); return $this->_helper ->search([], diff --git a/cosmogramme/sql/patch/patch_461.php b/cosmogramme/sql/patch/patch_461.php new file mode 100644 index 0000000000000000000000000000000000000000..6a220ff3db325225532ea8d1b76501096af204ad --- /dev/null +++ b/cosmogramme/sql/patch/patch_461.php @@ -0,0 +1,7 @@ +<?php +$adapter = Zend_Db_Table_Abstract::getDefaultAdapter(); + +try { + $adapter->query( 'UPDATE `payfip` set sigb_status=-2 where bib_id is null'); +} catch(Exception $e) { +} diff --git a/library/Class/Payfip.php b/library/Class/Payfip.php index ea74fefce12fa1e44e879ed074fc1163b80a203b..41e5cf635444627ce467a028c165c0e3aea71514 100644 --- a/library/Class/Payfip.php +++ b/library/Class/Payfip.php @@ -22,7 +22,7 @@ class PayfipLoader extends Storm_Model_Loader { use Trait_Translator; - public function newWith(string $client_id, Class_Users $user, string $amount, string $reference, array $debts ): Class_Payfip_PaymentResult { + public function newWith(string $client_id, Class_Users $user, string $amount, string $reference, array $debts, bool $without_ils=false ): Class_Payfip_PaymentResult { if (! $client_id) $client_id = (new Class_AdminVar_Payfip)->clientId(); @@ -32,12 +32,19 @@ class PayfipLoader extends Storm_Model_Loader { 'reference' => $reference, 'debts' => $debts]); $payment->setObject($this->_('Paiement prestations %s', $payment->getReference())); + if ($without_ils) + $payment->setWithoutIls(); return $payment->save() ? new Class_Payfip_PaymentSuccess($payment) : new Class_Payfip_PersistenceFailure; } + public function newWithoutIls(string $client_id, Class_Users $user, string $amount, string $reference, array $debts ): Class_Payfip_PaymentResult { + return static::newWith( $client_id, $user, $amount, $reference, $debts); + } + + public function findForTest() : ?Class_Payfip { if (!$user = Class_Users::getIdentity()) return null; @@ -120,7 +127,9 @@ class PayfipLoader extends Storm_Model_Loader { return [ Class_Payfip::SIGB_OK => $this->_('OK'), + Class_Payfip::SIGB_NA => $this->_('N/A'), Class_Payfip::SIGB_UNKNOWN => $this->_('Inconnu'), + Class_Payfip::SIGB_CANCELED => $this->_('Annulé'), Class_Payfip::SIGB_ERROR => $this->_('Erreur'), ]; } @@ -168,7 +177,7 @@ class PayfipLoader extends Storm_Model_Loader { $amount = (int)$last_test->getAmount() + 100; $reference = (int)$last_test->getReference() + 1; - $payment_response = Class_Payfip::newWith($client_id, $last_test->getUser(),(string)$amount,(string)$reference, []); + $payment_response = Class_Payfip::newWithoutIls($client_id, $last_test->getUser(),(string)$amount,(string)$reference, []); return $payment_response->payfip(); } } @@ -186,9 +195,11 @@ class Class_Payfip extends Storm_Model_Abstract { const RESULT_ERROR = 'E'; const RESULT_UNKNOWN = ''; - const SIGB_OK = 1; + const SIGB_NA = -2; const SIGB_ERROR = -1; const SIGB_UNKNOWN = 0; + const SIGB_OK = 1; + const SIGB_CANCELED = 2; const TEST_MODE = 'testMode'; const TEST_MODE_ENABLED = 1; @@ -228,9 +239,9 @@ class Class_Payfip extends Storm_Model_Abstract { $_has_many = ['debts' => ['model' => Class_Debt::class, 'role' => 'payfip', 'dependents' => 'delete']] - ; + public function beforeSave() { if (!$this->isNew()) return; @@ -283,17 +294,23 @@ class Class_Payfip extends Storm_Model_Abstract { public function canBeSynchronized() : bool { - return $this->getReference() && !$this->isSigbStatusOk(); + if (($this->withoutIls() && ($this->isResultUnknown() + || $this->isResultError()))) + return true; + return ($this->withIls() && ( $this->getReference() && !$this->isSigbStatusOk())); } public function isResultCanceled() : bool { - return in_array($this->getResult(), ['', static::RESULT_CANCELED], true); + return $this->getResult() == static::RESULT_CANCELED; } public function canBeCancelled() : bool { - return $this->isResultUnknown() || ( $this->isResultCanceled() && $this->isSigbOnError()); + if ($this->withoutIls()) + return false; + return $this->isResultUnknown() + || ( $this->isResultCanceled() && $this->isSigbOnError()); } @@ -328,15 +345,33 @@ class Class_Payfip extends Storm_Model_Abstract { protected function _updatePaymentResult( Class_Payfip_PaymentResult $payment_result) : self { - $payment_result->isValid() + if ($payment_result->isCanceled()) + return $this->beSigbCanceled(); + + return ($payment_result->isValid()) ? $this->beSigbSynched() : $this->beSigbError($payment_result->error()); + } - return $this; + + protected function withoutIls(): bool { + return $this->getSigbStatus()==static::SIGB_NA; + } + + + protected function withIls(): bool { + return $this->getSigbStatus()!=static::SIGB_NA; + } + + + public function setWithoutIls(): self { + return $this->setSigbStatus(Class_Payfip::SIGB_NA); } public function updateSigb() : self { + if($this->withoutIls()) + return $this; if ($this->isResultUnknown() || $this->isResultError() || $this->isSigbStatusOk()) @@ -442,6 +477,16 @@ class Class_Payfip extends Storm_Model_Abstract { } + public function beSigbCanceled() : self { + return $this->setSigbStatus(static::SIGB_CANCELED); + } + + + public function isSigbStatusCanceled() : bool { + return static::SIGB_CANCELED == $this->getSigbStatus(); + } + + public function isSigbStatusUnknown() : bool { return static::SIGB_UNKNOWN === $this->getSigbStatus(); } @@ -483,10 +528,10 @@ class Class_Payfip extends Storm_Model_Abstract { public function renderClassForJournal() : array { $special_class = ''; - if ($this->isResultUnknown()|| $this->isResultError()) + if ($this->isResultUnknown()|| $this->isResultError() ||$this->isSigbStatusError()) $special_class = 'error'; - if ($this->getResultLabel() == 'Annulé' ) + if ( $this->isSigbStatusCanceled() || $this->isResultCanceled()) $special_class = 'warning'; return $special_class @@ -499,7 +544,8 @@ class Class_Payfip extends Storm_Model_Abstract { $userpayment = new Class_User_Payment($this->getUser()); $this->beCanceled(); $this->save(); - return $this->endSigb(); + $payment_result = $this->endSigb(); + return $payment_result; } diff --git a/library/Class/Payfip/PaymentResult.php b/library/Class/Payfip/PaymentResult.php index 36f662086e7b5c1d221c895a098a70c87de3157d..a64ef377c56cc3c902e0b314af1fad2326a504e4 100644 --- a/library/Class/Payfip/PaymentResult.php +++ b/library/Class/Payfip/PaymentResult.php @@ -48,4 +48,9 @@ abstract class Class_Payfip_PaymentResult { public function sendMail(): self { return $this; } + + + public function isCanceled(): bool { + return false; + } } diff --git a/library/Class/Payfip/SigbError.php b/library/Class/Payfip/SigbError.php index 6bb98acdaf0d3c8bf5b9b2e24577eafc0793711b..5b3c17699bdd38863225c25add86ed56790cb5df 100644 --- a/library/Class/Payfip/SigbError.php +++ b/library/Class/Payfip/SigbError.php @@ -24,7 +24,7 @@ class Class_Payfip_SigbError extends Class_Payfip_PaymentError { protected string $_error_message; protected string $_error_code; - + const TRANSACTION_NOT_FOUND='TransactionNotFoundForPaymentId'; public function __construct(string $error_code,string $error_message) { $this->_error_code = $error_code; $this->_error_message = $error_message; @@ -36,6 +36,13 @@ class Class_Payfip_SigbError extends Class_Payfip_PaymentError { } + public function isCanceled(): bool { + if ($this->_error_code == static::TRANSACTION_NOT_FOUND) + return true; + return parent::isCanceled(); + } + + public function errorCode() : string{ return $this->_error_code; } diff --git a/tests/db/UpgradeDBTest.php b/tests/db/UpgradeDBTest.php index b39ef3c1c032ebee6442ff505f645beacdf46fed..70bf7b5c2c74e0c3bd6c23b3d037313833f1a6bc 100644 --- a/tests/db/UpgradeDBTest.php +++ b/tests/db/UpgradeDBTest.php @@ -5614,15 +5614,14 @@ class UpgradeDB_459_Test extends UpgradeDBTestCase { - class UpgradeDB_460_Test extends UpgradeDBTestCase { protected $_client_id; public function prepare(){ if (!$this->_client_id = Class_AdminVar::get('PAYFIP_CLIENT_ID')) Class_AdminVar::set('PAYFIP_CLIENT_ID', 'TESTID'); + $this->query("insert into payfip(id_op, user_id, reference, amount,paid_on, result) values ('toto', 336,'1234767889', 1634, '2023-06-01 12:00:28','C')"); - $this->silentQuery('alter table payfip drop client_id;'); } @@ -5647,3 +5646,34 @@ class UpgradeDB_460_Test extends UpgradeDBTestCase { $this->assertEquals(Class_AdminVar::get('PAYFIP_CLIENT_ID'), $data['client_id']); } } + + + + +class UpgradeDB_461_Test extends UpgradeDBTestCase { + + public function prepare(){ + $this->query("insert into payfip(id_op, user_id, reference, amount,paid_on, result) values ('toto', 336,'1234767889', 1634, '2023-06-01 12:00:28','C')"); + $this->query("insert into payfip(id_op, bib_id,user_id, reference, amount,paid_on, result) values ('toto with bib',1, 336,'1234767889', 1634, '2023-06-01 12:00:28','C')"); + } + + + public function tearDown() { + $this->query('delete from payfip where reference="1234767889" and id_op="toto";'); + parent::tearDown(); + } + + + /** @test */ + public function sigbStatusShouldBeSetForNonBibIdPayfip() { + $data = $this->query('select sigb_status from payfip where id_op="toto"')->fetch(); + $this->assertEquals(-2, $data['sigb_status']); + } + + + /** @test */ + public function sigbStatusShouldNotBeSetWithBibIdPayfip() { + $data = $this->query('select sigb_status from payfip where id_op="toto with bib"')->fetch(); + $this->assertEquals(0, $data['sigb_status']); + } +} diff --git a/tests/scenarios/Payfip/PayfipBatchTest.php b/tests/scenarios/Payfip/PayfipBatchTest.php index 251382ba51861e68ee51a2241b13ddeb5bfb7ecd..428fbcaace96ecefe4e5d559a88a5938a1587b13 100644 --- a/tests/scenarios/Payfip/PayfipBatchTest.php +++ b/tests/scenarios/Payfip/PayfipBatchTest.php @@ -22,7 +22,6 @@ require_once __DIR__ . '/PayfipFixtures.php'; require_once __DIR__ . '/PayfipMockNanookClient.php'; - class PayfipBatchDisabledTest extends ModelTestCase { protected string $_log = ''; @@ -57,7 +56,6 @@ abstract class PayfipBatchEnabledTestCase extends ModelTestCase { protected string $_debug_log = ''; protected MockMailTransport $_mail_transport; - public function setUp() { parent::setUp(); $this->_mail_transport = new MockMailTransport(); @@ -121,11 +119,13 @@ abstract class PayfipBatchSigbUnknownTestCase extends ModelTestCase { $this->fixture(Class_Payfip::class, ['id' => 1, + 'bib_id' => 20, 'reference' => '99939', 'type' => 'payfip-test', 'id_op' => '99I88I', 'amount' => 2882, 'user' => Class_Users::find(336), + 'bib_id' => 20, 'result' => Class_Payfip::RESULT_PAYED_BY_CB, 'sigb_status' => Class_Payfip::SIGB_UNKNOWN, ]); @@ -223,7 +223,7 @@ class PayfipBatchPaidByCbSigbUnknownWithEndPaymentErrorTest 'paymentType' => 'CB', 'paymentDate' => '', 'paymentInfo' => 'Référence commande : 99939'])) - ->answerFile('endPaymentResponseTransactionNotFound.xml'); + ->answerFile('endPaymentResponseTechnicalError.xml'); } @@ -241,7 +241,55 @@ class PayfipBatchPaidByCbSigbUnknownWithEndPaymentErrorTest /** @test */ public function debugLogShouldContainsStatusChangeDescription() { - $this->assertContains('[Payfip] Transaction (ref: 99939, idop: 99I88I) en erreur SIGB : Aucun paiement en cours trouvé pour la référence fournie', + $this->assertContains('[Payfip] Transaction (ref: 99939, idop: 99I88I) en erreur SIGB : Une erreur inconnue est survenue', + $this->_debug_log); + } + + + /** @test */ + public function logShouldContainsJobsGlobalDescription() { + $this->assertContains('Synchronisation des transactions Payfip dont le résultat est inconnu +Aucune transaction à synchroniser +Synchronisation des transactions Payfip avec le SIGB +Une transaction synchronisée', + $this->_log); + } +} + + + + +class PayfipBatchPaidByCbSigbUnknownWithTransactionNotFoundTest + extends PayfipBatchSigbUnknownTestCase { + + protected function _prepareFixtures() { + $this->_nanook_client + ->onPostData('EndPayment/patronId/336', + http_build_query(['totalAmount' => '28.82', + 'paymentId' => '99939', + 'status' => 'Accepted', + 'paymentType' => 'CB', + 'paymentDate' => '', + 'paymentInfo' => 'Référence commande : 99939'])) + ->answerFile('endPaymentResponseTransactionNotFound.xml'); + } + + + /** @test */ + public function shouldBeSigbStatusCanceled() { + $this->assertEquals(Class_Payfip::SIGB_CANCELED ,$this->_payment->getSigbStatus()); + } + + + /** @test */ + public function sigbLastCallShouldBeToday() { + $this->assertEquals('2023-02-07 11:43:35', $this->_payment->getSigbLastCallDate()); + } + + + /** @test */ + public function debugLogShouldContainsStatusChangeDescriptionSynchronized() { + $this->assertContains('[Payfip] Transaction (ref: 99939, idop: 99I88I) synchronisée', $this->_debug_log); } @@ -319,6 +367,7 @@ class PayfipBatchPayfipWebserviceErrorWithJournalTest extends PayfipBatchEnabled 'id_op' => '99I88I', 'amount' => 2882, 'user' => Class_Users::find(336), + 'bib_id' => 20, 'result' => Class_Payfip::RESULT_UNKNOWN, 'sigb_status' => Class_Payfip::SIGB_UNKNOWN, ]); @@ -354,6 +403,7 @@ class PayfipBatchPayfipWebserviceReturnsHtmlWithJournalTest extends PayfipBatchE 'reference' => '08437980', 'id_op' => '99I88I', 'user' => Class_Users::find(336), + 'bib_id' => 20, 'result' => Class_Payfip::RESULT_UNKNOWN, 'sigb_status' => Class_Payfip::SIGB_UNKNOWN, ]); @@ -382,12 +432,12 @@ class PayfipBatchPayfipWebserviceReturnsHtmlWithJournalTest extends PayfipBatchE abstract class PayfipBatchPayfipWebserviceReturnsOKTestCase extends PayfipBatchEnabledTestCase { protected string $_response_file; - protected function _prepareFixture() { $this->fixture(Class_Payfip::class, ['id' => 1, 'type' => 'payfip-test', 'user_id' => 336, + 'bib_id' => 20, 'reference' => '08937498', 'amount' => 8839, 'id_op' => '99I88I', @@ -395,8 +445,6 @@ abstract class PayfipBatchPayfipWebserviceReturnsOKTestCase extends PayfipBatchE 'sigb_status' => Class_Payfip::SIGB_UNKNOWN, ]); - - $response = str_replace('{ID_OP}', 'toto', file_get_contents(__DIR__.'/'.$this->_response_file)); @@ -407,6 +455,7 @@ abstract class PayfipBatchPayfipWebserviceReturnsOKTestCase extends PayfipBatchE + class PayfipBatchRefreshReturnPaidPaymentSigbErrorTest extends PayfipBatchPayfipWebserviceReturnsOKTestCase { @@ -421,6 +470,7 @@ class PayfipBatchRefreshReturnPaidPaymentSigbErrorTest 'reference' => '098764321', 'amount' => 8839, 'id_op' => '99I88I', + 'bib_id'=> 20, 'result' => Class_Payfip::RESULT_UNKNOWN, 'sigb_status' => Class_Payfip::SIGB_UNKNOWN, ]); @@ -457,18 +507,19 @@ class PayfipBatchRefreshReturnPaidPaymentSigbErrorTest Class_Payfip::find(1)->getSigbStatus()); } + /** @test */ - public function payfipMailShouldBeSent(){ - $this->assertEquals( 'admin@mybib.fr', $this->_mail_transport->sent_mail - ->getRecipients()[0]); + public function payfipMailShouldBeSent(){ + $this->assertEquals( 'admin@mybib.fr', $this->_mail_transport->sent_mail + ->getRecipients()[0]); } - /** @test */ + /** @test */ public function payfipBodyMailShouldBeSentWith2Errors(){ $this->assertContains( 'Transaction (ref: 08937498', quoted_printable_decode($this->_mail_transport->sent_mail->getBodyHtml(true))); $this->assertContains( 'Transaction (ref: 098764321', $this->_mail_transport->sent_mail - ->getBodyHtml(true)); + ->getBodyHtml(true)); } @@ -491,15 +542,16 @@ class PayfipBatchRefreshReturnPaidPaymentSigbKOTest parent::_prepareFixture(); $this->fixture(Class_Payfip::class, - ['id' => 2, - 'type' => 'payfip-test', - 'user_id' => 336, - 'reference' => '098764321', - 'amount' => 8839, - 'id_op' => '99I88I', - 'result' => Class_Payfip::RESULT_PAYED_BY_CB, - 'sigb_status' => Class_Payfip::SIGB_ERROR, - ]); + ['id' => 2, + 'type' => 'payfip-test', + 'user_id' => 336, + 'reference' => '098764321', + 'amount' => 8839, + 'bib_id' => 20, + 'id_op' => '99I88I', + 'result' => Class_Payfip::RESULT_PAYED_BY_CB, + 'sigb_status' => Class_Payfip::SIGB_ERROR, + ]); Class_Webservice_SIGB_Nanook_Service::shouldThrowError(false); Class_AdminVar::set(Class_AdminVar_Payfip::ERROR_MAIL_RECIPIENT,'admin@mybib.fr'); @@ -513,7 +565,7 @@ class PayfipBatchRefreshReturnPaidPaymentSigbKOTest 'paymentDate' => '', 'paymentInfo' => 'Référence commande : 098764321'])) ->answerFile('endPaymentResponseSuccess.xml'); -; + ; } @@ -525,6 +577,7 @@ class PayfipBatchRefreshReturnPaidPaymentSigbKOTest + class PayfipBatchRefreshReturnPaidPaymentSigbOKTest extends PayfipBatchPayfipWebserviceReturnsOKTestCase { diff --git a/tests/scenarios/Payfip/PayfipDashboardTest.php b/tests/scenarios/Payfip/PayfipDashboardTest.php index f7228baf360149c507badad185afecc8574181f0..f882a5b7065ade586604f39fab1c881b43de23d4 100644 --- a/tests/scenarios/Payfip/PayfipDashboardTest.php +++ b/tests/scenarios/Payfip/PayfipDashboardTest.php @@ -147,7 +147,6 @@ class PayfipDashboardDisplayAdminPortailTest extends PayfipDashboardTestCase { parent::setUp(); Class_Users::getIdentity() ->changeRoleTo(ZendAfi_Acl_AdminControllerRoles::ADMIN_PORTAIL); - $this->dispatch('/admin/payfip/index'); } diff --git a/tests/scenarios/Payfip/PayfipEndPaymentTest.php b/tests/scenarios/Payfip/PayfipEndPaymentTest.php index 5decccfa97481828dca798d5bb93e32883910638..93041fbee4cab9d76ae53cd00d12c916c42b9db1 100644 --- a/tests/scenarios/Payfip/PayfipEndPaymentTest.php +++ b/tests/scenarios/Payfip/PayfipEndPaymentTest.php @@ -78,6 +78,7 @@ class PayfipEndPaymentValidTest extends ModelTestCase { ['id' => 1, 'id_op' => 'toto', 'user' => $user, + 'bib' => $user->getBib(), 'reference'=> '1234767889', 'amount' => 1634, 'paid_on' => '2023-06-01 12:00:28', diff --git a/tests/scenarios/Payfip/PayfipPermissionTest.php b/tests/scenarios/Payfip/PayfipPermissionTest.php index dc6b49a1c0b141282fc8ad4ec32e2d8b8f272a17..a8900e15ba1d917b585f053f3d7c605954ce4b66 100644 --- a/tests/scenarios/Payfip/PayfipPermissionTest.php +++ b/tests/scenarios/Payfip/PayfipPermissionTest.php @@ -87,10 +87,10 @@ abstract class PayfipPermissionsTestCase extends Admin_AbstractControllerTestCas '122344433444')->setPaidOn('')->save(); $this->getPaymentWithIdOp(3, $this->createUserForSite(3, 'hara', $this->getBibCran()), - '122343344444')->setPaidOn('2012-02-24 12:00:00')->setResult('P')->save(); + '122343344444')->setPaidOn('2012-02-24 12:00:00')->setResult(Class_Payfip::RESULT_PAYED_BY_CB)->save(); $this->getPaymentWithIdOp(4, $this->createUserForSite(4, 'kiri', $this->getBibAnnecy()), - '122343344444')->setPaidOn('2023-02-24 12:00:00')->setResult('P')->save(); + '122343344444')->setPaidOn('2023-02-24 12:00:00')->setResult(Class_Payfip::RESULT_PAYED_BY_CB)->save(); $this->getPaymentWithIdOp(5, $this->createUserForSite(4, 'kiri', $this->getBibAnnecy()), @@ -103,7 +103,7 @@ abstract class PayfipPermissionsTestCase extends Admin_AbstractControllerTestCas $this->getPaymentWithIdOp(6, $this->createUserForSite(4, 'kiri', $this->getBibAnnecy()), '122343344444') - ->setResult('') + ->setResult(Class_Payfip::RESULT_ERROR) ->setReference('abg567j') ->setObject('Un sujet - avec, des caractères non alpha') ->setPayfipLastError('{"label":"La valeur de l\' OBJET est incorrecte.","code":"O1","severity":"2"}') @@ -112,14 +112,15 @@ abstract class PayfipPermissionsTestCase extends Admin_AbstractControllerTestCas $this->getPaymentWithIdOp(7, $this->createUserForSite(4, 'kiri', $this->getBibAnnecy()), '122343344445') - ->setResult('A') + ->setResult(Class_Payfip::RESULT_CANCELED) ->setReference('abg891j') ->setObject('Un sujet - avec, des caractères non alpha') ->setPayfipLastError('{"label":"La valeur de l\' OBJET est incorrecte.","code":"O1","severity":"2"}') ->save(); $this->getPaymentWithIdOp(8, $this->createUserForSite(4, 'kiri', $this->getBibAnnecy()), - '122343344444')->setReference('myref')->setPaidOn('2023-02-24 12:00:00')->setResult('P')->setSigbError('Unknown')->setSigbStatus(Class_Payfip::SIGB_ERROR)->save(); + '122343344444')->setReference('myref')->setPaidOn('2023-02-24 12:00:00')->setResult(Class_Payfip::RESULT_PAYED_BY_CB)->setSigbError('Unknown')->setSigbStatus(Class_Payfip::SIGB_ERROR)->save(); + Class_Users::getIdentity() ->changeRoleTo(ZendAfi_Acl_AdminControllerRoles::ADMIN_BIB) @@ -180,12 +181,12 @@ class PayfipPermissionAdminBibTransactionsDispatchTest } + /** @test */ - public function payfipFirstLineStatusShouldBeInconnu() { - $this->assertXPath('//table[@id="payfip_table"]//tr[1][@class="error"]//td[. = "Inconnu"]'); + public function payfipFirstLineStatusShouldBeCBPayed() { + $this->assertXPathContentContains('//table[@id="payfip_table"]//tr[1]//td', "CB"); } - /** @test */ public function payfipSecondLineStatusShouldBeInconnu() { $this->assertXPath('//table[@id="payfip_table"]//tr[2][@class="error"]//td[. = "Inconnu"]'); @@ -199,8 +200,14 @@ class PayfipPermissionAdminBibTransactionsDispatchTest /** @test */ - public function payfipThirdLineStatusShouldBeAnnulé() { - $this->assertXPath('//table[@id="payfip_table"]//tr[3][@class="warning"]//td[. = "Annulé"]'); + public function payfipFourthLineStatusShouldBeAnnulé() { + $this->assertXPath('//table[@id="payfip_table"]//tr[4][@class="warning"]//td[. = "Annulé"]'); + } + + + /** @test */ + public function payfipFifthLineStatusShouldHaveErrorClass() { + $this->assertXPath('//table[@id="payfip_table"]//tr[5][@class="error"]//td[. = "Erreur"]'); } @@ -253,8 +260,8 @@ class PayfipPermissionAdminBibTransactionsDispatchTest /** @test */ - public function tableShouldContains2ActionCancel() { - $this->assertXPathCount('//tr/td/div[@class="actions"]/a[contains(@href,"/admin/payfip/cancel/")]', 2); + public function tableShouldContains1ActionCancel() { + $this->assertXPathCount('//tr/td/div[@class="actions"]/a[contains(@href,"/admin/payfip/cancel/")]', 1); } @@ -299,7 +306,7 @@ class PayfipPermissionAdminBibTransactionsSearchDispatchTest ->assertSave(); $this->dispatch('/admin/payfip/transactions?' - . http_build_query(['search_result' =>'P', + . http_build_query(['search_result' =>Class_Payfip::RESULT_PAYED_BY_CB, 'search_paid_on_start' => '2021/02/02'])); } diff --git a/tests/scenarios/Payfip/endPaymentResponseTechnicalError.xml b/tests/scenarios/Payfip/endPaymentResponseTechnicalError.xml new file mode 100644 index 0000000000000000000000000000000000000000..0a62d25dd05b38a1a11cd3e77e06fa8a5065a385 --- /dev/null +++ b/tests/scenarios/Payfip/endPaymentResponseTechnicalError.xml @@ -0,0 +1,2 @@ +<?xml version="1.0" encoding="UTF-8"?> +<EndPayment><error>EndPaymentTechnicalError</error></EndPayment>