Changeset 15221

Show
Ignore:
Timestamp:
07/05/08 23:34:20 (5 years ago)
Author:
kumatch
Message:

Added a Phwittr_Account::deletePicture() method.

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

Legend:

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

    r14663 r15221  
    118118     */  
    119119   public function updatePicture($id, $file) 
    120     { 
     120   { 
    121121        $pathinfo = pathinfo($file); 
    122122        $pathinfo['filename'] = basename($file, ".{$pathinfo['extension']}"); 
     
    144144        $normalImage->save(ASIDO_OVERWRITE_ENABLED); 
    145145    } 
     146 
     147    // }}} 
     148    // {{{ deletePicture 
     149 
     150    /** 
     151     * アイコンを削除する 
     152     *  
     153     * @param integer $id 
     154     * @return mixed 
     155     */  
     156   public function deletePicture($id) 
     157   { 
     158        $mapper = Piece_ORM::getMapper('Users'); 
     159        $user = $mapper->findById($id); 
     160         
     161        $user->image = null; 
     162        $user->updatedAt = date('Y-m-d H:i:s'); 
     163 
     164        $mapper->update($user); 
     165   } 
     166 
     167 
    146168 
    147169    // }}} 
  • events/phpframework/piece_framework/trunk/specs/Phwittr/AccountSpec.php

    r14837 r15221  
    183183        $this->spec(file_exists($this->_sampleDirectory . '/example_normal.png')) 
    184184                    ->should->beTrue(); 
     185    } 
     186 
     187    public function itユーザ画像を個別で削除すると、フィールド値が削除される() 
     188    { 
     189        $mapper = Piece_ORM::getMapper('Users'); 
     190        $newUser = $mapper->findById($this->_foo->id); 
     191 
     192        $this->spec($newUser->image)->should->be('example.png'); 
     193 
     194        Phwittr_Account::deletePicture($this->_foo->id); 
     195 
     196        $mapper = Piece_ORM::getMapper('Users'); 
     197        $newUser = $mapper->findById($this->_foo->id); 
     198 
     199        $this->spec($newUser->image)->should->beNull(); 
    185200    } 
    186201