Current file: htdocs/app/code/core/Mage/Core/Model/Mysql4/Store/Group.php
Legend: executed not executed dead code

  Coverage
  Classes Functions / Methods Lines
Total
0.00%0.00%
0.00% 0 / 1
0.00%0.00%
0.00% 0 / 6 CRAP
0.00%0.00%
0.00% 0 / 41
 
Mage_Core_Model_Mysql4_Store_Group
0.00%0.00%
0.00% 0 / 1
0.00%0.00%
0.00% 0 / 6
0.00%0.00%
0.00% 0 / 41
 _construct()
0.00%0.00%
0.00% 0 / 1 2
0.00%0.00%
0.00% 0 / 2
 _afterSave(Mage_Core_Model_Abstract $model)
0.00%0.00%
0.00% 0 / 1 2
0.00%0.00%
0.00% 0 / 4
 _updateWebsiteDefaultGroup($websiteId, $groupId)
0.00%0.00%
0.00% 0 / 1 6
0.00%0.00%
0.00% 0 / 12
 _changeWebsite(Mage_Core_Model_Abstract $model)
0.00%0.00%
0.00% 0 / 1 20
0.00%0.00%
0.00% 0 / 13
 _updateStoreWebsite($groupId, $websiteId)
0.00%0.00%
0.00% 0 / 1 2
0.00%0.00%
0.00% 0 / 5
 _saveDefaultStore($groupId, $storeId)
