Skip to content
Snippets Groups Projects
Commit 7814bffe authored by pbarroca's avatar pbarroca
Browse files

FRBR: Saisie d'une url contenant un permalien opac enregistre seulement la clef

parent 35d08602
Branches
Tags
No related merge requests found
......@@ -49,6 +49,16 @@ class Class_FRBR_Link extends Storm_Model_Abstract {
->validateAttribute('source', 'Zend_Validate_NotEmpty', $this->_('Un libellé objet A est requis'))
->validateAttribute('target', 'Zend_Validate_NotEmpty', $this->_('Un libellé objet B est requis'));
}
public function beforeSave() {
parent::beforeSave();
if (false === strpos($this->getSource(), '/clef/'))
return;
$parts = explode('/', $this->getSource());
$this->setSource($parts[array_search('clef', $parts) + 1]);
}
}
?>
\ No newline at end of file
......@@ -133,8 +133,7 @@ class Admin_FrbrLinkControllerEditSuiteTest extends Admin_FrbrLinkControllerTest
}
class Admin_FrbrLinkControllerEditSuiteValidPostTest extends Admin_FrbrLinkControllerTestCase {
abstract class Admin_FrbrLinkControllerEditSuiteValidPostTestCase extends Admin_FrbrLinkControllerTestCase {
public function setUp() {
parent::setUp();
......@@ -145,10 +144,6 @@ class Admin_FrbrLinkControllerEditSuiteValidPostTest extends Admin_FrbrLinkContr
Storm_Test_ObjectWrapper::onLoaderOfModel('Class_FRBR_LinkType')
->whenCalled('getComboList')
->answers([3 => 'Suite']);
$this->postDispatch('/admin/frbr-link/edit/id/2',
['type_id' => 3, 'source' => 'TOTOALAPLAGE', 'target' => 'TOTOFAITDUTUBA'],
true);
}
......@@ -162,4 +157,38 @@ class Admin_FrbrLinkControllerEditSuiteValidPostTest extends Admin_FrbrLinkContr
public function shouldRedirect() {
$this->assertRedirect();
}
}
class Admin_FrbrLinkControllerEditSuiteValidPostTest extends Admin_FrbrLinkControllerEditSuiteValidPostTestCase {
public function setUp() {
parent::setUp();
$this->postDispatch('/admin/frbr-link/edit/id/2',
['type_id' => 3, 'source' => 'TOTOALAPLAGE', 'target' => 'TOTOFAITDUTUBA'],
true);
}
}
class Admin_FrbrLinkControllerEditSuiteValidWithFullURLPostTest extends Admin_FrbrLinkControllerEditSuiteValidPostTestCase {
public function setUp() {
parent::setUp();
$this->postDispatch('/admin/frbr-link/edit/id/2',
['type_id' => 3,
'source' => 'http://localhost/afi-opac3-ce/recherche/viewnotice/clef/LES1000MOTSDELINFO-POURMIEUXCOMPRENDREE-COMBRESE--GALLIMARDJEUNESSE-2003-1/type_doc/1/id/44275',
'target' => 'TOTOFAITDUTUBA'],
true);
}
/** @test */
public function sourceShouldContainOnlyKey() {
$model = Class_FRBR_Link::find(2);
$this->assertEquals('LES1000MOTSDELINFO-POURMIEUXCOMPRENDREE-COMBRESE--GALLIMARDJEUNESSE-2003-1',
$model->getSource());
}
}
\ No newline at end of file
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