Newer
Older
/** @test */
public function shouldDisplayWebserviceError() {
$this->assertXPathContentContains('//div',
'Erreurs du webservice');
}
class ModulesControllerAbonneSuggestionAchatTest extends Admin_AbstractControllerTestCase {
public function setUp() {
parent::setUp();
Class_Profil::getCurrentProfil()
->setCfgModules(['abonne' => ['suggestion-achat-add' => ['help-text' => 'Entrez votre suggestion']]]);
$this->dispatch('/admin/modules/abonne?id_profil=2&action1=suggestion-achat-add&type_module=abonne&config=site', true);
}
/** @test */
public function titleShouldBeProperty() {
$this->assertXPathContentContains('//h1', 'Propriétés du module : Suggestions d\'achat');
}
/** @test */
public function textareHelpTextShouldContainsEntrezVotreSuggestion() {
$this->assertXPathContentContains('//textarea[@name="help-text"]',
'Entrez votre suggestion');
}
/** @test */
public function textareHelpTextShouldBeCkeditor() {
$this->assertXPathContentContains('//script',
'CKEDITOR.replace(\'cke-help-text\'');
}
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
class AbonneControllerSuggestionAchatBibSelectOrderTest extends AbstractControllerTestCase {
public function setUp() {
parent::setUp();
$this->fixture('Class_Bib', ['id' => 11, 'libelle' => 'Test']);
$this->fixture('Class_Bib', ['id' => 12, 'libelle' => 'Mer']);
$this->fixture('Class_Bib', ['id' => 13, 'libelle' => 'Agence']);
$this->fixture('Class_Bib', ['id' => 14, 'libelle' => 'Plage']);
$this->dispatch('abonne/suggestion-achat-add', true);
}
/** @test */
public function BibSelectShouldBeAgence() {
$this->assertXPath('//form//select[@name="bib_id"]//option[2][@value="13"]');
}
/** @test */
public function BibSelectShouldBeMer() {
$this->assertXPath('//form//select[@name="bib_id"]//option[3][@value="12"]');
}
/** @test */
public function BibSelectShouldBePlage() {
$this->assertXPath('//form//select[@name="bib_id"]//option[4][@value="14"]');
}
/** @test */
public function BibSelectShouldBeTest() {
$this->assertXPath('//form//select[@name="bib_id"]//option[5][@value="11"]');
}
}
class AbonneControllerSuggestionAchatInactiveTest
extends AbstractControllerTestCase {
protected $_storm_default_to_volatile = true;
public function setUp() {
parent::setUp();
$this->fixture('Class_AdminVar', ['id' => 'DISABLE_SUGGESTIONS',
'valeur' => '1']);
public function provider() {
return [['/abonne/suggestion-achat'],
['/abonne/suggestion-achat-add'],
['/abonne/suggestion-achat-ok']];
/**
* @test
* @dataProvider provider
**/
public function shouldContainsDisabledMessage($url) {
$this->dispatch($url, true);
$this->assertXPathContentContains('//div',
'les suggestions d\'achats ne sont pas possibles pour le moment.',
$this->_response->getBody());

Ghislain Loas
committed
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
}
class AbonneControllerSuggestionAchatAddPostAndRecordsFoundTest extends AbonneControllerSuggestionAchatAddPostTestCase {
protected $_storm_default_to_volatile = true;
public function setUp() {
parent::setUp();
Class_AdminVar::set('SEARCH_RECORD_BEFORE_SUGGEST', 1);
$mock_transport = new MockMailTransport();
Zend_Mail::setDefaultTransport($mock_transport);
$search_result = $this
->mock()->beStrict()
->whenCalled('fetchRecords')
->answers([$this->fixture('Class_Notice',
['id' => 1,
'titre_principal' => 'Trolls de Troy'])]);
$search_engine = $this
->mock()
->whenCalled('lancerRecherche')
->answers($search_result);
Class_MoteurRecherche::setInstance($search_engine);
$this->postDispatch('/opac/abonne/suggestion-achat-add',
['DocType' => Class_TypeDoc::LIVRE,
'Site' => '12',
'titre' => 'Trolls de Troy']);
}
/** @test */
public function recordsListShouldContainsTrollsDeTroy() {
$this->assertXPathContentContains('//div', 'Trolls de Troy', $this->_response->getBody());
}
}
class AbonneControllerSuggestionAchatAddPostWithValidateSuggestionTest extends AbonneControllerSuggestionAchatAddPostTestCase {
protected $_storm_default_to_volatile = true;
public function setUp() {
parent::setUp();
Class_AdminVar::set('SEARCH_RECORD_BEFORE_SUGGEST', 1);
$mock_transport = new MockMailTransport();
Zend_Mail::setDefaultTransport($mock_transport);
$search_result = $this
->mock()->beStrict()
->whenCalled('fetchRecords')
->answers([$this->fixture('Class_Notice',
['id' => 1,
'titre_principal' => 'Le mystère de la patate. Une enquête de l\'inspecteur Lapou'])]);
$search_engine = $this
->mock()
->whenCalled('lancerRecherche')
->answers($search_result);
Class_MoteurRecherche::setInstance($search_engine);
$this->postDispatch('/opac/abonne/suggestion-achat-add/validate_suggestion/1',
['titre' => 'Le mystère de la patate',
'auteur' => 'Bénédicte Guettier',
'type_doc_id' => Class_TypeDoc::LIVRE,
'commentaire' => 'Une enquête de l\'inspecteur Lapou']);
}
/** @test */
public function responseShouldRedirect() {
$this->assertRedirect();
}
/** @test */
public function assertFlashMessengerShouldContainsSuggestionAdded() {
$this->assertFlashMessengerContentContains('Suggestion d\'achat enregistrée');
}