0.00%0.00%
0.00% 0 / 1 2
0.00%0.00%
0.00% 0 / 5


       1                 : <?php                                                                                                    
       2                 : /**                                                                                                      
       3                 :  * Magento                                                                                               
       4                 :  *                                                                                                       
       5                 :  * NOTICE OF LICENSE                                                                                     
       6                 :  *                                                                                                       
       7                 :  * This source file is subject to the Open Software License (OSL 3.0)                                    
       8                 :  * that is bundled with this package in the file LICENSE.txt.                                            
       9                 :  * It is also available through the world-wide-web at this URL:                                          
      10                 :  * http://opensource.org/licenses/osl-3.0.php                                                            
      11                 :  * If you did not receive a copy of the license and are unable to                                        
      12                 :  * obtain it through the world-wide-web, please send an email                                            
      13                 :  * to license@magentocommerce.com so we can send you a copy immediately.                                 
      14                 :  *                                                                                                       
      15                 :  * DISCLAIMER                                                                                            
      16                 :  *                                                                                                       
      17                 :  * Do not edit or add to this file if you wish to upgrade Magento to newer                               
      18                 :  * versions in the future. If you wish to customize Magento for your                                     
      19                 :  * needs please refer to http://www.magentocommerce.com for more information.                            
      20                 :  *                                                                                                       
      21                 :  * @category    Mage                                                                                     
      22                 :  * @package     Mage_Core                                                                                
      23                 :  * @copyright   Copyright (c) 2010 Magento Inc. (http://www.magentocommerce.com)                         
      24                 :  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)              
      25                 :  */                                                                                                      
      26                 :                                                                                                          
      27                 : /**                                                                                                      
      28                 :  * Store group resource model                                                                            
      29                 :  *                                                                                                       
      30                 :  * @category   Mage                                                                                      
      31                 :  * @package    Mage_Core                                                                                 
      32                 :  * @author      Magento Core Team <core@magentocommerce.com>                                             
      33                 :  */                                                                                                      
      34                 :                                                                                                          
      35                 : class Mage_Core_Model_Mysql4_Store_Group extends Mage_Core_Model_Mysql4_Abstract                         
      36                 : {                                                                                                        
      37                 :     protected function _construct()                                                                      
      38                 :     {                                                                                                    
      39               0 :         $this->_init('core/store_group', 'group_id');                                                    
      40               0 :     }                                                                                                    
      41                 :                                                                                                          
      42                 :     protected function _afterSave(Mage_Core_Model_Abstract $model)                                       
      43                 :     {                                                                                                    
      44               0 :         $this->_updateStoreWebsite($model->getId(), $model->getWebsiteId());                             
      45               0 :         $this->_updateWebsiteDefaultGroup($model->getWebsiteId(), $model->getId());                      
      46               0 :         $this->_changeWebsite($model);                                                                   
      47                 :                                                                                                          
      48               0 :         return $this;                                                                                    
      49                 :     }                                                                                                    
      50                 :                                                                                                          
      51                 :     protected function _updateWebsiteDefaultGroup($websiteId, $groupId)                                  
      52                 :     {                                                                                                    
      53               0 :         $write = $this->_getWriteAdapter();                                                              
      54               0 :         $cnt   = $write->fetchOne($write->select()                                                       
      55               0 :             ->from($this->getTable('core/store_group'), array('count'=>'COUNT(*)'))                      
      56               0 :             ->where($write->quoteInto('website_id=?', $websiteId)),                                      
      57               0 :             'count');                                                                                    
      58               0 :         if ($cnt == 1) {                                                                                 
      59               0 :             $write->update($this->getTable('core/website'),                                              
      60               0 :                 array('default_group_id' => $groupId),                                                   
      61               0 :                 $write->quoteInto('website_id=?', $websiteId)                                            
      62               0 :             );                                                                                           
      63               0 :         }                                                                                                
      64               0 :         return $this;                                                                                    
      65                 :     }                                                                                                    
      66                 :                                                                                                          
      67                 :     protected function _changeWebsite(Mage_Core_Model_Abstract $model) {                                 
      68               0 :         if ($model->getOriginalWebsiteId() && $model->getWebsiteId() != $model->getOriginalWebsiteId()) {
      69               0 :             $write = $this->_getWriteAdapter();                                                          
      70               0 :             $groupId = $write->fetchOne($write->select()                                                 
      71               0 :                 ->from($this->getTable('core/website'), 'default_group_id')                              
      72               0 :                 ->where($write->quoteInto('website_id=?', $model->getOriginalWebsiteId())),              
      73                 :                 'default_group_id'                                                                       
      74               0 :             );                                                                                           
      75               0 :             if ($groupId == $model->getId()) {                                                           
      76               0 :                 $write->update($this->getTable('core/website'),                                          
      77               0 :                     array('default_group_id'=>0),                                                        
      78               0 :                     $write->quoteInto('website_id=?', $model->getOriginalWebsiteId()));                  
      79               0 :             }                                                                                            
      80               0 :         }                                                                                                
      81               0 :         return $this;                                                                                    
      82                 :     }                                                                                                    
      83                 :                                                                                                          
      84                 :     protected function _updateStoreWebsite($groupId, $websiteId)                                         
      85                 :     {                                                                                                    
      86               0 :         $write = $this->_getWriteAdapter();                                                              
      87               0 :         $bind = array('website_id'=>$websiteId);                                                         
      88               0 :         $condition = $write->quoteInto('group_id=?', $groupId);                                          
      89               0 :         $this->_getWriteAdapter()->update($this->getTable('core/store'), $bind, $condition);             
      90               0 :         return $this;                                                                                    
      91                 :     }                                                                                                    
      92                 :                                                                                                          
      93                 :     protected function _saveDefaultStore($groupId, $storeId)                                             
      94                 :     {                                                                                                    
      95               0 :         $write = $this->_getWriteAdapter();                                                              
      96               0 :         $bind = array('default_store_id'=>$storeId);                                                     
      97               0 :         $condition = $write->quoteInto('group_id=?', $groupId);                                          
      98               0 :         $this->_getWriteAdapter()->update($this->getMainTable(), $bind, $condition);                     
      99               0 :         return $this;                                                                                    
     100                 :     }                                                                                                    
     101                 : }                                                                                                        

Generated by PHP_CodeCoverage 1.0.4 using PHP 5.3.4 and PHPUnit 3.5.13 at Tue Jul 5 9:07:16 UTC 2011.