Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
<?php
/**
* Copyright (c) 2012-2014, 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 'tests/fixtures/NanookFixtures.php';
abstract class AbstractAbonneControllerSuggestionAchatNanookTestCase extends AbstractControllerTestCase {
protected
$_storm_default_to_volatile = true,
$_francis;
public function setUp() {
parent::setUp();
$logger = $this->mock()
->whenCalled('log')->answers(true)
->whenCalled('logError')
->willDo(
function($url, $message) {
throw new RuntimeException($url . ' :: ' . $message);
});
Class_WebService_SIGB_AbstractService::setLogger($logger);
$sigb_conf = $this->fixture('Class_IntBib',
['id' => 3,
'comm_params' => ['url_serveur' => ''],
'comm_sigb' => Class_IntBib::COM_NANOOK]);
$this->fixture('Class_Bib', ['id' => 12,
'libelle' => 'Tatim bib',
'int_bib' => $sigb_conf]);
$this->_francis = $this->fixture('Class_Users', ['id' => 3,
'login' => 'francis',
'password' => 'test',
'int_bib' => $sigb_conf]);
ZendAfi_Auth::getInstance()->logUser($this->_francis);
$this->mock_web_client = $this->mock();
$this->mock_web_client
->whenCalled('open_url')
->with('http:///service/AuthenticatePatron/username/francis/password/test')
->answers(NanookFixtures::authenticatePatronResponse())
->whenCalled('open_url')
->with('http:///service/GetPatronInfo/patronId/187')
->answers(NanookFixtures::patronInfoResponse())
->beStrict();
$sigb_comm = Class_IntBib::find(3)->getSIGBComm();
$sigb_comm->setWebClient($this->mock_web_client);
}
}
class AbonneControllerSuggestionAchatNanookListTest extends AbstractAbonneControllerSuggestionAchatNanookTestCase {
public function setUp() {
parent::setUp();
$this->dispatch('/opac/abonne/suggestion-achat', true);
}
/** @test */
public function pageShouldContainsSuggestionFromNanook() {
$this->assertXPathContentContains('//div', 'some suggestions', $this->_response->getBody());
}
}
class AbonneControllerSuggestionAchatNanookAddTest extends AbstractAbonneControllerSuggestionAchatNanookTestCase {
protected $_storm_default_to_volatile = true;
public function setUp() {
parent::setUp();
$this->dispatch('/opac/abonne/suggestion-achat-add', true);
}
/** @test */
public function formShouldContainsNanookElement() {
$this->assertXPathContentContains('//div', 'some suggestions', $this->_response->getBody());
}
}
class AbonneControllerSuggestionAchatNanookAddPostTest extends AbstractAbonneControllerSuggestionAchatNanookTestCase {
protected $_storm_default_to_volatile = true;
public function setUp() {
parent::setUp();
$this->postDispatch('/opac/abonne/suggestion-achat-add', ['titre' => 'fu',
'auteur' => 'mf',
'isbn' => '2-07-0541 27_4',
'description_url' => 'bokeh-kibrary-portail.org',
'commentaire' => 'no']);
}
/** @test */
public function suggestionShouldHaveBeenSend() {
$this->assertContains(['suggestion'], $this->_francis->getSuggestionAchat());
}
}