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
<?php
/**
* Copyright (c) 2012, Agence Française Informatique (AFI). All rights reserved.
*
* AFI-OPAC 2.0 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).
*
* AFI-OPAC 2.0 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 AFI-OPAC 2.0; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
require_once 'AbstractControllerTestCase.php';
class AbonneControllerSuggestionAchatFormTest extends AbstractControllerTestCase {
public function setUp() {
parent::setUp();
$this->dispatch('/opac/abonne/suggestion-achat', true);
}
/** @test */
public function pageTitleShouldBeSuggestionAchat() {
$this->assertXPathContentContains('//title', 'Suggestion d\'achat');
}
/** @test */
public function boiteShouldHaveTitleSuggestionAchat() {
$this->assertXPathContentContains('//div[@class="boiteMilieu"]//h1', 'Suggestion d\'achat');
}
/** @test */
public function formShouldContainsInputForTitre() {
$this->assertXPath('//form//input[@name="titre"][@placeholder="Harry Potter à l\'école des sorciers"]');
}
/** @test */
public function formShouldContainsInputForAuteur() {
$this->assertXPath('//form//input[@name="auteur"][@placeholder="Joanne Kathleen Rowling"]');
}
/** @test */
public function formShouldContainsInputForDescriptionUrl() {
$this->assertXPath('//form//input[@type="url"][@name="description_url"][@placeholder="http://fr.wikipedia.org/wiki/Harry_Potter_à_l\'école_des_sorciers"]');
}
/** @test */
public function formShouldContainsInputForISBN() {
$this->assertXPath('//form//input[@name="isbn"][@placeholder="2-07-054127-4"]');
}
/** @test */
public function formShouldContainsTextAreaForCommentaire() {
$this->assertXPath('//form//textarea[@name="commentaire"]');
}
/** @test */
public function formShouldContainsSubmitButtonEnvoyer() {
$this->assertXPath('//form//input[@type="submit"][@value="Envoyer"]');
}
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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
class AbonneControllerSuggestionAchatPostValidDataTest extends AbstractControllerTestCase {
protected $_suggestion;
protected function _loginHook($account) {
$account->username = 'Arnaud';
$account->ID_USER = 666;
}
public function setUp() {
parent::setUp();
Storm_Test_ObjectWrapper::onLoaderOfModel('Class_SuggestionAchat')
->whenCalled('save')
->willDo(
function($suggestion){
$this->_suggestion = $suggestion->setId(66);
});
$this->postDispatch('/opac/abonne/suggestion-achat',
['titre' => 'Harry Potter',
'auteur' => 'J.K.Rowling',
'description_url' => 'http://harrypotter.fr',
'isbn' => '2-07-0541 27_4',
'commentaire' => 'Je veux le lire',
'submit' => 'Envoyer']);
}
/** @test */
public function newSuggestionShouldHaveTitreHarryPotter() {
$this->assertEquals('Harry Potter', $this->_suggestion->getTitre());
}
/** @test */
public function newSuggestionShouldHaveAuteurJKRowling() {
$this->assertEquals('J.K.Rowling', $this->_suggestion->getAuteur());
}
/** @test */
public function newSuggetionShouldHaveDescriptionUrlHarryPotterDotFr() {
$this->assertEquals('http://harrypotter.fr', $this->_suggestion->getDescriptionUrl());
}
/** @test */
public function newSuggestionsShouldHaveIsbn2070541274() {
$this->assertEquals('2070541274', $this->_suggestion->getIsbn());
}
/** @test */
public function shouldNotHaveSubmitAttribute() {
$this->assertNotContains('submit', array_keys($this->_suggestion->toArray()));
}
/** @test */
public function newSuggestionShouldHaveCommentaireJeVeuxLeLire() {
$this->assertEquals('Je veux le lire', $this->_suggestion->getCommentaire());
}
/** @test */
public function newSuggestionShouldBelongsToArnaud() {
$this->assertEquals('Arnaud', $this->_suggestion->getUser()->getLogin());
}
/** @test */
public function newSuggetionShouldDateCreationShouldBeToday() {
$this->assertEquals(date('Y-m-d'), $this->_suggestion->getDateCreation());
}
/** @test */
public function responseShouldRedirectToSuggestionAchatId66() {
$this->assertRedirectTo('/opac/abonne/suggestion-achat/id/66');
}
}
class AbonneControllerSuggestionAchatWithIdTest extends AbstractControllerTestCase {
public function setUp() {
parent::setUp();
Class_SuggestionAchat::newInstanceWithId(66);
$this->dispatch('/opac/abonne/suggestion-achat/id/66', true);
}
/** @test */
public function pageShouldDisplaySuggestionPriseEnCompte() {
$this->assertXPathContentContains('//p', 'Votre suggestion d\'achat');
}
}