Changeset 13492

Show
Ignore:
Timestamp:
06/08/08 18:10:47 (5 years ago)
Author:
kumatch
Message:

Refactored.

Location:
events/phpframework/piece_framework/trunk
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • events/phpframework/piece_framework/trunk/libs/Phwittr/Service.php

    r13490 r13492  
    155155 
    156156        if (!$user) { 
    157             return false; 
     157            throw new Phwittr_Service_Exception('認証に失敗しました'); 
    158158        } 
    159159 
  • events/phpframework/piece_framework/trunk/specs/Phwittr/AuthenticationSpec.php

    r13490 r13492  
    7979        $this->_createUserRecord($this->_foo); 
    8080 
    81         $this->spec(Phwittr_Service::authenticate('dummy', 'dummy'))->should->beFalse(); 
    82         $this->spec(Phwittr_Service::authenticate('dummy@example.com', 'dummy'))->should->beFalse(); 
    83         $this->spec(Phwittr_Service::authenticate($this->_foo->userName, 'dummy'))->should->beFalse(); 
    84         $this->spec(Phwittr_Service::authenticate($this->_foo->email, 'dummy'))->should->beFalse(); 
    85         $this->spec(Phwittr_Service::authenticate('dummy', $this->_foo->password))->should->beFalse(); 
    86         $this->spec(Phwittr_Service::authenticate('dummy@example.com', $this->_foo->password))->should->beFalse(); 
     81        try { 
     82            Phwittr_Service::authenticate($this->_foo->userName, 'dummy'); 
     83        } catch (Phwittr_Service_Exception $e) { 
     84            return; 
     85        } 
     86 
     87        $this->fail(); 
    8788    } 
    8889 
    89     public function it仮登録状態のユーザの認証は認められない() 
     90    public function it仮登録状態のユーザではユーザ名とパスワードによる認証はできない() 
    9091    { 
    9192        $this->_foo->flag = 0; 
     
    9394        $this->_foo->flag = 1; 
    9495 
    95         $result1 = Phwittr_Service::authenticate($this->_foo->userName, 
    96                                                  $this->_foo->password 
    97                                                  ); 
    98         $result2 = Phwittr_Service::authenticate($this->_foo->email, 
    99                                                  $this->_foo->password 
    100                                                  ); 
     96        try { 
     97            Phwittr_Service::authenticate($this->_foo->userName, 
     98                                          $this->_foo->password 
     99                                          ); 
     100        } catch (Phwittr_Service_Exception $e) { 
     101            return; 
     102        } 
    101103 
    102         $this->spec($result1)->should->beFalse(); 
    103         $this->spec($result2)->should->beFalse(); 
     104        $this->fail(); 
     105    } 
     106 
     107    public function it仮登録状態のユーザではメールアドレスとパスワードによる認証はできない() 
     108    { 
     109        $this->_foo->flag = 0; 
     110        $this->_createUserRecord($this->_foo); 
     111        $this->_foo->flag = 1; 
     112 
     113        try { 
     114            Phwittr_Service::authenticate($this->_foo->email, 
     115                                          $this->_foo->password 
     116                                          ); 
     117        } catch (Phwittr_Service_Exception $e) { 
     118            return; 
     119        } 
     120 
     121        $this->fail(); 
    104122    } 
    105123