Commit 1fcc059f authored by efalcy's avatar efalcy

hotline#112284 fix tests

parent 46555bb3
Pipeline #10477 passed with stage
in 46 minutes and 9 seconds
......@@ -163,7 +163,7 @@ class AuthController extends ZendAfi_Controller_Action {
public function loginAction() {
$this->view->preferences = $this->_loginPrefFromWidgetOrModule();
$redirect = $this->_getParam('redirect', Class_Url::absolute(['module' => 'opac',
$redirect = $this->_getParam('redirect', Class_Url::relative(['module' => 'opac',
'action' => 'index',
'controller' => 'index']));
$this->view->redirect = $redirect;
......
......@@ -155,6 +155,12 @@ class Class_Url {
*/
public static function assemble(array $urlOptions = array(), $name = null, $reset = true, $encode = true) {
$router = Zend_Controller_Front::getInstance()->getRouter();
$inspector_gadget = Zend_Controller_Front::getInstance()
->getPlugin('ZendAfi_Controller_Plugin_InspectorGadget');
if ($inspector_gadget)
$urlOptions = $inspector_gadget->addToParams($urlOptions);
return $router->assemble($urlOptions, $name, $reset, $encode);
}
......@@ -266,12 +272,6 @@ Bokeh Error : adminVar "NOM_DOMAINE" is empty. Bokeh in php cli mode is unable t
if (is_string($url_array_or_string))
return static::_beginWithSlash($url_array_or_string);
$inspector_gadget = Zend_Controller_Front::getInstance()
->getPlugin('ZendAfi_Controller_Plugin_InspectorGadget');
if ($inspector_gadget)
$url_array_or_string = $inspector_gadget->addToParams($url_array_or_string);
return static::assemble($url_array_or_string, $name, $reset, $encode);
}
}
......@@ -1081,7 +1081,7 @@ class AuthControllerPostSimpleSuccessfulTest extends AuthControllerPostSimpleSuc
/** @test */
public function responseShouldBeARedirectToOPAC() {
$this->assertRedirectTo('/opac');
$this->assertRedirectTo('/');
}
......@@ -1343,7 +1343,7 @@ class AuthControllerPostSimpleFailureTest extends AuthControllerPostSimpleTestCa
public function withAuthenticationFailureResponseShouldBeRedirect() {
$this->postDispatch('/opac/auth/login',
['username' => 'foo', 'password' => 'bar']);
$this->assertRedirectTo('/opac');
$this->assertRedirectTo('/');
}
......
......@@ -104,7 +104,7 @@ class AuthControllerWithoutPasswordKohaTest extends AuthControllerWithoutPasswor
public function setUp() {
parent::setUp();
$this->postDispatch('/opac/auth/login', ['username' => 'foo', 'password' => 'bar', 'inspector_gadget' => 'keep']);
$this->postDispatch('/opac/auth/login', ['username' => 'foo', 'password' => 'bar' , 'inspector_gadget' => 'keep']);
}
......@@ -127,12 +127,18 @@ class AuthControllerWithoutPasswordKohaTest extends AuthControllerWithoutPasswor
->whenCalled('getLastResponse')
->answers(
(new Class_Entity())->setStatus('ok')->setBody(KohaFixtures::xmlAuthenticatePatronOk()))
->whenCalled('getLastRequest')
->answers('true')
->beStrict();
Class_HttpClientFactory::setInstance($this->mock()->whenCalled('getLastHttpClient')->answers($this->_mock_web_client));
$this->_service = Class_WebService_SIGB_Koha::getService($this->_params);
$this->_service->setWebClient($this->_mock_web_client);
}
public function tearDown() {
Class_HttpClientFactory::resetInstance();
parent::tearDown();
}
/** @test */
public function userFooShouldBeLogged() {
......@@ -148,7 +154,7 @@ class AuthControllerWithoutPasswordKohaTest extends AuthControllerWithoutPasswor
/** @test */
public function withActionLoginWithInspectorGadgetShouldKeepWebserviceCalls() {
$this->assertRedirectTo('http://localhost/bokeh/index/index/inspector_gadget/keep');
$this->assertRedirectTo('/index/index/inspector_gadget/keep');
$this->assertNotNull(Zend_Registry::get('session')->inspectorCalls);
}
......
......@@ -234,21 +234,48 @@ class AuthorPageViewAuthorWithoutRecordTest extends AuthorPageTestCase {
class AuthorPageViewByIdTest extends AuthorPageTestCase {
class AuthorPageViewByIdWithInspectorGadgetTest extends AuthorPageTestCase {
public function setUp() {
parent::setUp();
$this->dispatch('/author/view/id/2408/inspector_gadget/1');
}
/** @test */
public function biographyTextLesMiserablesShouldBeReplacedByLinkToRecord() {
$this->assertXPathContentContains('//div[@class="biography"]//a[contains(@href, "/recherche/viewnotice/code_rebond/A2408/inspector_gadget/1/id/9")][@title="Accéder au document: Les Misérables"]',
'Les Misérables',$this->_response->getBody());
}
/** @test */
public function pageShouldContainsInspectorGadgetButton() {
$this->assertXPathContentContains('//button[contains(@class,"admin-button")]', 'Auteur Bokeh');
}
/** @test */
public function pageShouldLinkGavrocheWithCodeRebondAndFacet() {
$this->assertXPath('//div[@class="records"]//div[@class="simple_wall"]/a[contains(@href, "/recherche/viewnotice/id/8/inspector_gadget/1/clef/GAVROCHE_HUGO/code_rebond/A2408/facette/T1")]',
$this->_response->getBody());
}
/** @test */
public function pageShouldLinkLesMiserablesWithCodeRebondAndFacet() {
$this->assertXPath('//div[@class="records"]//div[@class="simple_wall"]/a[contains(@href, "/recherche/viewnotice/id/9/inspector_gadget/1/clef/MISERABLES_HUGO/code_rebond/A2408/facette/T1")]');
}
}
class AuthorPageViewByIdTest extends AuthorPageTestCase {
public function setUp() {
parent::setUp();
$this->dispatch('/author/view/id/2408');
}
/** @test */
public function authorWikdataIdShouldBeQ8298() {
$this->assertEquals('Q8298', Class_CodifAuteur::find(2408)->getWikidataId());
......@@ -294,7 +321,7 @@ class AuthorPageViewByIdTest extends AuthorPageTestCase {
/** @test */
public function biographyTextLesMiserablesShouldBeReplacedByLinkToRecord() {
$this->assertXPathContentContains('//div[@class="biography"]//a[contains(@href, "/recherche/viewnotice/code_rebond/A2408/id/9")][@title="Accéder au document: Les Misérables"]',
'Les Misérables');
'Les Misérables',$this->_response->getBody());
}
......@@ -411,14 +438,14 @@ class AuthorPageViewByIdTest extends AuthorPageTestCase {
/** @test */
public function pageShouldLinkGavrocheWithCodeRebondAndFacet() {
$this->assertXPath('//div[@class="records"]//div[@class="simple_wall"]/a[contains(@href, "/recherche/viewnotice/id/8/inspector_gadget/1/clef/GAVROCHE_HUGO/code_rebond/A2408/facette/T1")]',
$this->assertXPath('//div[@class="records"]//div[@class="simple_wall"]/a[contains(@href, "/recherche/viewnotice/id/8/clef/GAVROCHE_HUGO/code_rebond/A2408/facette/T1")]',
$this->_response->getBody());
}
/** @test */
public function pageShouldLinkLesMiserablesWithCodeRebondAndFacet() {
$this->assertXPath('//div[@class="records"]//div[@class="simple_wall"]/a[contains(@href, "/recherche/viewnotice/id/9/inspector_gadget/1/clef/MISERABLES_HUGO/code_rebond/A2408/facette/T1")]');
$this->assertXPath('//div[@class="records"]//div[@class="simple_wall"]/a[contains(@href, "/recherche/viewnotice/id/9/clef/MISERABLES_HUGO/code_rebond/A2408/facette/T1")]');
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment