diff --git a/VERSIONS_HOTLINE/137875 b/VERSIONS_HOTLINE/137875 new file mode 100644 index 0000000000000000000000000000000000000000..9ee3c2938bca314fece38579dc0f06e7a1f1df3f --- /dev/null +++ b/VERSIONS_HOTLINE/137875 @@ -0,0 +1 @@ +- hotline #137875 Administration : tableau de bord PNB, correction du tri sur certaines colonnes \ No newline at end of file diff --git a/library/Class/Album/UsageReport.php b/library/Class/Album/UsageReport.php index 835da0c1d51e5fcdc3032bbb7ea1f49e54664ea0..5e57c015e7110b082f563b08729408728842722c 100644 --- a/library/Class/Album/UsageReport.php +++ b/library/Class/Album/UsageReport.php @@ -24,20 +24,8 @@ class Class_Album_UsageReport extends Storm_Model_Abstract { protected $_table_name = 'album_usage_report', - $_belongs_to = ['item' => ['model' => 'Class_Album_Item', - 'referenced_in' => 'item_id']], - $_overrided_attributes = ['id', - 'item_id', - 'title', - 'loan_quantity', - 'total_quantity', - 'live_quantity', - 'hold_count', - 'duration', - 'license_expiration', - 'order_date', - 'genres', - 'sections']; + $_belongs_to = ['item' => ['model' => Class_Album_Item::class, + 'referenced_in' => 'item_id']]; public function isInfiniteLoan() { diff --git a/library/Class/TableDescription/PNBLoansHistory.php b/library/Class/TableDescription/PNBLoansHistory.php index 04cc182269b455f8bb1641661e7480e90f1291cf..83b130a1e133cf8c4e5aebeda5aedb9daf8878ab 100644 --- a/library/Class/TableDescription/PNBLoansHistory.php +++ b/library/Class/TableDescription/PNBLoansHistory.php @@ -26,11 +26,16 @@ class Class_TableDescription_PNBLoansHistory extends Class_TableDescription { public function init() { $this ->addColumn($this->_('Date d\'emprunt'), - function($model) { return (new DateTime($model->getLoanDate())) - ->format('d/m/Y');}) + ['callback' => function($model) { + return (new DateTime($model->getLoanDate())) + ->format('d/m/Y'); + }, + 'sort_attribute' => 'loan_date']) ->addColumn($this->_('Date de retour'), - function($model) { return (new DateTime($model->getExpectedReturnDate())) - ->format('d/m/Y');}) + ['callback' => function($model) { + return (new DateTime($model->getExpectedReturnDate())) + ->format('d/m/Y');}, + 'sort_attribute' => 'expected_return_date']) ->addColumn($this->_('Titre'), ['attribute' => 'title', 'sortable' => false]); diff --git a/library/Class/TableDescription/PNBUsages.php b/library/Class/TableDescription/PNBUsages.php index f916ee438d50233a5e642800e4c1b714251a584f..2537475294bf5cfef2fd0666065c7a12335277a9 100644 --- a/library/Class/TableDescription/PNBUsages.php +++ b/library/Class/TableDescription/PNBUsages.php @@ -29,11 +29,15 @@ class Class_TableDescription_PNBUsages extends Class_TableDescription { ->_addLiveLoansColumns() ->addColumn($this->_('Nombre de réservations'), 'hold_count') ->addColumn($this->_('Durée de prêt en jours'), 'duration') - ->addColumn($this->_('Nombre de jours restant sur la licence'), 'license_expiration_or_infinite') + ->addColumn($this->_('Nombre de jours restant sur la licence'), + ['attribute' => 'license_expiration_or_infinite', + 'sort_attribute' => 'license_expiration']) ->addColumn($this->_('Date de commande'), - function($usage) { - return (new DateTime($usage->getOrderDate()))->format('d/m/Y'); - }) + ['callback' => function($usage) { + return (new DateTime($usage->getOrderDate())) + ->format('d/m/Y'); + }, + 'sort_attribute' => 'order_date']) ->_addExtraColumns(); return $this->_getRowActions(); } @@ -55,8 +59,10 @@ class Class_TableDescription_PNBUsages extends Class_TableDescription { protected function _addExtraColumns() { if (Class_AdminVar::get('DILICOM_PNB_BOARD_DISPLAY_SECTION')) - $this->addColumn($this->_('Genre'), 'genre_labels') - ->addColumn($this->_('Section'), 'section_labels'); + $this->addColumn($this->_('Genre'), ['attribute' => 'genre_labels', + 'sortable' => false]) + ->addColumn($this->_('Section'), ['attribute' => 'section_labels', + 'sortable' => false]); return $this; } diff --git a/tests/scenarios/PnbDilicom/PnbDilicomAdminLoansHistoryTest.php b/tests/scenarios/PnbDilicom/PnbDilicomAdminLoansHistoryTest.php new file mode 100644 index 0000000000000000000000000000000000000000..623840553040a9cb55efe99c81b1d4c0f3276961 --- /dev/null +++ b/tests/scenarios/PnbDilicom/PnbDilicomAdminLoansHistoryTest.php @@ -0,0 +1,176 @@ +<?php +/** + * Copyright (c) 2012-2021, Agence Française Informatique (AFI). All rights reserved. + * + * BOKEH is free software; you can redistribute it and/or modify + * it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE as published by + * the Free Software Foundation. + * + * There are special exceptions to the terms and conditions of the AGPL as it + * is applied to this software (see README file). + * + * BOKEH is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU AFFERO GENERAL PUBLIC LICENSE for more details. + * + * You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE + * along with BOKEH; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + +require_once('PnbDilicomAdminTest.php'); + + +abstract class PnbDilicomAdminLoansHistoryTestCase extends PnbDilicomAdminTestCase { + public function setUp() { + parent::setUp(); + + foreach(range(5, 25) as $i) + $this->fixture(Class_Loan_Pnb::class, + ['id' => $i, + 'record_origin_id' => 'Dilicom-3663608260879', + 'subscriber_id' => '000006', + 'user_id' => 4078, + 'expected_return_date' => sprintf('2018-01-%s 13:57:33', + str_pad($i, 2, '0', STR_PAD_LEFT)), + 'loan_date' => sprintf('2017-11-%s 13:57:33', + str_pad($i, 2, '0', STR_PAD_LEFT)), + 'loan_link' => 'https://pnb-dilicom.centprod.com/v2//XXXXXXXX.do', + 'order_line_id' => '584837a045ce56ef0a072a8b']); + } +} + + + + +class PnbDilicomAdminLoansHistoryTest extends PnbDilicomAdminLoansHistoryTestCase { + protected $_search_params = ['search_order' => 'loan_date', + 'search_loan_date_debut' => '10/11/2017', + 'search_loan_date_fin' => '20/11/2017']; + + public function setup() { + parent::setup(); + $this->dispatch('/admin/pnb/loans?' . http_build_query($this->_search_params)); + } + + + /** @test */ + public function pageShouldContainsTopMenu() { + $this->assertXPath('//div[@class="menu"]'); + } + + + /** @test */ + public function h2ShouldBeLoansHistory() { + $this->assertXPathContentContains('//h2', 'Historique des prêts'); + } + + + /** @test */ + public function exportCSVLoansButtonWithParamsShouldBePresent() { + $this->assertXPathContentContains('//button[contains(@data-url, "/admin/pnb/export-loans-csv?' . http_build_query($this->_search_params) . '")]', + 'Exporter le tableau en CSV'); + } + + + /** @test */ + public function pageShouldContainsPaginationWithParamsForPageTwo() { + $this->assertXPath('//div[@class="pager"]//a[contains(@href, "/admin/pnb/loans/search_order/loan_date/search_loan_date_debut/10%2F11%2F2017/search_loan_date_fin/20%2F11%2F2017/search_expected_return_date_debut//search_expected_return_date_fin//page/2")]'); + } + + + /** @test */ + public function tableShouldContainsColumnForTitle() { + $this->assertXPathContentContains('//table//td', 'Hell is from here to eternity'); + } + + + /** @test */ + public function tableShouldContainsColumnForGenre() { + $this->assertNotXPathContentContains('//table//td', 'Heavy Metal; Jazz'); + } + + + /** @test */ + public function tableShouldContainsColumnForSections() { + $this->assertNotXPathContentContains('//table//td', 'Espace métal; Espace jazz'); + } + + + /** @test */ + public function tableShouldContainsColumnForLoanDate() { + $this->assertXPathContentContains('//table//td', '10/11/2017'); + } + + + /** @test */ + public function loanDateColumnShouldBeSortedOnLoanDateAttribute() { + $this->assertXPathContentContains('//table//tr//th/a[contains(text(), "Date d\'emprunt")]/@href', 'search_order=loan_date+desc&'); + } + + + + /** @test */ + public function tableShouldContainsColumnForExpectedReturnDate() { + $this->assertXPathContentContains('//table//td', '10/01/2018'); + } + + + + /** @test */ + public function returnDateColumnShouldBeSortedOnExpectedReturnDateAttribute() { + $this->assertXPathContentContains('//table//tr//th/a[contains(text(), "Date de retour")]/@href', 'search_order=expected_return_date&'); + } + + + + /** @test */ + public function searchFormShouldContainsInputForReturnDateStart() { + $this->assertXPath('//form//fieldset[@id="fieldset-search_group"]//input[@name="search_expected_return_date_debut"]'); + } + + + /** @test */ + public function searchFormShouldContainsInputForReturnDateEnd() { + $this->assertXPath('//form//fieldset[@id="fieldset-search_group"]//input[@name="search_expected_return_date_fin"]'); + } + + + /** @test */ + public function searchFormShouldContainsInputForLoanDateStart() { + $this->assertXPath('//form//fieldset[@id="fieldset-search_group"]//input[@name="search_loan_date_debut"]'); + } + + + /** @test */ + public function searchFormShouldContainsInputForLoanDateEnd() { + $this->assertXPath('//form//fieldset[@id="fieldset-search_group"]//input[@name="search_loan_date_fin"]'); + } +} + + + + +class PnbDilicomAdminLoansHistoryWithDilicomGenreSectionAdminVar extends PnbDilicomAdminLoansHistoryTestCase { + public function setUp() { + parent::setup(); + Class_AdminVar::set('DILICOM_PNB_BOARD_DISPLAY_SECTION',1); + $this->dispatch('/admin/pnb/loans?' + . http_build_query(['search_order' => 'loan_date', + 'search_loan_date_debut' => '10/11/2017', + 'search_loan_date_fin' => '20/11/2017'])); + } + + + /** @test */ + public function tableShouldContainsColumnForGenre() { + $this->assertXPathContentContains('//table//td', 'Heavy Metal; Jazz'); + } + + + /** @test */ + public function tableShouldContainsColumnForSections() { + $this->assertXPathContentContains('//table//td', 'Espace métal; Espace jazz'); + } +} diff --git a/tests/scenarios/PnbDilicom/PnbDilicomAdminTest.php b/tests/scenarios/PnbDilicom/PnbDilicomAdminTest.php index 1190aec59592ebbedf664ce3115fd8202d2518d7..b3d85c64f3cd5ba14af66817319ac97ffeec2e86 100644 --- a/tests/scenarios/PnbDilicom/PnbDilicomAdminTest.php +++ b/tests/scenarios/PnbDilicom/PnbDilicomAdminTest.php @@ -599,6 +599,30 @@ class PnbDilicomAdminSearchUsageTest extends PnbDilicomAdminSearchTestCase { public function exportButtonShouldKeepParams() { $this->assertXPath('//button[contains(@data-url,"/export-csv?' . http_build_query($this->_search_params) . '")]'); } + + + /** @test */ + public function genreColumnShouldNotBeSortable() { + $this->assertXPath('//table//tr//th[text()="Genre"][@data-sorter="false"]'); + } + + + /** @test */ + public function sectionColumnShouldNotBeSortable() { + $this->assertXPath('//table//tr//th[text()="Section"][@data-sorter="false"]'); + } + + + /** @test */ + public function licenceExpirationColumnShouldBeSortedOnLicenseExpirationAttribute() { + $this->assertXPathContentContains('//table//tr//th/a[contains(text(), "restant sur la licence")]/@href', 'search_order=license_expiration&'); + } + + + /** @test */ + public function orderDateColumnShouldBeSortedOrderDateAttribute() { + $this->assertXPathContentContains('//table//tr//th/a[text()="Date de commande"]/@href', 'search_order=order_date&'); + } } @@ -990,145 +1014,3 @@ class PnbDilicomAdminIndexControllerTest extends AbstractControllerTestCase { parent::tearDown(); } } - - - - -abstract class PnbDilicomAdminLoansTestCase extends PnbDilicomAdminTestCase { - public function setUp() { - parent::setUp(); - - foreach(range(5, 25) as $i) - $this->fixture(Class_Loan_Pnb::class, - ['id' => $i, - 'record_origin_id' => 'Dilicom-3663608260879', - 'subscriber_id' => '000006', - 'user_id' => 4078, - 'expected_return_date' => sprintf('2018-01-%s 13:57:33', - str_pad($i, 2, '0', STR_PAD_LEFT)), - 'loan_date' => sprintf('2017-11-%s 13:57:33', - str_pad($i, 2, '0', STR_PAD_LEFT)), - 'loan_link' => 'https://pnb-dilicom.centprod.com/v2//XXXXXXXX.do', - 'order_line_id' => '584837a045ce56ef0a072a8b']); - } -} - - - - -class PnbDilicomAdminLoansTest extends PnbDilicomAdminLoansTestCase { - protected $_search_params = ['search_order' => 'loan_date', - 'search_loan_date_debut' => '10/11/2017', - 'search_loan_date_fin' => '20/11/2017']; - - public function setup() { - parent::setup(); - $this->dispatch('/admin/pnb/loans?' . http_build_query($this->_search_params)); - } - - - /** @test */ - public function pageShouldContainsTopMenu() { - $this->assertXPath('//div[@class="menu"]'); - } - - - /** @test */ - public function h2ShouldBeLoansHistory() { - $this->assertXPathContentContains('//h2', 'Historique des prêts'); - } - - - /** @test */ - public function exportCSVLoansButtonWithParamsShouldBePresent() { - $this->assertXPathContentContains('//button[contains(@data-url, "/admin/pnb/export-loans-csv?' . http_build_query($this->_search_params) . '")]', - 'Exporter le tableau en CSV'); - } - - - /** @test */ - public function pageShouldContainsPaginationWithParamsForPageTwo() { - $this->assertXPath('//div[@class="pager"]//a[contains(@href, "/admin/pnb/loans/search_order/loan_date/search_loan_date_debut/10%2F11%2F2017/search_loan_date_fin/20%2F11%2F2017/search_expected_return_date_debut//search_expected_return_date_fin//page/2")]'); - } - - - /** @test */ - public function tableShouldContainsColumnForTitle() { - $this->assertXPathContentContains('//table//td', 'Hell is from here to eternity'); - } - - - /** @test */ - public function tableShouldContainsColumnForGenre() { - $this->assertNotXPathContentContains('//table//td', 'Heavy Metal; Jazz'); - } - - - /** @test */ - public function tableShouldContainsColumnForSections() { - $this->assertNotXPathContentContains('//table//td', 'Espace métal; Espace jazz'); - } - - - /** @test */ - public function tableShouldContainsColumnForLoanDate() { - $this->assertXPathContentContains('//table//td', '10/11/2017'); - } - - - /** @test */ - public function tableShouldContainsColumnForExpectedReturnDate() { - $this->assertXPathContentContains('//table//td', '10/01/2018'); - } - - - /** @test */ - public function searchFormShouldContainsInputForReturnDateStart() { - $this->assertXPath('//form//fieldset[@id="fieldset-search_group"]//input[@name="search_expected_return_date_debut"]'); - } - - - /** @test */ - public function searchFormShouldContainsInputForReturnDateEnd() { - $this->assertXPath('//form//fieldset[@id="fieldset-search_group"]//input[@name="search_expected_return_date_fin"]'); - } - - - /** @test */ - public function searchFormShouldContainsInputForLoanDateStart() { - $this->assertXPath('//form//fieldset[@id="fieldset-search_group"]//input[@name="search_loan_date_debut"]'); - } - - - /** @test */ - public function searchFormShouldContainsInputForLoanDateEnd() { - $this->assertXPath('//form//fieldset[@id="fieldset-search_group"]//input[@name="search_loan_date_fin"]'); - } -} - - - - -class PnbDilicomAdminControllerWithDilicomGenreSectionAdminVar extends PnbDilicomAdminLoansTestCase { - - public function setUp() { - parent::setup(); - Class_AdminVar::set('DILICOM_PNB_BOARD_DISPLAY_SECTION',1); - $this->dispatch('/admin/pnb/loans?' - . http_build_query(['search_order' => 'loan_date', - 'search_loan_date_debut' => '10/11/2017', - 'search_loan_date_fin' => '20/11/2017'])); - } - - - /** @test */ - public function tableShouldContainsColumnForGenre() { - $this->assertXPathContentContains('//table//td', 'Heavy Metal; Jazz'); - } - - - /** @test */ - public function tableShouldContainsColumnForSections() { - $this->assertXPathContentContains('//table//td', 'Espace métal; Espace jazz'); - } -}