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

  Coverage
  Classes Functions / Methods Lines
Total
0.00%0.00%
0.00% 0 / 1
23.08%23.08%
23.08% 3 / 13 CRAP
20.75%20.75%
20.75% 11 / 53
 
Mage_Core_Model_Mysql4_Store_Collection
0.00%0.00%
0.00% 0 / 1
23.08%23.08%
23.08% 3 / 13
20.75%20.75%
20.75% 11 / 53
 _construct()
100.00%100.00%
100.00% 1 / 1 1
100.00%100.00%
100.00% 2 / 2
 setLoadDefault($loadDefault)
100.00%100.00%
100.00% 1 / 1 1
100.00%100.00%
100.00% 2 / 2
 getLoadDefault()
100.00%100.00%
100.00% 1 / 1 1
100.00%100.00%
100.00% 1 / 1
 setWithoutDefaultFilter()
0.00%0.00%
0.00% 0 / 1 2
0.00%0.00%
0.00% 0 / 2
 addGroupFilter($groupId)
0.00%0.00%
0.00% 0 / 1 6
0.00%0.00%
0.00% 0 / 6
 addIdFilter($store)
0.00%0.00%
0.00% 0 / 1 6
0.00%0.00%
0.00% 0 / 6
 addWebsiteFilter($website)
0.00%0.00%
0.00% 0 / 1 6
0.00%0.00%
0.00% 0 / 6
 addCategoryFilter($category)
0.00%0.00%
0.00% 0 / 1 6
0.00%0.00%
0.00% 0 / 4
 toOptionArray()
0.00%0.00%
0.00% 0 / 1 2
0.00%0.00%
0.00% 0 / 1
 toOptionHash()
0.00%0.00%
0.00% 0 / 1 2
0.00%0.00%
0.00% 0 / 1
 load($printQuery = false, $logQuery = false)
0.00%0.00%
0.00% 0 / 1 2.06
75.00%75.00%
75.00% 6 / 8
 loadByCategoryIds(array $categories)
0.00%0.00%
0.00% 0 / 1 2
0.00%0.00%
0.00% 0 / 8
 addRootCategoryIdAttribute()
