UsersNonValidTest.php 3.86 KB
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
<?php
/**
 * Copyright (c) 2012-2017, Agence Française Informatique (AFI). All rights reserved.
 *
 * BOKEH 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).
 *
 * BOKEH 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 BOKEH; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301  USA
 */


class Class_UsersNonValidActivateTest extends ModelTestCase {
  protected
    $_storm_default_to_volatile = true,
    $_new_user;

  public function setUp() {
    parent::setUp();
Laurent's avatar
Laurent committed
30

31 32 33 34 35 36 37
    $this
      ->fixture('Class_UsersNonValid',
                ['id' => 3,
                 'login' => 'jb',
                 'lastname' => 'brown',
                 'firstname' => 'james',
                 'idabon' => '123',
Laurent's avatar
Laurent committed
38
                 'id_site' => 3,
39 40 41
                 'mail' => 'jb@sexmach.ne',
                 'password' => 'ifeelgood'])
      ->activate();
42 43 44 45 46 47

    $this->_new_user = Class_Users::find(1);
  }


  /** @test */
48 49
  public function usersNonValidShouldNotBeDeleted() {
    $this->assertNotNull(Class_UsersNonValid::find(3));
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71
  }


  /** @test */
  public function userLoginShouldBeJB() {
    $this->assertEquals('jb', $this->_new_user->getLogin());
  }


  /** @test */
  public function userNomShouldBeBrown() {
    $this->assertEquals('brown', $this->_new_user->getNom());
  }


  /** @test */
  public function userPrenomShouldBeJames() {
    $this->assertEquals('james', $this->_new_user->getPrenom());
  }


  /** @test */
Patrick Barroca's avatar
Patrick Barroca committed
72 73
  public function userPasswordShouldBeIfeelgoodHashed() {
    $this->assertTrue($this->_new_user->verifyPassword('ifeelgood'));
74 75
  }
}
Laurent's avatar
Laurent committed
76

77 78


Laurent's avatar
Laurent committed
79
class Class_UsersNonValidActivateWithConnectionToSIGBTest extends ModelTestCase {
80
  protected $_new_user;
Laurent's avatar
Laurent committed
81 82 83 84

  public function setUp() {
    parent::setUp();

85 86 87 88 89
    $int_bib = $this->fixture('Class_IntBib', ['id' => 3])
                    ->beKoha()
                    ->beCommKoha()
                    ->setCommParams(['url_serveur' => 'https://mon.koha.la',
                                     'use_card_number'=>'12414C12']);
Laurent's avatar
Laurent committed
90 91
    $int_bib->assertSave();

92
    $bib = $this->fixture('Class_Bib',
Laurent's avatar
Laurent committed
93 94
                          ['id' => 3,
                           'libelle' => 'Tatoine',
95 96
                           'int_bib' => $int_bib,
                           'visibilite' => Class_Bib::V_DATA]);
Laurent's avatar
Laurent committed
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

    Class_User_ILSSubscription::setTimeSource(new TimeSourceForTest('2019-02-12 11:25:31'));

    $this
      ->fixture('Class_UsersNonValid',
                ['id' => 3,
                 'login' => 'jb',
                 'lastname' => 'brown',
                 'firstname' => 'james',
                 'idabon' => '123',
                 'id_site' => 3,
                 'mail' => 'jb@sexmach.ne',
                 'password' => 'ifeelgood'])
      ->activate();

    $this->_new_user = Class_Users::find(1);
  }


  public function tearDown() {
    Class_User_ILSSubscription::setTimeSource(null);
    parent::tearDown();
  }


  /** @test */
  public function userRoleShouldBeAbonneSIGB() {
124
    $this->assertTrue($this->_new_user->isAbonne());
Laurent's avatar
Laurent committed
125 126 127 128 129 130 131
  }


  /** @test */
  public function userDateFinShouldBesetToNextyear() {
    $this->assertEquals('2020-02-12', $this->_new_user->getDateFin());
  }
132 133 134 135 136 137 138


  /** @test */
  public function userShouldHaveTatoineSigbComm() {
    $this->assertNotNull($comm = $this->_new_user->getSIGBComm());
    $this->assertEquals('https://mon.koha.la', $comm->getServerRoot());
  }
Laurent's avatar
Laurent committed
139
}