Newer
Older
<?php
/**
* Copyright (c) 2012, Agence Française Informatique (AFI). All rights reserved.
*
* 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).
*
* 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
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
require_once 'AbstractControllerTestCase.php';
class OAIControllerIdentifyTest extends AbstractControllerTestCase {
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
131
132
protected $_xpath;
public function setUp() {
parent::setUp();
$this->_xpath = TestXPathFactory::newOai();
Storm_Test_ObjectWrapper::onLoaderOfModel('Class_Notice')
->whenCalled('getEarliestNotice')
->answers(Class_Notice::getLoader()
->newInstanceWithId(2)
->setDateMaj('2011-07-11'));
Storm_Test_ObjectWrapper::onLoaderOfModel('Class_CosmoVar')
->whenCalled('find')
->with('mail_admin')
->answers(Class_CosmoVar::getLoader()
->newInstanceWithId('mail_admin')
->setValeur('user@server.fr'));
$this->dispatch('/opac/oai/request?verb=Identify');
}
/** @test */
public function controllerShouldBeOai() {
$this->assertController('oai');
}
/** @test */
public function actionShouldBeIdentify() {
$this->assertAction('identify');
}
/** @test */
public function xmlShouldBeValid() {
$dom = new DOMDocument();
$dom->loadXml($this->_response->getBody());
$dom->schemaValidate('tests/application/modules/opac/controllers/OAI-PMH.xsd');
}
/** @test */
public function responseDateShouldBeNow() {
$this->_xpath->assertXPathContentContains($this->_response->getBody(),
'//oai:responseDate',
date('Y-m-d'));
}
/** @test */
public function requestVerbShouldBeIdentify() {
$this->_xpath->assertXpath($this->_response->getBody(),
'//oai:request[@verb="Identify"]');
}
/** @test */
public function repositoryNameShouldBeAfiOpac3OaiRepository() {
$this->_xpath->assertXPathContentContains($this->_response->getBody(),
'//oai:Identify/oai:repositoryName',
$_SERVER['SERVER_NAME'] . ' Oai repository');
}
/** @test */
public function baseUrlShouldBeMoulinsDotFr() {
$this->_xpath->assertXpathContentContains($this->_response->getBody(),
'//oai:Identify/oai:baseURL',
'http://' . $_SERVER['SERVER_NAME'] . BASE_URL . '/opac/oai/request');
}
/** @test */
public function protocolVersionShouldBeTwoDotZero() {
$this->_xpath->assertXPathContentContains($this->_response->getBody(),
'//oai:Identify/oai:protocolVersion',
'2.0');
}
/** @test */
public function earliestDateStampShouldBeJulyEleven2011() {
$this->_xpath->assertXPathContentContains($this->_response->getBody(),
'//oai:Identify/oai:earliestDatestamp',
'2011-07-11');
}
/** @test */
public function granularityShouldBeYearMonthDay() {
$this->_xpath->assertXPathContentContains($this->_response->getBody(),
'//oai:Identify/oai:granularity',
'YYYY-MM-DD');
}
/** @test */
public function deletedRecordShouldBeNo() {
$this->_xpath->assertXPathContentContains($this->_response->getBody(),
'//oai:Identify/oai:deletedRecord',
'no');
}
/** @test */
public function adminEmailShouldBeUserAtServerDotfr() {
$this->_xpath->assertXPathContentContains($this->_response->getBody(),
'//oai:Identify/oai:adminEmail',
'user@server.fr');
}