Skip to content
Snippets Groups Projects
Commit 795f69b3 authored by efalcy's avatar efalcy
Browse files

Liaison Formulaires / Users

parent a0295735
No related merge requests found
......@@ -4619,6 +4619,7 @@ tests/library/Class/File/MimeTest.php -text
tests/library/Class/FileWriterTest.php -text
tests/library/Class/Folder/ManagerTest.php -text
tests/library/Class/FormationTest.php -text
tests/library/Class/FormulaireTest.php -text
tests/library/Class/GlobalSqlRefactoringTest.php -text
tests/library/Class/I18nTest.php -text
tests/library/Class/I18nTranslatorTest.php -text
......
......@@ -22,10 +22,13 @@
class Class_Formulaire extends Storm_Model_Abstract {
use Trait_TimeSource;
protected $_datas;
protected $_table_name='formulaires';
protected $_default_attribute_values = ['data' => ''];
protected $_belongs_to = ['user' => ['model' => 'Class_Users',
'referenced_in' => 'id_user']];
protected $_default_attribute_values = ['data' => 'a:0:{}'];
protected $_datas;
public static function mergeDataNames($formulaires) {
$names = [];
foreach($formulaires as $formulaire) {
......
......@@ -141,40 +141,46 @@ class Class_Users extends Storm_Model_Abstract {
protected $_table_name = 'bib_admin_users';
protected $_table_primary = 'ID_USER';
protected $_loader_class = 'UsersLoader';
protected $_has_many = array('subscriptions' => array('model' => 'Class_NewsletterSubscription',
'role' => 'user',
'dependents' => 'delete'),
protected $_has_many = [
'subscriptions' => ['model' => 'Class_NewsletterSubscription',
'role' => 'user',
'dependents' => 'delete'],
'newsletters' => array('through' => 'subscriptions'),
'newsletters' => ['through' => 'subscriptions'],
'avis' => array('model' => 'Class_AvisNotice',
'role' => 'user',
'order' => 'date_avis desc'),
'avis' => ['model' => 'Class_AvisNotice',
'role' => 'user',
'order' => 'date_avis desc'],
'avis_articles' => array('model' => 'Class_Avis',
'role' => 'auteur',
'order' => 'date_avis desc'),
'avis_articles' => ['model' => 'Class_Avis',
'role' => 'auteur',
'order' => 'date_avis desc'],
'paniers' => array('model' => 'Class_PanierNotice',
'role' => 'user'),
'paniers' => ['model' => 'Class_PanierNotice',
'role' => 'user'],
'session_formation_inscriptions' => array('model' => 'Class_SessionFormationInscription',
'role' => 'stagiaire'),
'session_formation_inscriptions' => ['model' => 'Class_SessionFormationInscription',
'role' => 'stagiaire'],
'session_formations' => array('through' => 'session_formation_inscriptions'),
'session_formations' => ['through' => 'session_formation_inscriptions'],
'formations' => array('through' => 'session_formation_inscriptions'),
'formations' => ['through' => 'session_formation_inscriptions'],
'session_formation_interventions' => array('model' => 'Class_SessionFormationIntervention',
'role' => 'intervenant'),
'session_formation_interventions' => ['model' => 'Class_SessionFormationIntervention',
'role' => 'intervenant'],
'session_interventions' => array('through' => 'session_formation_interventions'),
'session_interventions' => ['through' => 'session_formation_interventions'],
'user_group_memberships' => array('model' => 'Class_UserGroupMembership',
'role' => 'user'),
'user_group_memberships' => ['model' => 'Class_UserGroupMembership',
'role' => 'user'],
'user_groups' => array('through' => 'user_group_memberships')
);
'user_groups' => ['through' => 'user_group_memberships'],
'formulaires' => ['model' => 'Class_Formulaire',
'role' => 'user',
'order' => 'date_creation desc'],
];
protected $_belongs_to = array('bib' => array('model' => 'Class_Bib',
......
<?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
*/
class FormulaireTest extends Storm_Test_ModelTestCase {
public function setUp() {
parent::setUp();
$this->_fantomas = Class_Users::newInstanceWithId(23, ['login' => 'fantomas']);
$this->_formulaire = Class_Formulaire::newInstanceWithId(2, ['id_user' => 23]);
Storm_Test_ObjectWrapper::onLoaderOfModel('Class_Formulaire')
->whenCalled('findAllBy')
->answers([$this->_formulaire]);
}
/** @test */
public function formulaireUserShouldBeFantomas() {
$this->assertEquals('fantomas', $this->_formulaire->getUser()->getLogin());
}
/** @test */
public function userFantomasShouldHaveOneFormulaire() {
$this->assertEquals([$this->_formulaire],
$this->_fantomas->getFormulaires());
}
}
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