0.00%0.00%
0.00% 0 / 1 2
0.00%0.00%
0.00% 0 / 6


       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                 :  * Stores collection                                                                                      
      29                 :  *                                                                                                        
      30                 :  * @category   Mage                                                                                       
      31                 :  * @package    Mage_Core                                                                                  
      32                 :  * @author      Magento Core Team <core@magentocommerce.com>                                              
      33                 :  */                                                                                                       
      34                 : class Mage_Core_Model_Mysql4_Store_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract          
      35                 : {                                                                                                         
      36                 :     protected $_loadDefault = false;                                                                      
      37                 :                                                                                                           
      38                 :     protected function _construct()                                                                       
      39                 :     {                                                                                                     
      40              15 :         $this->_init('core/store');                                                                       
      41              15 :     }                                                                                                     
      42                 :                                                                                                           
      43                 :     public function setLoadDefault($loadDefault)                                                          
      44                 :     {                                                                                                     
      45              15 :         $this->_loadDefault = $loadDefault;                                                               
      46              15 :         return $this;                                                                                     
      47                 :     }                                                                                                     
      48                 :                                                                                                           
      49                 :     public function getLoadDefault()                                                                      
      50                 :     {                                                                                                     
      51              15 :         return $this->_loadDefault;                                                                       
      52                 :     }                                                                                                     
      53                 :                                                                                                           
      54                 :     public function setWithoutDefaultFilter()                                                             
      55                 :     {                                                                                                     
      56               0 :         $this->getSelect()->where($this->getConnection()->quoteInto('main_table.store_id>?', 0));         
      57               0 :         return $this;                                                                                     
      58                 :     }                                                                                                     
      59                 :                                                                                                           
      60                 :     /**                                                                                                   
      61                 :      * Add filter by group id.                                                                            
      62                 :      * Group id can be passed as one single value or array of values.                                     
      63                 :      *                                                                                                    
      64                 :      * @param int|array $groupId                                                                          
      65                 :      * @return Mage_Core_Model_Mysql4_Store_Collection                                                    
      66                 :      */                                                                                                   
      67                 :     public function addGroupFilter($groupId)                                                              
      68                 :     {                                                                                                     
      69               0 :         if (is_array($groupId)) {                                                                         
      70               0 :             $condition = $this->getConnection()->quoteInto("main_table.group_id IN (?)", $groupId);       
      71               0 :         } else {                                                                                          
      72               0 :             $condition = $this->getConnection()->quoteInto("main_table.group_id = ?",$groupId);           
      73                 :         }                                                                                                 
      74                 :                                                                                                           
      75               0 :         $this->addFilter('group_id', $condition, 'string');                                               
      76               0 :         return $this;                                                                                     
      77                 :     }                                                                                                     
      78                 :                                                                                                           
      79                 :     public function addIdFilter($store)                                                                   
      80                 :     {                                                                                                     
      81               0 :         if (is_array($store)) {                                                                           
      82               0 :             $condition = $this->getConnection()->quoteInto("main_table.store_id IN (?)", $store);         
      83               0 :         }                                                                                                 
      84                 :         else {                                                                                            
      85               0 :             $condition = $this->getConnection()->quoteInto("main_table.store_id=?",$store);               
      86                 :         }                                                                                                 
      87                 :                                                                                                           
      88               0 :         $this->addFilter('store_id', $condition, 'string');                                               
      89               0 :         return $this;                                                                                     
      90                 :     }                                                                                                     
      91                 :                                                                                                           
      92                 :     public function addWebsiteFilter($website)                                                            
      93                 :     {                                                                                                     
      94               0 :         if (is_array($website)) {                                                                         
      95               0 :             $condition = $this->getConnection()->quoteInto("main_table.website_id IN (?)", $website);     
      96               0 :         }                                                                                                 
      97                 :         else {                                                                                            
      98               0 :             $condition = $this->getConnection()->quoteInto("main_table.website_id=?",$website);           
      99                 :         }                                                                                                 
     100                 :                                                                                                           
     101               0 :         $this->addFilter('website_id', $condition, 'string');                                             
     102               0 :         return $this;                                                                                     
     103                 :     }                                                                                                     
     104                 :                                                                                                           
     105                 :     /**                                                                                                   
     106                 :      * Add root category id filter to store collection                                                    
     107                 :      *                                                                                                    
     108                 :      * @param   int|array $category                                                                       
     109                 :      * @return  Mage_Core_Model_Mysql4_Store_Collection                                                   
     110                 :      */                                                                                                   
     111                 :     public function addCategoryFilter($category)                                                          
     112                 :     {                                                                                                     
     113               0 :         if (!is_array($category)) {                                                                       
     114               0 :             $category = array($category);                                                                 
     115               0 :         }                                                                                                 
     116               0 :         return $this->loadByCategoryIds($category);                                                       
     117                 :     }                                                                                                     
     118                 :                                                                                                           
     119                 :     public function toOptionArray()                                                                       
     120                 :     {                                                                                                     
     121               0 :         return $this->_toOptionArray('store_id', 'name');                                                 
     122                 :     }                                                                                                     
     123                 :                                                                                                           
     124                 :     public function toOptionHash()                                                                        
     125                 :     {                                                                                                     
     126               0 :         return $this->_toOptionHash('store_id', 'name');                                                  
     127                 :     }                                                                                                     
     128                 :                                                                                                           
     129                 :     public function load($printQuery = false, $logQuery = false)                                          
     130                 :     {                                                                                                     
     131              15 :         if (!$this->getLoadDefault()) {                                                                   
     132               0 :             $this->getSelect()->where($this->getConnection()->quoteInto('main_table.store_id>?', 0));     
     133               0 :         }                                                                                                 
     134              15 :         $this->addOrder('CASE WHEN main_table.store_id = 0 THEN 0 ELSE 1 END', 'ASC')                     
     135              15 :             ->addOrder('main_table.sort_order', 'ASC')                                                    
     136              15 :             ->addOrder('main_table.name', 'ASC');                                                         
     137              15 :         parent::load($printQuery, $logQuery);                                                             
     138              15 :         return $this;                                                                                     
     139                 :     }                                                                                                     
     140                 :                                                                                                           
     141                 :     /**                                                                                                   
     142                 :      * Add root category id filter to store collection                                                    
     143                 :      *                                                                                                    
     144                 :      * @param   array $categories                                                                         
     145                 :      * @return  Mage_Core_Model_Mysql4_Store_Collection                                                   
     146                 :      */                                                                                                   
     147                 :     public function loadByCategoryIds(array $categories)                                                  
     148                 :     {                                                                                                     
     149               0 :         $this->setLoadDefault(true);                                                                      
     150               0 :         $condition = $this->getConnection()->quoteInto('group_table.root_category_id IN(?)', $categories);
     151               0 :         $this->_select->joinLeft(                                                                         
     152               0 :             array('group_table' => $this->getTable('core/store_group')),                                  
     153               0 :             'main_table.group_id=group_table.group_id',                                                   
     154               0 :             array('root_category_id')                                                                     
     155               0 :         )->where($condition);                                                                             
     156                 :                                                                                                           
     157               0 :         return $this;                                                                                     
     158                 :     }                                                                                                     
     159                 :                                                                                                           
     160                 :     public function addRootCategoryIdAttribute()                                                          
     161                 :     {                                                                                                     
     162               0 :         $this->_select->joinLeft(                                                                         
     163               0 :             array('group_table' => $this->getTable('core/store_group')),                                  
     164               0 :             'main_table.group_id=group_table.group_id',                                                   
     165               0 :             array('root_category_id')                                                                     
     166               0 :         );                                                                                                
     167               0 :         return $this;                                                                                     
     168                 :     }                                                                                                     
     169                 : }                                                                                                         

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.