Commit b8e348e5 authored by Ivan Chepurnyi's avatar Ivan Chepurnyi

Support PSR-2 Naming convension for interfaces and abstract classes

parent cdfc200a
......@@ -26,7 +26,6 @@ class EcomDev_PHPUnit_Controller_Front extends Mage_Core_Controller_Varien_Front
* Resets initialized routers before front controller re-initialization
* on test cases
*
* (non-PHPdoc)
* @see Mage_Core_Controller_Varien_Front::init()
*/
public function init()
......
......@@ -26,8 +26,8 @@
*/
class EcomDev_PHPUnit_Controller_Request_Http
extends Mage_Core_Controller_Request_Http
implements EcomDev_PHPUnit_Isolation_Interface,
EcomDev_PHPUnit_Controller_Request_Interface
implements EcomDev_PHPUnit_IsolationInterface,
EcomDev_PHPUnit_Controller_RequestInterface
{
/**
* List of $_SERVER variable changes
......@@ -47,7 +47,6 @@ class EcomDev_PHPUnit_Controller_Request_Http
/**
* Initializes forward data
*
* (non-PHPdoc)
* @see Mage_Core_Controller_Request_Http::initForward()
*/
public function initForward()
......@@ -63,7 +62,7 @@ class EcomDev_PHPUnit_Controller_Request_Http
/**
* Returns only request uri that was set before
* (non-PHPdoc)
*
* @see Zend_Controller_Request_Http::getRequestUri()
*/
public function getRequestUri()
......@@ -119,7 +118,7 @@ class EcomDev_PHPUnit_Controller_Request_Http
}
/**
* Resets $_POST superglobal for test request
* Resets $_POST super global for test request
*
* @return EcomDev_PHPUnit_Controller_Request_Http
*/
......@@ -225,7 +224,6 @@ class EcomDev_PHPUnit_Controller_Request_Http
/**
* Returns header from test request parameters
*
* (non-PHPdoc)
* @see Zend_Controller_Request_Http::getHeader()
*/
public function getHeader($header)
......@@ -261,7 +259,7 @@ class EcomDev_PHPUnit_Controller_Request_Http
}
/**
* Sets value for a particular $_SERVER superglobal array key for test request
* Sets value for a particular $_SERVER super global array key for test request
*
* Saves original value for returning it back
*
......@@ -281,7 +279,7 @@ class EcomDev_PHPUnit_Controller_Request_Http
}
/**
* Sets multiple values for $_SERVER superglobal in test request
* Sets multiple values for $_SERVER super global in test request
*
* @param array $values
* @return EcomDev_PHPUnit_Controller_Request_Http
......@@ -295,7 +293,7 @@ class EcomDev_PHPUnit_Controller_Request_Http
}
/**
* Resets $_SERVER superglobal to previous state
* Resets $_SERVER super global to previous state
*
* @return EcomDev_PHPUnit_Controller_Request_Http
*/
......@@ -306,7 +304,7 @@ class EcomDev_PHPUnit_Controller_Request_Http
$_SERVER[$name] = $value;
} elseif (isset($_SERVER[$name])) {
// If original value was not set,
// then unsetting the changed value
// then unset the changed value
unset($_SERVER[$name]);
}
}
......@@ -343,7 +341,6 @@ class EcomDev_PHPUnit_Controller_Request_Http
/**
* Returns HTTP host from base url that were set in the controller
*
* (non-PHPdoc)
* @see Mage_Core_Controller_Request_Http::getHttpHost()
*/
public function getHttpHost($trimPort = false)
......@@ -373,7 +370,6 @@ class EcomDev_PHPUnit_Controller_Request_Http
/**
* Returns only base url that was set before
*
* (non-PHPdoc)
* @see Mage_Core_Controller_Request_Http::getBaseUrl()
*/
public function getBaseUrl()
......
......@@ -26,8 +26,8 @@
*/
class EcomDev_PHPUnit_Controller_Response_Http
extends Mage_Core_Controller_Response_Http
implements EcomDev_PHPUnit_Isolation_Interface,
EcomDev_PHPUnit_Controller_Response_Interface
implements EcomDev_PHPUnit_IsolationInterface,
EcomDev_PHPUnit_Controller_ResponseInterface
{
const LINE_ENDING = "\r\n";
......@@ -39,7 +39,7 @@ class EcomDev_PHPUnit_Controller_Response_Http
protected $_sentHeaders = null;
/**
* Response that was sent via sendRespose()
* Response that was sent via sendResponse()
* or sendHeaders() or outputBody() methods
*
* @var string
......@@ -80,7 +80,6 @@ class EcomDev_PHPUnit_Controller_Response_Http
/**
* Implementation of sending the headers to output
*
* (non-PHPdoc)
* @see Mage_Core_Controller_Response_Http::sendHeaders()
*/
public function sendHeaders()
......@@ -156,7 +155,7 @@ class EcomDev_PHPUnit_Controller_Response_Http
/**
* Implementation of sending response for test case
* (non-PHPdoc)
*
* @see Mage_Core_Controller_Response_Http::sendResponse()
*/
public function sendResponse()
......@@ -213,7 +212,7 @@ class EcomDev_PHPUnit_Controller_Response_Http
/**
* Can send headers implementation for test case
*
* (non-PHPdoc)
*
* @see Zend_Controller_Response_Abstract::canSendHeaders()
*/
public function canSendHeaders($throw = false)
......
......@@ -43,7 +43,7 @@ class EcomDev_PHPUnit_Model_App extends Mage_Core_Model_App
const AREA_PART_TRANSLATE = EcomDev_PHPUnit_Model_App_Area::PART_TRANSLATE;
const AREA_PART_CONFIG = EcomDev_PHPUnit_Model_App_Area::PART_CONFIG;
const INTERFACE_ISOLATION = 'EcomDev_PHPUnit_Isolation_Interface';
const INTERFACE_ISOLATION = 'EcomDev_PHPUnit_IsolationInterface';
const REGISTRY_PATH_LAYOUT_SINGLETON = '_singleton/core/layout';
const REGISTRY_PATH_DESIGN_PACKAGE_SINGLETON = '_singleton/core/design_package';
......@@ -260,6 +260,7 @@ class EcomDev_PHPUnit_Model_App extends Mage_Core_Model_App
* @param string $configPath
* @param string $interface
* @param string $modelName
* @throws RuntimeException
* @return Mage_Core_Model_Abstract
*/
protected function _getModelFromConfig($configPath, $interface, $modelName = 'Model')
......@@ -330,6 +331,7 @@ class EcomDev_PHPUnit_Model_App extends Mage_Core_Model_App
*
* @param string $key
* @param string $value
* @return $this
*/
public function replaceRegistry($key, $value)
{
......@@ -356,7 +358,7 @@ class EcomDev_PHPUnit_Model_App extends Mage_Core_Model_App
/**
* Returns request for test suite
* (non-PHPdoc)
*
* @see Mage_Core_Model_App::getRequest()
* @return EcomDev_PHPUnit_Controller_Request_Http
*/
......@@ -374,7 +376,7 @@ class EcomDev_PHPUnit_Model_App extends Mage_Core_Model_App
/**
* Returns response for test suite
* (non-PHPdoc)
*
* @see Mage_Core_Model_App::getResponse()
* @return EcomDev_PHPUnit_Controller_Response_Http
*/
......@@ -397,6 +399,7 @@ class EcomDev_PHPUnit_Model_App extends Mage_Core_Model_App
*
* @param string $configPath
* @param string $interface
* @throws RuntimeException
* @return string
*/
protected function _getClassNameFromConfig($configPath, $interface = null)
......
......@@ -24,7 +24,7 @@
class EcomDev_PHPUnit_Model_App_Area
extends Mage_Core_Model_App_Area
implements EcomDev_PHPUnit_Isolation_Interface
implements EcomDev_PHPUnit_IsolationInterface
{
const AREA_TEST = 'test';
const AREA_ADMINHTML = 'adminhtml';
......
......@@ -118,9 +118,8 @@ class EcomDev_PHPUnit_Model_Config extends Mage_Core_Model_Config
}
/**
* Overriden for test case model instance creation mocking
* Overridden for test case model instance creation mocking
*
* (non-PHPdoc)
* @see Mage_Core_Model_Config::getModelInstance()
*/
public function getModelInstance($modelClass='', $constructArguments=array())
......@@ -133,7 +132,7 @@ class EcomDev_PHPUnit_Model_Config extends Mage_Core_Model_Config
}
/**
* Overriden for test case model instance creation mocking
* Overridden for test case model instance creation mocking
*
* (non-PHPdoc)
* @see Mage_Core_Model_Config::getModelInstance()
......@@ -170,6 +169,7 @@ class EcomDev_PHPUnit_Model_Config extends Mage_Core_Model_Config
/**
* Loads scope snapshot
*
* @throws RuntimeException
* @return EcomDev_PHPUnit_Model_Config
*/
public function loadScopeSnapshot()
......
......@@ -2,13 +2,13 @@
class EcomDev_PHPUnit_Model_Design_Package
extends Mage_Core_Model_Design_Package
implements EcomDev_PHPUnit_Design_Package_Interface,
EcomDev_PHPUnit_Isolation_Interface
implements EcomDev_PHPUnit_Design_PackageInterface,
EcomDev_PHPUnit_IsolationInterface
{
/**
* Asserts layout file existance in design packages,
* and returns actual and expected filenames as result
* Asserts layout file existence in design packages,
* and returns actual and expected file names as result
*
* @param string $fileName
* @param string $area
......
<?php
class EcomDev_PHPUnit_Model_Expectation
implements EcomDev_PHPUnit_Model_Expectation_Interface
implements EcomDev_PHPUnit_Model_ExpectationInterface
{
/**
* List of created data object ids by path format
......@@ -38,7 +38,7 @@ class EcomDev_PHPUnit_Model_Expectation
/**
* Retrieves data object for a particular path format
*
* @see EcomDev_PHPUnit_Model_Expectation_Interface::getDataObject()
* @see EcomDev_PHPUnit_Model_ExpectationInterface::getDataObject()
*/
public function getDataObject($pathFormat = null, $args = array())
{
......@@ -77,7 +77,7 @@ class EcomDev_PHPUnit_Model_Expectation
/**
* Applies loaded data
*
* @see EcomDev_PHPUnit_Model_Test_Loadable_Interface::apply()
* @see EcomDev_PHPUnit_Model_Test_LoadableInterface::apply()
*/
public function apply()
{
......@@ -89,7 +89,7 @@ class EcomDev_PHPUnit_Model_Expectation
* Removes objects created in object cache
* Clears loaded data property
*
* @see EcomDev_PHPUnit_Model_Test_Loadable_Interface::discard()
* @see EcomDev_PHPUnit_Model_Test_LoadableInterface::discard()
*/
public function discard()
{
......@@ -116,7 +116,7 @@ class EcomDev_PHPUnit_Model_Expectation
/**
* Loads expected data from test case annotations
*
* @see EcomDev_PHPUnit_Model_Test_Loadable_Interface::loadByTestCase()
* @see EcomDev_PHPUnit_Model_Test_LoadableInterface::loadByTestCase()
*/
public function loadByTestCase(PHPUnit_Framework_TestCase $testCase)
{
......
......@@ -18,27 +18,10 @@
*/
/**
* Interface for fixture model
* Can be used for creation of
* absolutely different implementation of fixture,
* then current one.
* @deprecated since 0.4.0
*
*/
interface EcomDev_PHPUnit_Model_Expectation_Interface extends EcomDev_PHPUnit_Model_Test_Loadable_Interface
interface EcomDev_PHPUnit_Model_Expectation_Interface
extends EcomDev_PHPUnit_Model_ExpectationInterface
{
/**
* Returns data object with expectations
*
* @param string $pathFormat
* @param array $args arguments for format function
* @return EcomDev_PHPUnit_Model_Expectation_Object
*/
public function getDataObject($pathFormat = null, $args = array());
/**
* Check is expectation loaded
*
* @return boolean
*/
public function isLoaded();
}
\ No newline at end of file
......@@ -59,7 +59,7 @@ class EcomDev_PHPUnit_Model_Expectation_Object
return $current;
}
/* (non-PHPdoc)
/**
* @see Iterator::key()
*/
public function key()
......@@ -67,7 +67,7 @@ class EcomDev_PHPUnit_Model_Expectation_Object
return current($this->_iterationKeys);
}
/* (non-PHPdoc)
/**
* @see Iterator::next()
*/
public function next()
......@@ -75,7 +75,7 @@ class EcomDev_PHPUnit_Model_Expectation_Object
next($this->_iterationKeys);
}
/* (non-PHPdoc)
/**
* @see Iterator::rewind()
*/
public function rewind()
......@@ -83,7 +83,7 @@ class EcomDev_PHPUnit_Model_Expectation_Object
$this->_iterationKeys = $this->keys();
}
/* (non-PHPdoc)
/**
* @see Iterator::valid()
*/
public function valid()
......
<?php
/**
* PHP Unit test suite for Magento
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
*
* @category EcomDev
* @package EcomDev_PHPUnit
* @copyright Copyright (c) 2013 EcomDev BV (http://www.ecomdev.org)
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* @author Ivan Chepurnyi <ivan.chepurnyi@ecomdev.org>
*/
/**
* Interface for fixture model
* Can be used for creation of
* absolutely different implementation of fixture,
* then current one.
*
*/
interface EcomDev_PHPUnit_Model_ExpectationInterface extends EcomDev_PHPUnit_Model_LoadableInterface
{
/**
* Returns data object with expectations
*
* @param string $pathFormat
* @param array $args arguments for format function
* @return EcomDev_PHPUnit_Model_Expectation_Object
*/
public function getDataObject($pathFormat = null, $args = array());
/**
* Check is expectation loaded
*
* @return boolean
*/
public function isLoaded();
}
\ No newline at end of file
......@@ -25,7 +25,7 @@
*/
class EcomDev_PHPUnit_Model_Fixture
extends Varien_Object
implements EcomDev_PHPUnit_Model_Fixture_Interface
implements EcomDev_PHPUnit_Model_FixtureInterface
{
// Configuration path for eav loaders
/* @deprecated since 0.3.0 */
......@@ -80,7 +80,7 @@ class EcomDev_PHPUnit_Model_Fixture
* 'node/path' => 'value'
* ),
* 'table' => array(
* 'tablename' => array(
* 'table/name' => array(
* array(
* 'column1' => 'value'
* 'column2' => 'value'
......@@ -125,7 +125,7 @@ class EcomDev_PHPUnit_Model_Fixture
/**
* Processors list
*
* @var EcomDev_PHPUnit_Model_Fixture_Processor_Interface[]
* @var EcomDev_PHPUnit_Model_Fixture_ProcessorInterface[]
*/
protected $_processors = array();
......@@ -253,7 +253,7 @@ class EcomDev_PHPUnit_Model_Fixture
/**
* Sets current fixture scope
*
* @param string $scope EcomDev_PHPUnit_Model_Fixture_Interface::SCOPE_LOCAL|EcomDev_PHPUnit_Model_Fixture_Interface::SCOPE_SHARED
* @param string $scope EcomDev_PHPUnit_Model_FixtureInterface::SCOPE_LOCAL|EcomDev_PHPUnit_Model_FixtureInterface::SCOPE_SHARED
* @return EcomDev_PHPUnit_Model_Fixture
*/
public function setScope($scope)
......@@ -421,7 +421,7 @@ class EcomDev_PHPUnit_Model_Fixture
/**
* Returns list of available processors for fixture
*
* @return EcomDev_PHPUnit_Model_Fixture_Processor_Interface[]
* @return EcomDev_PHPUnit_Model_Fixture_ProcessorInterface[]
*/
public function getProcessors()
{
......@@ -429,7 +429,7 @@ class EcomDev_PHPUnit_Model_Fixture
$processorsNode = Mage::getConfig()->getNode(self::XML_PATH_FIXTURE_PROCESSORS);
foreach ($processorsNode->children() as $code => $processorAlias) {
$processor = Mage::getSingleton((string)$processorAlias);
if ($processor instanceof EcomDev_PHPUnit_Model_Fixture_Processor_Interface) {
if ($processor instanceof EcomDev_PHPUnit_Model_Fixture_ProcessorInterface) {
$this->_processors[$code] = $processor;
}
}
......@@ -613,7 +613,7 @@ class EcomDev_PHPUnit_Model_Fixture
* Retrieves eav loader for a particular entity type
*
* @param string $entityType
* @return EcomDev_PHPUnit_Model_Mysql4_Fixture_Eav_Abstract
* @return EcomDev_PHPUnit_Model_Mysql4_Fixture_AbstractEav
* @deprecated since 0.3.0
*/
protected function _getEavLoader($entityType)
......@@ -636,7 +636,7 @@ class EcomDev_PHPUnit_Model_Fixture
throw new InvalidArgumentException('Must specify a data type for the loader');
}
$reflection = EcomDev_Utils_Reflection::getRelflection($this);
$reflection = EcomDev_Utils_Reflection::getReflection($this);
$loaders = Mage::getConfig()->getNode($reflection->getConstant("XML_PATH_FIXTURE_{$dataType}_LOADERS"));
......
......@@ -17,137 +17,10 @@
*/
/**
* Interface for fixture model
* Can be used for creation of
* absolutely different implementation of fixture,
* then current one.
*
* @deprecated since 0.4.0
*/
interface EcomDev_PHPUnit_Model_Fixture_Interface extends EcomDev_PHPUnit_Model_Test_Loadable_Interface
interface EcomDev_PHPUnit_Model_Fixture_Interface
extends EcomDev_PHPUnit_Model_FixtureInterface
{
/** Local scope - used for fixtures that apply only to the current test */
const SCOPE_LOCAL = 'local';
/** Shared scope - used for fixtures that apply to the current test class */
const SCOPE_SHARED = 'shared';
/** Default scope - used for storing data that exists in database before tests are run */
const SCOPE_DEFAULT = 'default';
/**
* Sets fixture options
*
* @param array $options
* @return EcomDev_PHPUnit_Model_Fixture_Interface
*/
public function setOptions(array $options);
/**
* Sets fixture options
*
* @return array
*/
public function getOptions();
/**
* Sets storage for fixtures
*
* @param Varien_Object $storage
* @return EcomDev_PHPUnit_Model_Fixture_Interface
*/
public function setStorage(Varien_Object $storage);
/**
* Retrieve fixture storage
*
* @return Varien_Object
*/
public function getStorage();
/**
* Retrieves storage data for a particular fixture scope
*
* @param string $key
* @param string|null $scope
*/
public function getStorageData($key, $scope = null);
/**
* Sets storage data for a particular fixture scope
*
* @param string $key
* @param mixed $value
* @param string|null $scope
*/
public function setStorageData($key, $value, $scope = null);
/**
* Returns current fixture scope
*
* @return string
*/
public function getScope();
/**
* Sets current fixture scope
*
*
* @param string $scope EcomDev_PHPUnit_Model_Fixture_Interface::SCOPE_LOCAL|EcomDev_PHPUnit_Model_Fixture_Interface::SCOPE_SHARED
*/
public function setScope($scope);
/**
* Check that current fixture scope is equal to SCOPE_DEFAULT
*
* @abstract
* @return boolean
*/
public function isScopeDefault();
/**
* Check that current fixture scope is equal to SCOPE_SHARED
*
* @return boolean
*/
public function isScopeShared();
/**
* Check that current fixture scope is equal to SCOPE_LOCAL
*
* @return boolean
*/
public function isScopeLocal();
/**
* Loads fixture files from test class annotations
*
* @param string $className
* @return EcomDev_PHPUnit_Model_Fixture_Interface
*/
public function loadForClass($className);
/**
* Sets fixture value
*
* @param string $key
* @param array[] $value
*
* @return EcomDev_PHPUnit_Model_Fixture_Interface
*/
public function setFixtureValue($key, $value);
/**
* Retrieves fixture value
*
* @param string $key
*
* @return array[]
*/
public function getFixtureValue($key);
/**
* Returns VFS wrapper instance
*
* @return EcomDev_PHPUnit_Model_Fixture_Vfs
*/
public function getVfs();
}
......@@ -21,7 +21,7 @@
class EcomDev_PHPUnit_Model_Fixture_Processor_Attributes
extends Mage_Core_Model_Abstract
implements EcomDev_PHPUnit_Model_Fixture_Processor_Interface
implements EcomDev_PHPUnit_Model_Fixture_ProcessorInterface
{
const STORAGE_KEY = 'entities';
......@@ -45,10 +45,10 @@ class EcomDev_PHPUnit_Model_Fixture_Processor_Attributes
/**
* Does nothing
*
* @param EcomDev_PHPUnit_Model_Fixture_Interface $fixture
* @param EcomDev_PHPUnit_Model_FixtureInterface $fixture
* @return EcomDev_PHPUnit_Model_Fixture_Processor_Attributes
*/
public function initialize(EcomDev_PHPUnit_Model_Fixture_Interface $fixture)
public function initialize(EcomDev_PHPUnit_Model_FixtureInterface $fixture)
{
return $this;
}
......@@ -80,11 +80,11 @@ class EcomDev_PHPUnit_Model_Fixture_Processor_Attributes
*
* @param array $data
* @param string $key
* @param EcomDev_PHPUnit_Model_Fixture_Interface $fixture
* @param EcomDev_PHPUnit_Model_FixtureInterface $fixture
*
* @return EcomDev_PHPUnit_Model_Fixture_Processor_Attributes
*/
public function apply(array $data, $key, EcomDev_PHPUnit_Model_Fixture_Interface $fixture)
public function apply(array $data, $key, EcomDev_PHPUnit_Model_FixtureInterface $fixture)
{
$attributeLoaders = array();
......@@ -112,20 +112,20 @@ class EcomDev_PHPUnit_Model_Fixture_Processor_Attributes
*
* @param array[] $data
* @param string $key
* @param EcomDev_PHPUnit_Model_Fixture_Interface $fixture
* @param EcomDev_PHPUnit_Model_FixtureInterface $fixture
*
* @return EcomDev_PHPUnit_Model_Fixture_Processor_Attributes
*/
public function discard(array $data, $key, EcomDev_PHPUnit_Model_Fixture_Interface $fixture)
public function discard(array $data, $key, EcomDev_PHPUnit_Model_FixtureInterface $fixture)
{
$ignoreCleanUp = array();
// Ignore cleaning of entities if shared fixture loaded something for them
if ($fixture->isScopeLocal()
&& $fixture->getStorageData(self::STORAGE_KEY,
EcomDev_PHPUnit_Model_Fixture_Interface::SCOPE_SHARED)) {
EcomDev_PHPUnit_Model_FixtureInterface::SCOPE_SHARED)) {
$ignoreCleanUp = $fixture->getStorageData(self::STORAGE_KEY,
EcomDev_PHPUnit_Model_Fixture_Interface::SCOPE_SHARED);
EcomDev_PHPUnit_Model_FixtureInterface::SCOPE_SHARED);
}
$this->getResource()->beginTransaction();
......
......@@ -16,17 +16,17 @@
* @author Ivan Chepurnyi <ivan.chepurnyi@ecomdev.org>
*/
class EcomDev_PHPUnit_Model_Fixture_Processor_Cache implements EcomDev_PHPUnit_Model_Fixture_Processor_Interface
class EcomDev_PHPUnit_Model_Fixture_Processor_Cache implements EcomDev_PHPUnit_Model_Fixture_ProcessorInterface
{
const STORAGE_KEY = 'cache_options';
/**
* Initializes cache options
*
* @param EcomDev_PHPUnit_Model_Fixture_Interface $fixture
* @param EcomDev_PHPUnit_Model_FixtureInterface $fixture
* @return EcomDev_PHPUnit_Model_Fixture_Processor_Cache
*/
public function initialize(EcomDev_PHPUnit_Model_Fixture_Interface $fixture)
public function initialize(EcomDev_PHPUnit_Model_FixtureInterface $fixture)
{
$options = $fixture->getOptions();
if (isset($options['cache'])) {
......@@ -54,11 +54,11 @@ class EcomDev_PHPUnit_Model_Fixture_Processor_Cache implements EcomDev_PHPUnit_M
*
* @param array $data
* @param string $key
* @param EcomDev_PHPUnit_Model_Fixture_Interface $fixture
* @param EcomDev_PHPUnit_Model_FixtureInterface $fixture
*
* @return EcomDev_PHPUnit_Model_Fixture_Processor_Cache
*/
public function apply(array $data, $key, EcomDev_PHPUnit_Model_Fixture_Interface $fixture)
public function apply(array $data, $key, EcomDev_PHPUnit_Model_FixtureInterface $fixture)
{
$originalOptions = EcomDev_PHPUnit_Test_Case_Util::app()->getCacheOptions();
$fixture->setStorageData(self::STORAGE_KEY, $originalOptions);
......@@ -73,11 +73,11 @@ class EcomDev_PHPUnit_Model_Fixture_Processor_Cache implements EcomDev_PHPUnit_M
*
* @param array[] $data
* @param string $key
* @param EcomDev_PHPUnit_Model_Fixture_Interface $fixture
* @param EcomDev_PHPUnit_Model_FixtureInterface $fixture
*
* @return EcomDev_PHPUnit_Model_Fixture_Processor_Cache
*/
public function discard(array $data, $key, EcomDev_PHPUnit_Model_Fixture_Interface $fixture)
public function discard(array $data, $key, EcomDev_PHPUnit_Model_FixtureInterface $fixture)
{
EcomDev_PHPUnit_Test_Case_Util::app()->setCacheOptions(
$fixture->getStorageData(self::STORAGE_KEY)
......
......@@ -16,15 +16,16 @@
* @author Ivan Chepurnyi <ivan.chepurnyi@ecomdev.org>
*/
class EcomDev_PHPUnit_Model_Fixture_Processor_Config implements EcomDev_PHPUnit_Model_Fixture_Processor_Interface
class EcomDev_PHPUnit_Model_Fixture_Processor_Config
implements EcomDev_PHPUnit_Model_Fixture_ProcessorInterface
{
/**
* Does nothing
*
* @param EcomDev_PHPUnit_Model_Fixture_Interface $fixture
* @return EcomDev_PHPUnit_Model_Fixture_Processor_Config
* @param EcomDev_PHPUnit_Model_FixtureInterface $fixture
* @return $this
*/
public function initialize(EcomDev_PHPUnit_Model_Fixture_Interface $fixture)
public function initialize(EcomDev_PHPUnit_Model_FixtureInterface $fixture)
{
return $this;
}
......@@ -34,11 +35,11 @@ class EcomDev_PHPUnit_Model_Fixture_Processor_Config implements EcomDev_PHPUnit_
*
* @param array $data
* @param string $key
* @param EcomDev_PHPUnit_Model_Fixture_Interface $fixture
* @param EcomDev_PHPUnit_Model_FixtureInterface $fixture
*
* @return EcomDev_PHPUnit_Model_Fixture_Processor_Config
* @return $this
*/
public function apply(array $data, $key, EcomDev_PHPUnit_Model_Fixture_Interface $fixture)
public function apply(array $data, $key, EcomDev_PHPUnit_Model_FixtureInterface $fixture)
{
$key === 'config_xml' ? $this->_applyConfigXml($data) : $this->_applyConfig($data);
return $this;
......@@ -48,7 +49,7 @@ class EcomDev_PHPUnit_Model_Fixture_Processor_Config implements EcomDev_PHPUnit_
* Applies fixture configuration values into Mage_Core_Model_Config
*
* @param array $configuration
* @return EcomDev_PHPUnit_Model_Fixture_Processor_Config
* @return $this
* @throws InvalidArgumentException
*/
protected function _applyConfig($configuration)
......@@ -83,7 +84,7 @@ class EcomDev_PHPUnit_Model_Fixture_Processor_Config implements EcomDev_PHPUnit_
* Applies raw xml data to config node
*
* @param array $configuration
* @return EcomDev_PHPUnit_Model_Fixture_Processor_Config
* @return $this
* @throws InvalidArgumentException
*/
protected function _applyConfigXml($configuration)
......@@ -119,11 +120,11 @@ class EcomDev_PHPUnit_Model_Fixture_Processor_Config implements EcomDev_PHPUnit_
*
* @param array[] $data
* @param string $key
* @param EcomDev_PHPUnit_Model_Fixture_Interface $fixture
* @param EcomDev_PHPUnit_Model_FixtureInterface $fixture
*
* @return EcomDev_PHPUnit_Model_Fixture_Processor_Config
* @return $this
*/
public function discard(array $data, $key, EcomDev_PHPUnit_Model_Fixture_Interface $fixture)
public function discard(array $data, $key, EcomDev_PHPUnit_Model_FixtureInterface $fixture)
{
$this->_restoreConfig();
return $this;
......@@ -147,7 +148,7 @@ class EcomDev_PHPUnit_Model_Fixture_Processor_Config implements EcomDev_PHPUnit_
* @param string $path
* @param string $value
*
* @return EcomDev_PHPUnit_Model_Fixture_Processor_Config
* @return $this
*/
protected function _setConfigNodeValue($path, $value)
{
......
......@@ -19,7 +19,7 @@
class EcomDev_PHPUnit_Model_Fixture_Processor_Eav
extends Mage_Core_Model_Abstract
implements EcomDev_PHPUnit_Model_Fixture_Processor_Interface
implements EcomDev_PHPUnit_Model_Fixture_ProcessorInterface
{
const STORAGE_KEY = 'entities';
......@@ -43,10 +43,10 @@ class EcomDev_PHPUnit_Model_Fixture_Processor_Eav
/**
* Does nothing
*
* @param EcomDev_PHPUnit_Model_Fixture_Interface $fixture
* @param EcomDev_PHPUnit_Model_FixtureInterface $fixture
* @return EcomDev_PHPUnit_Model_Fixture_Processor_Eav
*/
public function initialize(EcomDev_PHPUnit_Model_Fixture_Interface $fixture)
public function initialize(EcomDev_PHPUnit_Model_FixtureInterface $fixture)
{
return $this;
}
......@@ -55,7 +55,7 @@ class EcomDev_PHPUnit_Model_Fixture_Processor_Eav
* Retrieves eav loader for a particular entity type
*
* @param string $entityType
* @return EcomDev_PHPUnit_Model_Mysql4_Fixture_Eav_Abstract
* @return EcomDev_PHPUnit_Model_Mysql4_Fixture_AbstractEav
*/
protected function _getEavLoader($entityType)
{
......@@ -78,11 +78,11 @@ class EcomDev_PHPUnit_Model_Fixture_Processor_Eav
*
* @param array $data
* @param string $key
* @param EcomDev_PHPUnit_Model_Fixture_Interface $fixture
* @param EcomDev_PHPUnit_Model_FixtureInterface $fixture
*
* @return EcomDev_PHPUnit_Model_Fixture_Processor_Eav
*/
public function apply(array $data, $key, EcomDev_PHPUnit_Model_Fixture_Interface $fixture)
public function apply(array $data, $key, EcomDev_PHPUnit_Model_FixtureInterface $fixture)
{
$eavLoaders = array();
......@@ -110,20 +110,20 @@ class EcomDev_PHPUnit_Model_Fixture_Processor_Eav
*
* @param array[] $data
* @param string $key
* @param EcomDev_PHPUnit_Model_Fixture_Interface $fixture
* @param EcomDev_PHPUnit_Model_FixtureInterface $fixture
*
* @return EcomDev_PHPUnit_Model_Fixture_Processor_Eav
*/
public function discard(array $data, $key, EcomDev_PHPUnit_Model_Fixture_Interface $fixture)
public function discard(array $data, $key, EcomDev_PHPUnit_Model_FixtureInterface $fixture)
{
$ignoreCleanUp = array();
// Ignore cleaning of entities if shared fixture loaded something for them
if ($fixture->isScopeLocal()
&& $fixture->getStorageData(self::STORAGE_KEY,
EcomDev_PHPUnit_Model_Fixture_Interface::SCOPE_SHARED)) {
EcomDev_PHPUnit_Model_FixtureInterface::SCOPE_SHARED)) {
$ignoreCleanUp = $fixture->getStorageData(self::STORAGE_KEY,
EcomDev_PHPUnit_Model_Fixture_Interface::SCOPE_SHARED);
EcomDev_PHPUnit_Model_FixtureInterface::SCOPE_SHARED);
}
$this->getResource()->beginTransaction();
......
......@@ -16,35 +16,11 @@
* @author Ivan Chepurnyi <ivan.chepurnyi@ecomdev.org>
*/
/**
* @deprecated since 0.4.0
*/
interface EcomDev_PHPUnit_Model_Fixture_Processor_Interface
extends EcomDev_PHPUnit_Model_Fixture_ProcessorInterface
{
/**
* Applies data from fixture file
*
* @param array[] $data
* @param string $key
* @param EcomDev_PHPUnit_Model_Fixture_Interface $fixture
*
* @return EcomDev_PHPUnit_Model_Fixture_Processor_Interface
*/
public function apply(array $data, $key, EcomDev_PHPUnit_Model_Fixture_Interface $fixture);
/**
* Discards data from fixture file
*
* @param array[] $data
* @param string $key
* @param EcomDev_PHPUnit_Model_Fixture_Interface $fixture
*
* @return EcomDev_PHPUnit_Model_Fixture_Processor_Interface
*/
public function discard(array $data, $key, EcomDev_PHPUnit_Model_Fixture_Interface $fixture);
/**
* Initializes fixture processor before applying data
*
* @param EcomDev_PHPUnit_Model_Fixture_Interface $fixture
* @return EcomDev_PHPUnit_Model_Fixture_Processor_Interface
*/
public function initialize(EcomDev_PHPUnit_Model_Fixture_Interface $fixture);
}
......@@ -37,7 +37,8 @@
* - core/url
*
*/
class EcomDev_PHPUnit_Model_Fixture_Processor_Registry implements EcomDev_PHPUnit_Model_Fixture_Processor_Interface
class EcomDev_PHPUnit_Model_Fixture_Processor_Registry
implements EcomDev_PHPUnit_Model_Fixture_ProcessorInterface
{
const STORAGE_KEY = 'registry';
......@@ -46,12 +47,12 @@ class EcomDev_PHPUnit_Model_Fixture_Processor_Registry implements EcomDev_PHPUni
*
* @param array[] $data
* @param string $key
* @param EcomDev_PHPUnit_Model_Fixture_Interface $fixture
* @param EcomDev_PHPUnit_Model_FixtureInterface $fixture
*
* @return EcomDev_PHPUnit_Model_Fixture_Processor_Registry
* @throws RuntimeException
*/
public function apply(array $data, $key, EcomDev_PHPUnit_Model_Fixture_Interface $fixture)
public function apply(array $data, $key, EcomDev_PHPUnit_Model_FixtureInterface $fixture)
{
$typeToKey = array(
'singleton' => '_singleton/',
......@@ -88,11 +89,11 @@ class EcomDev_PHPUnit_Model_Fixture_Processor_Registry implements EcomDev_PHPUni
*
* @param array[] $data
* @param string $key
* @param EcomDev_PHPUnit_Model_Fixture_Interface $fixture
* @param EcomDev_PHPUnit_Model_FixtureInterface $fixture
*
* @return EcomDev_PHPUnit_Model_Fixture_Processor_Interface
* @return EcomDev_PHPUnit_Model_Fixture_ProcessorInterface
*/
public function discard(array $data, $key, EcomDev_PHPUnit_Model_Fixture_Interface $fixture)
public function discard(array $data, $key, EcomDev_PHPUnit_Model_FixtureInterface $fixture)
{
if ($fixture->getStorageData(self::STORAGE_KEY) === null) {
return $this;
......@@ -111,10 +112,10 @@ class EcomDev_PHPUnit_Model_Fixture_Processor_Registry implements EcomDev_PHPUni
/**
* Initializes fixture processor before applying data
*
* @param EcomDev_PHPUnit_Model_Fixture_Interface $fixture
* @param EcomDev_PHPUnit_Model_FixtureInterface $fixture
* @return EcomDev_PHPUnit_Model_Fixture_Processor_Registry
*/
public function initialize(EcomDev_PHPUnit_Model_Fixture_Interface $fixture)
public function initialize(EcomDev_PHPUnit_Model_FixtureInterface $fixture)
{
$options = $fixture->getOptions();
$registry = array();
......
......@@ -17,7 +17,7 @@
*/
class EcomDev_PHPUnit_Model_Fixture_Processor_Scope
implements EcomDev_PHPUnit_Model_Fixture_Processor_Interface
implements EcomDev_PHPUnit_Model_Fixture_ProcessorInterface
{
const STORAGE_KEY = 'scope';
......@@ -35,10 +35,10 @@ class EcomDev_PHPUnit_Model_Fixture_Processor_Scope
/**
* Does nothing
*
* @param EcomDev_PHPUnit_Model_Fixture_Interface $fixture
* @param EcomDev_PHPUnit_Model_FixtureInterface $fixture
* @return EcomDev_PHPUnit_Model_Fixture_Processor_Scope
*/
public function initialize(EcomDev_PHPUnit_Model_Fixture_Interface $fixture)
public function initialize(EcomDev_PHPUnit_Model_FixtureInterface $fixture)
{
return $this;
}
......@@ -48,18 +48,18 @@ class EcomDev_PHPUnit_Model_Fixture_Processor_Scope
*
* @param string $type
* @param array $row
* @param EcomDev_PHPUnit_Model_Fixture_Interface $fixture
* @param EcomDev_PHPUnit_Model_FixtureInterface $fixture
* @return boolean|Mage_Core_Model_Abstract
*/
protected function _handleScopeRow($type, $row, EcomDev_PHPUnit_Model_Fixture_Interface $fixture)
protected function _handleScopeRow($type, $row, EcomDev_PHPUnit_Model_FixtureInterface $fixture)
{
$previousScope = array();
if ($fixture->isScopeLocal()
&& $fixture->getStorageData(self::STORAGE_KEY,
EcomDev_PHPUnit_Model_Fixture_Interface::SCOPE_SHARED) !== null) {
EcomDev_PHPUnit_Model_FixtureInterface::SCOPE_SHARED) !== null) {
$previousScope = $fixture->getStorageData(self::STORAGE_KEY,
EcomDev_PHPUnit_Model_Fixture_Interface::SCOPE_SHARED);
EcomDev_PHPUnit_Model_FixtureInterface::SCOPE_SHARED);
}
if (isset($previousScope[$type][$row[$type . '_id']])) {
......@@ -135,12 +135,12 @@ class EcomDev_PHPUnit_Model_Fixture_Processor_Scope
*
* @param array $data
* @param string $key
* @param EcomDev_PHPUnit_Model_Fixture_Interface $fixture
* @param EcomDev_PHPUnit_Model_FixtureInterface $fixture
*
* @throws RuntimeException
* @return EcomDev_PHPUnit_Model_Fixture_Processor_Scope
*/
public function apply(array $data, $key, EcomDev_PHPUnit_Model_Fixture_Interface $fixture)
public function apply(array $data, $key, EcomDev_PHPUnit_Model_FixtureInterface $fixture)
{
EcomDev_PHPUnit_Test_Case_Util::app()->disableEvents();
// Validate received fixture data
......@@ -173,11 +173,11 @@ class EcomDev_PHPUnit_Model_Fixture_Processor_Scope
*
* @param array[] $data
* @param string $key
* @param EcomDev_PHPUnit_Model_Fixture_Interface $fixture
* @param EcomDev_PHPUnit_Model_FixtureInterface $fixture
*
* @return EcomDev_PHPUnit_Model_Fixture_Processor_Scope
*/
public function discard(array $data, $key, EcomDev_PHPUnit_Model_Fixture_Interface $fixture)
public function discard(array $data, $key, EcomDev_PHPUnit_Model_FixtureInterface $fixture)
{
if ($fixture->getStorageData(self::STORAGE_KEY) === null) {
return $this;
......
......@@ -19,7 +19,7 @@
class EcomDev_PHPUnit_Model_Fixture_Processor_Tables
extends Mage_Core_Model_Abstract
implements EcomDev_PHPUnit_Model_Fixture_Processor_Interface
implements EcomDev_PHPUnit_Model_Fixture_ProcessorInterface
{
const STORAGE_KEY = 'tables';
......@@ -35,10 +35,10 @@ class EcomDev_PHPUnit_Model_Fixture_Processor_Tables
/**
* Does nothing
*
* @param EcomDev_PHPUnit_Model_Fixture_Interface $fixture
* @param EcomDev_PHPUnit_Model_FixtureInterface $fixture
* @return EcomDev_PHPUnit_Model_Fixture_Processor_Tables
*/
public function initialize(EcomDev_PHPUnit_Model_Fixture_Interface $fixture)
public function initialize(EcomDev_PHPUnit_Model_FixtureInterface $fixture)
{
return $this;
}
......@@ -48,11 +48,11 @@ class EcomDev_PHPUnit_Model_Fixture_Processor_Tables
*
* @param array $data
* @param string $key
* @param EcomDev_PHPUnit_Model_Fixture_Interface $fixture
* @param EcomDev_PHPUnit_Model_FixtureInterface $fixture
*
* @return EcomDev_PHPUnit_Model_Fixture_Processor_Tables
*/
public function apply(array $data, $key, EcomDev_PHPUnit_Model_Fixture_Interface $fixture)
public function apply(array $data, $key, EcomDev_PHPUnit_Model_FixtureInterface $fixture)
{
$ignoreCleanUp = array();
......@@ -60,9 +60,9 @@ class EcomDev_PHPUnit_Model_Fixture_Processor_Tables
// Ignore cleaning of tables if shared fixture loaded something
if ($fixture->isScopeLocal()
&& $fixture->getStorageData(self::STORAGE_KEY,
EcomDev_PHPUnit_Model_Fixture_Interface::SCOPE_SHARED)) {
EcomDev_PHPUnit_Model_FixtureInterface::SCOPE_SHARED)) {
$ignoreCleanUp = array_keys($fixture->getStorageData(self::STORAGE_KEY,
EcomDev_PHPUnit_Model_Fixture_Interface::SCOPE_SHARED));
EcomDev_PHPUnit_Model_FixtureInterface::SCOPE_SHARED));
}
$this->getResource()->beginTransaction();
......@@ -86,20 +86,20 @@ class EcomDev_PHPUnit_Model_Fixture_Processor_Tables
*
* @param array[] $data
* @param string $key
* @param EcomDev_PHPUnit_Model_Fixture_Interface $fixture
* @param EcomDev_PHPUnit_Model_FixtureInterface $fixture
*
* @return EcomDev_PHPUnit_Model_Fixture_Processor_Tables
*/
public function discard(array $data, $key, EcomDev_PHPUnit_Model_Fixture_Interface $fixture)
public function discard(array $data, $key, EcomDev_PHPUnit_Model_FixtureInterface $fixture)
{
$restoreTableData = array();
// Data for tables used in shared fixture
if ($fixture->isScopeLocal()
&& $fixture->getStorageData(self::STORAGE_KEY,
EcomDev_PHPUnit_Model_Fixture_Interface::SCOPE_SHARED)) {
EcomDev_PHPUnit_Model_FixtureInterface::SCOPE_SHARED)) {
$restoreTableData = $fixture->getStorageData(self::STORAGE_KEY,
EcomDev_PHPUnit_Model_Fixture_Interface::SCOPE_SHARED);
EcomDev_PHPUnit_Model_FixtureInterface::SCOPE_SHARED);
}
$this->getResource()->beginTransaction();
......
......@@ -17,17 +17,17 @@
*/
class EcomDev_PHPUnit_Model_Fixture_Processor_Vfs implements EcomDev_PHPUnit_Model_Fixture_Processor_Interface
class EcomDev_PHPUnit_Model_Fixture_Processor_Vfs implements EcomDev_PHPUnit_Model_Fixture_ProcessorInterface
{
const STORAGE_KEY = 'vfs';
/**
* Does nothing
*
* @param EcomDev_PHPUnit_Model_Fixture_Interface $fixture
* @param EcomDev_PHPUnit_Model_FixtureInterface $fixture
* @return EcomDev_PHPUnit_Model_Fixture_Processor_Cache
*/
public function initialize(EcomDev_PHPUnit_Model_Fixture_Interface $fixture)
public function initialize(EcomDev_PHPUnit_Model_FixtureInterface $fixture)
{
return $this;
}
......@@ -37,15 +37,15 @@ class EcomDev_PHPUnit_Model_Fixture_Processor_Vfs implements EcomDev_PHPUnit_Mod
*
* @param array $data
* @param string $key
* @param EcomDev_PHPUnit_Model_Fixture_Interface $fixture
* @param EcomDev_PHPUnit_Model_FixtureInterface $fixture
*
* @return EcomDev_PHPUnit_Model_Fixture_Processor_Cache
*/
public function apply(array $data, $key, EcomDev_PHPUnit_Model_Fixture_Interface $fixture)
public function apply(array $data, $key, EcomDev_PHPUnit_Model_FixtureInterface $fixture)
{
if ($fixture->isScopeLocal()
&& ($parentData = $fixture->getStorageData(self::STORAGE_KEY,
EcomDev_PHPUnit_Model_Fixture_Interface::SCOPE_SHARED))) {
EcomDev_PHPUnit_Model_FixtureInterface::SCOPE_SHARED))) {
$data = array_merge_recursive($parentData, $data);
}
......@@ -60,11 +60,11 @@ class EcomDev_PHPUnit_Model_Fixture_Processor_Vfs implements EcomDev_PHPUnit_Mod
*
* @param array[] $data
* @param string $key
* @param EcomDev_PHPUnit_Model_Fixture_Interface $fixture
* @param EcomDev_PHPUnit_Model_FixtureInterface $fixture
*
* @return EcomDev_PHPUnit_Model_Fixture_Processor_Cache
*/
public function discard(array $data, $key, EcomDev_PHPUnit_Model_Fixture_Interface $fixture)
public function discard(array $data, $key, EcomDev_PHPUnit_Model_FixtureInterface $fixture)
{
$fixture->getVfs()->discard();
$fixture->setStorageData(self::STORAGE_KEY, null);
......
<?php
/**
* PHP Unit test suite for Magento
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
*
* @category EcomDev
* @package EcomDev_PHPUnit
* @copyright Copyright (c) 2013 EcomDev BV (http://www.ecomdev.org)
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* @author Ivan Chepurnyi <ivan.chepurnyi@ecomdev.org>
*/
interface EcomDev_PHPUnit_Model_Fixture_ProcessorInterface
{
/**
* Applies data from fixture file
*
* @param array[] $data
* @param string $key
* @param EcomDev_PHPUnit_Model_FixtureInterface $fixture
*
* @return EcomDev_PHPUnit_Model_Fixture_ProcessorInterface
*/
public function apply(array $data, $key, EcomDev_PHPUnit_Model_FixtureInterface $fixture);
/**
* Discards data from fixture file
*
* @param array[] $data
* @param string $key
* @param EcomDev_PHPUnit_Model_FixtureInterface $fixture
*
* @return $this
*/
public function discard(array $data, $key, EcomDev_PHPUnit_Model_FixtureInterface $fixture);
/**
* Initializes fixture processor before applying data
*
* @param EcomDev_PHPUnit_Model_FixtureInterface $fixture
* @return $this
*/
public function initialize(EcomDev_PHPUnit_Model_FixtureInterface $fixture);
}
\ No newline at end of file
......@@ -38,8 +38,7 @@ class EcomDev_PHPUnit_Model_Fixture_Vfs
/**
* Applies VFS directory structure
*
* @param $data
* @param bool $cloneCurrent
* @param array $data
*
* @return EcomDev_PHPUnit_Model_Fixture_Vfs
*/
......
<?php
/**
* PHP Unit test suite for Magento
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
*
* @category EcomDev
* @package EcomDev_PHPUnit
* @copyright Copyright (c) 2013 EcomDev BV (http://www.ecomdev.org)
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* @author Ivan Chepurnyi <ivan.chepurnyi@ecomdev.org>
*/
/**
* Interface for fixture model
* Can be used for creation of
* absolutely different implementation of fixture,
* then current one.
*
*/
interface EcomDev_PHPUnit_Model_FixtureInterface
extends EcomDev_PHPUnit_Model_LoadableInterface
{
/** Local scope - used for fixtures that apply only to the current test */
const SCOPE_LOCAL = 'local';
/** Shared scope - used for fixtures that apply to the current test class */
const SCOPE_SHARED = 'shared';
/** Default scope - used for storing data that exists in database before tests are run */
const SCOPE_DEFAULT = 'default';
/**
* Sets fixture options
*
* @param array $options
* @return $this
*/
public function setOptions(array $options);
/**
* Sets fixture options
*
* @return array
*/
public function getOptions();
/**
* Sets storage for fixtures
*
* @param Varien_Object $storage
* @return $this
*/
public function setStorage(Varien_Object $storage);
/**
* Retrieve fixture storage
*
* @return Varien_Object
*/
public function getStorage();
/**
* Retrieves storage data for a particular fixture scope
*
* @param string $key
* @param string|null $scope
*/
public function getStorageData($key, $scope = null);
/**
* Sets storage data for a particular fixture scope
*
* @param string $key
* @param mixed $value
* @param string|null $scope
*/
public function setStorageData($key, $value, $scope = null);
/**
* Returns current fixture scope
*
* @return string
*/
public function getScope();
/**
* Sets current fixture scope
*
*
* @param string $scope EcomDev_PHPUnit_Model_FixtureInterface::SCOPE_LOCAL|EcomDev_PHPUnit_Model_FixtureInterface::SCOPE_SHARED
*/
public function setScope($scope);
/**
* Check that current fixture scope is equal to SCOPE_DEFAULT
*
* @abstract
* @return boolean
*/
public function isScopeDefault();
/**
* Check that current fixture scope is equal to SCOPE_SHARED
*
* @return boolean
*/
public function isScopeShared();
/**
* Check that current fixture scope is equal to SCOPE_LOCAL
*
* @return boolean
*/
public function isScopeLocal();
/**
* Loads fixture files from test class annotations
*
* @param string $className
* @return $this
*/
public function loadForClass($className);
/**
* Sets fixture value
*
* @param string $key
* @param array[] $value
*
* @return $this
*/
public function setFixtureValue($key, $value);
/**
* Retrieves fixture value
*
* @param string $key
*
* @return array[]
*/
public function getFixtureValue($key);
/**
* Returns VFS wrapper instance
*
* @return EcomDev_PHPUnit_Model_Fixture_Vfs
*/
public function getVfs();
}
......@@ -24,8 +24,8 @@
*/
class EcomDev_PHPUnit_Model_Layout
extends Mage_Core_Model_Layout
implements EcomDev_PHPUnit_Constraint_Layout_Logger_Interface,
EcomDev_PHPUnit_Isolation_Interface
implements EcomDev_PHPUnit_Constraint_Layout_LoggerInterface,
EcomDev_PHPUnit_IsolationInterface
{
/**
* List of replaced blocks creation
......@@ -35,7 +35,7 @@ class EcomDev_PHPUnit_Model_Layout
protected $_replaceBlockCreation = array();
/**
* Records for gethering information about all,
* Records for gathering information about all,
* the actions that was performed
*
*
......@@ -83,8 +83,8 @@ class EcomDev_PHPUnit_Model_Layout
}
/**
* Overriden for possibility of replacing a block by mock object
* (non-PHPdoc)
* Overridden for possibility of replacing a block by mock object
*
* @see Mage_Core_Model_Layout::_getBlockInstance()
*/
protected function _getBlockInstance($block, array $attributes=array())
......@@ -182,6 +182,7 @@ class EcomDev_PHPUnit_Model_Layout
* @param string $action
* @param string $target
* @param array $parameters
* @param string $searchType
* @return boolean
*/
public function findByParameters($action, $target, array $parameters, $searchType = self::SEARCH_TYPE_AND)
......@@ -280,7 +281,6 @@ class EcomDev_PHPUnit_Model_Layout
/**
* Records action call
*
* (non-PHPdoc)
* @see Mage_Core_Model_Layout::_generateAction()
*/
protected function _generateAction($node, $parent)
......@@ -355,7 +355,7 @@ class EcomDev_PHPUnit_Model_Layout
/**
* Records information about new block creation
* (non-PHPdoc)
*
* @see Mage_Core_Model_Layout::_generateBlock()
*/
protected function _generateBlock($node, $parent)
......@@ -392,7 +392,7 @@ class EcomDev_PHPUnit_Model_Layout
/**
* Collects block creation
* (non-PHPdoc)
*
* @see Mage_Core_Model_Layout::addBlock()
*/
public function addBlock($block, $blockName)
......@@ -499,6 +499,8 @@ class EcomDev_PHPUnit_Model_Layout
* Returns block property by getter
*
* @param string $block
* @param $property
* @throws RuntimeException
* @return mixed
*/
public function getBlockProperty($block, $property)
......
<?php
/**
* PHP Unit test suite for Magento
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
*
* @category EcomDev
* @package EcomDev_PHPUnit
* @copyright Copyright (c) 2013 EcomDev BV (http://www.ecomdev.org)
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* @author Ivan Chepurnyi <ivan.chepurnyi@ecomdev.org>
*/
/**
* Interface for loadable test environment data
*
*/
interface EcomDev_PHPUnit_Model_LoadableInterface
{
/**
* Loads external data by test case instance
*
* @param PHPUnit_Framework_TestCase $testCase
* @return $this
*/
public function loadByTestCase(PHPUnit_Framework_TestCase $testCase);
/**
* Applies external data
*
* @return $this
*/
public function apply();
/**
* Reverts applied data
*
* @return $this
*/
public function discard();
}
......@@ -34,6 +34,7 @@ class EcomDev_PHPUnit_Model_Mysql4_Fixture extends Mage_Core_Model_Mysql4_Abstra
* Cleans table in test database
*
* @param string $tableEntity
* @throws EcomDev_PHPUnit_Model_Mysql4_Fixture_Exception
* @return EcomDev_PHPUnit_Model_Mysql4_Fixture
*/
public function cleanTable($tableEntity)
......@@ -55,6 +56,8 @@ class EcomDev_PHPUnit_Model_Mysql4_Fixture extends Mage_Core_Model_Mysql4_Abstra
*
* @param string $tableEntity
* @param array $tableData
* @throws EcomDev_PHPUnit_Model_Mysql4_Fixture_Exception
* @return $this
*/
public function loadTableData($tableEntity, $tableData)
{
......@@ -92,7 +95,7 @@ class EcomDev_PHPUnit_Model_Mysql4_Fixture extends Mage_Core_Model_Mysql4_Abstra
{
$record = array();
// Fullfil table records with data
// Populate table records with data
foreach ($tableColumns as $columnName => $definition) {
if (isset($row[$columnName])) {
$record[$columnName] = $this->_getTableRecordValue($row[$columnName]);
......@@ -113,6 +116,7 @@ class EcomDev_PHPUnit_Model_Mysql4_Fixture extends Mage_Core_Model_Mysql4_Abstra
*
*
* @param mixed $value
* @throws InvalidArgumentException
* @return string
*/
protected function _getTableRecordValue($value)
......
<?php
/**
* PHP Unit test suite for Magento
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
*
* @category EcomDev
* @package EcomDev_PHPUnit
* @copyright Copyright (c) 2013 EcomDev BV (http://www.ecomdev.org)
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* @author Ivan Chepurnyi <ivan.chepurnyi@ecomdev.org>
* @author Steve Rice <srice@endertech.com>
* @author Jonathan Day <jonathan@aligent.com.au>
*/
abstract class EcomDev_PHPUnit_Model_Mysql4_Fixture_AbstractAttribute
extends EcomDev_PHPUnit_Model_Mysql4_Fixture_AbstractComplex
{
protected $_setupModel = 'Mage_Eav_Model_Entity_Setup';
/**
* List of indexers required to build
*
* @var array
*/
protected $_requiredIndexers = array(
'catalog_product_attribute',
);
/**
* Original list of indexers required to build
*
* @var array
*/
protected $_originalIndexers = array();
/**
* Retrieve required indexers for re-building
*
* @return array
*/
public function getRequiredIndexers()
{
return $this->_requiredIndexers;
}
/**
* Run required indexers and reset to original required indexers
*
* @return EcomDev_PHPUnit_Model_Mysql4_Fixture_Eav_Abstract
*/
public function runRequiredIndexers()
{
if (empty($this->_options['doNotIndexAll'])) {
$indexer = Mage::getSingleton('index/indexer');
foreach ($this->getRequiredIndexers() as $indexerCode) {
if (empty($this->_options['doNotIndex'])
|| !in_array($indexerCode, $this->_options['doNotIndex'])) {
$indexer->getProcessByCode($indexerCode)
->reindexAll();
}
}
}
// Restoring original required indexers for making tests isolated
$this->_requiredIndexers = $this->_originalIndexers;
return $this;
}
/**
* Add indexer by specific code to required indexers list
*
* @param string $code
* @return EcomDev_PHPUnit_Model_Mysql4_Fixture_Eav_Abstract
*/
public function addRequiredIndexer($code)
{
if (!in_array($code, $this->_requiredIndexers)) {
$this->_requiredIndexers[] = $code;
}
return $this;
}
/**
* @param string $entityType
* @return array
*/
public function loadDefaultAttributes($entityType)
{
/** @var $eavConfig Mage_Eav_Model_Config */
$eavConfig = Mage::getSingleton('eav/config');
$attributeCodes = $eavConfig->getEntityAttributeCodes($entityType);
return $attributeCodes;
}
/**
* Loads EAV attribute into DB tables
*
* @throws UnexpectedValueException
* @throws InvalidArgumentException
* @param string $entityType
* @param array $values
* @return $this
*/
public function loadAttribute($entityType, $values)
{
/** @var $eavConfig Mage_Eav_Model_Config */
$eavConfig = Mage::getSingleton('eav/config');
/** @var $entityTypeModel Mage_Eav_Model_Entity_Type */
$entityTypeModel = $eavConfig->getEntityType($entityType);
$entityModel = $entityTypeModel->getEntity();
//use entity model to figure out setup class
$entityReflection = EcomDev_Utils_Reflection::getReflection($entityModel);
$classArray = explode('_', $entityReflection->getName());
$moduleName = $classArray[0] . '_' . $classArray[1];
$eavSetupModel = $this->_getSetupModelForModule($moduleName);
foreach ($values as $value) {
if (!isset($value['attribute_code'])) {
throw new InvalidArgumentException('Attribute definition must contain attribute_code');
}
/** @var $eavSetupModel Mage_Eav_Model_Entity_Setup */
$eavSetupModel->addAttribute($entityTypeModel->getEntityTypeCode(), $value['attribute_code'], $value);
}
return $this;
}
/**
* Remove fixture-generated attributes from database
*
* @param string $entityType
* @param array $attributes
* @throws EcomDev_PHPUnit_Model_Mysql4_Fixture_Exception
* @return EcomDev_PHPUnit_Model_Mysql4_Fixture_AbstractAttribute
*/
public function cleanAttributes($entityType, array $attributes)
{
$eavSetup = new Mage_Eav_Model_Entity_Setup('core_setup');
try {
if(empty($attributes)) {
throw new Exception('Attribute array cannot be empty');
}
else {
$attributeCodes = array();
foreach($attributes[$entityType] as $attribute){
$attributeCodes[] = $attribute['attribute_code'];
}
}
//delete entry from eav/attribute and allow FK cascade to delete all related values
//TODO: check if the attribute != is_user_defined (ie system), then *only* delete the attribute option values, not attribute definition
$this->_getWriteAdapter()
->delete(
$this->getTable('eav/attribute'),
array(
'entity_type_id = ?' => $eavSetup->getEntityTypeId($entityType),
'attribute_code IN (?)' => $attributeCodes,
)
);
$this->_getWriteAdapter()->commit();
} catch (Exception $e) {
throw new EcomDev_PHPUnit_Model_Mysql4_Fixture_Exception(
sprintf('Unable to clear records for a table "%s"', 'eav/attribute'),
$e
);
}
$this->resetAttributesAutoIncrement();
return $this;
}
/**
* Reset autoincrement value of all EAV attribute tables or those associated with an entity type
*
* @throws EcomDev_PHPUnit_Model_Mysql4_Fixture_Exception
* @param string $entityType
* @return EcomDev_PHPUnit_Model_Mysql4_Fixture_AbstractAttribute
*/
public function resetAttributesAutoIncrement($entityType = null)
{
//@TODO track which tables are altered
if ($entityType !== null) {
/** @var $eavConfig Mage_Eav_Model_Config */
$eavConfig = Mage::getSingleton('eav/config');
/** @var $entityTypeModel Mage_Eav_Model_Entity_Type */
$entityTypeModel = $eavConfig->getEntityType($entityType);
$this->resetTableAutoIncrement($entityTypeModel->getAdditionalAttributeTable());
} else {
//@TODO don't hardcode these
$this->resetTableAutoIncrement('eav/attribute');
$this->resetTableAutoIncrement('eav/attribute_set');
$this->resetTableAutoIncrement('eav/attribute_group');
$this->resetTableAutoIncrement('eav/attribute_label');
$this->resetTableAutoIncrement('eav/attribute_option');
$this->resetTableAutoIncrement('eav/attribute_option_value');
}
return $this;
}
/**
* Reset autoincrement value of a table
*
* @param string $table
* @return EcomDev_PHPUnit_Model_Mysql4_Fixture_AbstractAttribute
* @throws EcomDev_PHPUnit_Model_Mysql4_Fixture_Exception
*/
public function resetTableAutoIncrement($table)
{
try {
//reset table auto_increment to maximum value in table
$this->_getWriteAdapter()->query("ALTER TABLE `{$this->getTable($table)}` AUTO_INCREMENT = 1");
} catch (Exception $e) {
throw new EcomDev_PHPUnit_Model_Mysql4_Fixture_Exception(
sprintf('Unable to reset autoincrement for table "%s"', $table),
$e
);
}
return $this;
}
/**
* Get the setup model used by a Magento module
*
* @param $moduleName
* @return mixed
* @throws UnexpectedValueException
*/
protected function _getSetupModelForModule($moduleName)
{
$resources = Mage::getConfig()->getNode('global/resources')->children();
$resourceName = 'eav_setup';
$className = 'Mage_Eav_Model_Entity_Setup';
foreach ($resources as $resName => $resource) {
if (!$resource->setup) {
continue;
}
if (isset($resource->setup->module) && $resource->setup->module == $moduleName
&& isset($resource->setup->class)) {
$className = $resource->setup->getClassName();
$resourceName = $resName;
break;
}
}
$setupModel = new $className($resourceName);
$setupReflection = EcomDev_Utils_Reflection::getReflection($setupModel);
if (!$setupReflection->hasMethod('addAttribute')) {
throw new UnexpectedValueException('Problem loading EAV setup model');
}
return $setupModel;
}
}
<?php
/**
* PHP Unit test suite for Magento
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
*
* @category EcomDev
* @package EcomDev_PHPUnit
* @copyright Copyright (c) 2013 EcomDev BV (http://www.ecomdev.org)
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* @author Ivan Chepurnyi <ivan.chepurnyi@ecomdev.org>
* @author Steve Rice <srice@endertech.com>
*/
abstract class EcomDev_PHPUnit_Model_Mysql4_Fixture_AbstractComplex
extends EcomDev_PHPUnit_Model_Mysql4_Fixture
{
/**
* Fixture options
*
* @var array
*/
protected $_options = array();
/**
* Fixture model
*
* @var EcomDev_PHPUnit_Model_FixtureInterface
*/
protected $_fixture = null;
/**
* Inject fixture model into complex loader
*
* @param EcomDev_PHPUnit_Model_FixtureInterface $fixture
* @return EcomDev_PHPUnit_Model_Mysql4_Fixture_AbstractComplex
*/
public function setFixture($fixture)
{
$this->_fixture = $fixture;
return $this;
}
/**
* Set fixture options
*
* @param array $options
* @return EcomDev_PHPUnit_Model_Mysql4_Fixture_AbstractComplex
*/
public function setOptions(array $options)
{
$this->_options = $options;
return $this;
}
}
......@@ -14,258 +14,13 @@
* @copyright Copyright (c) 2013 EcomDev BV (http://www.ecomdev.org)
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* @author Ivan Chepurnyi <ivan.chepurnyi@ecomdev.org>
* @author Steve Rice <srice@endertech.com>
* @author Jonathan Day <jonathan@aligent.com.au>
*/
/**
* @deprecated since 0.4.0
*/
abstract class EcomDev_PHPUnit_Model_Mysql4_Fixture_Attribute_Abstract
extends EcomDev_PHPUnit_Model_Mysql4_Fixture_Complex_Abstract
extends EcomDev_PHPUnit_Model_Mysql4_Fixture_AbstractAttribute
{
protected $_setupModel = 'Mage_Eav_Model_Entity_Setup';
/**
* List of indexers required to build
*
* @var array
*/
protected $_requiredIndexers = array(
'catalog_product_attribute',
);
/**
* Original list of indexers required to build
*
* @var array
*/
protected $_originalIndexers = array();
/**
* Retrieve required indexers for re-building
*
* @return array
*/
public function getRequiredIndexers()
{
return $this->_requiredIndexers;
}
/**
* Run required indexers and reset to original required indexers
*
* @return EcomDev_PHPUnit_Model_Mysql4_Fixture_Eav_Abstract
*/
public function runRequiredIndexers()
{
if (empty($this->_options['doNotIndexAll'])) {
$indexer = Mage::getSingleton('index/indexer');
foreach ($this->getRequiredIndexers() as $indexerCode) {
if (empty($this->_options['doNotIndex'])
|| !in_array($indexerCode, $this->_options['doNotIndex'])) {
$indexer->getProcessByCode($indexerCode)
->reindexAll();
}
}
}
// Restoring original required indexers for making tests isolated
$this->_requiredIndexers = $this->_originalIndexers;
return $this;
}
/**
* Add indexer by specific code to required indexers list
*
* @param string $code
* @return EcomDev_PHPUnit_Model_Mysql4_Fixture_Eav_Abstract
*/
public function addRequiredIndexer($code)
{
if (!in_array($code, $this->_requiredIndexers)) {
$this->_requiredIndexers[] = $code;
}
return $this;
}
/**
* @param string $entityType
* @return array
*/
public function loadDefaultAttributes($entityType)
{
/** @var $eavConfig Mage_Eav_Model_Config */
$eavConfig = Mage::getSingleton('eav/config');
$attributeCodes = $eavConfig->getEntityAttributeCodes($entityType);
return $attributeCodes;
}
/**
* Loads EAV attribute into DB tables
*
* @throws UnexpectedValueException
* @throws InvalidArgumentException
* @param string $entityType
* @param array $values
*/
public function loadAttribute($entityType, $values)
{
/** @var $eavConfig Mage_Eav_Model_Config */
$eavConfig = Mage::getSingleton('eav/config');
/** @var $entityTypeModel Mage_Eav_Model_Entity_Type */
$entityTypeModel = $eavConfig->getEntityType($entityType);
$entityModel = $entityTypeModel->getEntity();
//use entity model to figure out setup class
$entityReflection = EcomDev_Utils_Reflection::getRelflection($entityModel);
$classArray = explode('_', $entityReflection->getName());
$moduleName = $classArray[0] . '_' . $classArray[1];
$eavSetupModel = $this->_getSetupModelForModule($moduleName);
foreach ($values as $value) {
if (!isset($value['attribute_code'])) {
throw new InvalidArgumentException('Attribute definition must contain attribute_code');
}
/** @var $eavSetupModel Mage_Eav_Model_Entity_Setup */
$eavSetupModel->addAttribute($entityTypeModel->getEntityTypeCode(), $value['attribute_code'], $value);
}
return $this;
}
/**
* Remove fixture-generated attributes from database
*
* @param string $entityType
* @param array $attributeCodes
* @return EcomDev_PHPUnit_Model_Mysql4_Fixture_Attribute_Abstract
* @throws EcomDev_PHPUnit_Model_Mysql4_Fixture_Exception
*/
public function cleanAttributes($entityType, array $attributes)
{
$eavSetup = new Mage_Eav_Model_Entity_Setup('core_setup');
try {
if(empty($attributes)) {
throw new Exception('Attribute array cannot be empty');
}
else {
$attributeCodes = array();
foreach($attributes[$entityType] as $attribute){
$attributeCodes[] = $attribute['attribute_code'];
}
}
//delete entry from eav/attribute and allow FK cascade to delete all related values
//TODO: check if the attribute != is_user_defined (ie system), then *only* delete the attribute option values, not attribute definition
$this->_getWriteAdapter()
->delete(
$this->getTable('eav/attribute'),
array(
'entity_type_id = ?' => $eavSetup->getEntityTypeId($entityType),
'attribute_code IN (?)' => $attributeCodes,
)
);
$this->_getWriteAdapter()->commit();
} catch (Exception $e) {
throw new EcomDev_PHPUnit_Model_Mysql4_Fixture_Exception(
sprintf('Unable to clear records for a table "%s"', 'eav/attribute'),
$e
);
}
$this->resetAttributesAutoIncrement();
return $this;
}
/**
* Reset autoincrement value of all EAV attribute tables or those associated with an entity type
*
* @throws EcomDev_PHPUnit_Model_Mysql4_Fixture_Exception
* @param string $entityType
* @return EcomDev_PHPUnit_Model_Mysql4_Fixture_Attribute_Abstract
*/
public function resetAttributesAutoIncrement($entityType = null)
{
//@TODO track which tables are altered
if ($entityType !== null) {
/** @var $eavConfig Mage_Eav_Model_Config */
$eavConfig = Mage::getSingleton('eav/config');
/** @var $entityTypeModel Mage_Eav_Model_Entity_Type */
$entityTypeModel = $eavConfig->getEntityType($entityType);
$this->resetTableAutoIncrement($entityTypeModel->getAdditionalAttributeTable());
} else {
//@TODO don't hardcode these
$this->resetTableAutoIncrement('eav/attribute');
$this->resetTableAutoIncrement('eav/attribute_set');
$this->resetTableAutoIncrement('eav/attribute_group');
$this->resetTableAutoIncrement('eav/attribute_label');
$this->resetTableAutoIncrement('eav/attribute_option');
$this->resetTableAutoIncrement('eav/attribute_option_value');
}
return $this;
}
/**
* Reset autoincrement value of a table
*
* @param string $table
* @return EcomDev_PHPUnit_Model_Mysql4_Fixture_Attribute_Abstract
* @throws EcomDev_PHPUnit_Model_Mysql4_Fixture_Exception
*/
public function resetTableAutoIncrement($table)
{
try {
//reset table auto_increment to maximum value in table
$this->_getWriteAdapter()->query("ALTER TABLE `{$this->getTable($table)}` AUTO_INCREMENT = 1");
} catch (Exception $e) {
throw new EcomDev_PHPUnit_Model_Mysql4_Fixture_Exception(
sprintf('Unable to reset autoincrement for table "%s"', $table),
$e
);
}
return $this;
}
/**
* Get the setup model used by a Magento module
*
* @param $moduleName
* @return mixed
* @throws UnexpectedValueException
*/
protected function _getSetupModelForModule($moduleName)
{
$resources = Mage::getConfig()->getNode('global/resources')->children();
$resourceName = 'eav_setup';
$className = 'Mage_Eav_Model_Entity_Setup';
foreach ($resources as $resName => $resource) {
if (!$resource->setup) {
continue;
}
if (isset($resource->setup->module) && $resource->setup->module == $moduleName
&& isset($resource->setup->class)) {
$className = $resource->setup->getClassName();
$resourceName = $resName;
break;
}
}
$setupModel = new $className($resourceName);
$setupReflection = EcomDev_Utils_Reflection::getRelflection($setupModel);
if (!$setupReflection->hasMethod('addAttribute')) {
throw new UnexpectedValueException('Problem loading EAV setup model');
}
return $setupModel;
}
}
......@@ -18,7 +18,7 @@
*/
class EcomDev_PHPUnit_Model_Mysql4_Fixture_Attribute_Default
extends EcomDev_PHPUnit_Model_Mysql4_Fixture_Attribute_Abstract
extends EcomDev_PHPUnit_Model_Mysql4_Fixture_AbstractAttribute
{
}
......@@ -14,46 +14,13 @@
* @copyright Copyright (c) 2013 EcomDev BV (http://www.ecomdev.org)
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* @author Ivan Chepurnyi <ivan.chepurnyi@ecomdev.org>
* @author Steve Rice <srice@endertech.com>
*/
abstract class EcomDev_PHPUnit_Model_Mysql4_Fixture_Complex_Abstract extends EcomDev_PHPUnit_Model_Mysql4_Fixture
{
/**
* Fixture options
*
* @var array
*/
protected $_options = array();
/**
* Fixture model
*
* @var EcomDev_PHPUnit_Model_Fixture_Interface
*/
protected $_fixture = null;
/**
* Inject fixture model into complex loader
*
* @param EcomDev_PHPUnit_Model_Fixture_Interface $fixture
* @return EcomDev_PHPUnit_Model_Mysql4_Fixture_Complex_Abstract
/**
* @deprecated since 0.4.0
*/
public function setFixture($fixture)
{
$this->_fixture = $fixture;
return $this;
}
abstract class EcomDev_PHPUnit_Model_Mysql4_Fixture_Complex_Abstract
extends EcomDev_PHPUnit_Model_Mysql4_Fixture_AbstractComplex
{
/**
* Set fixture options
*
* @param array $options
* @return EcomDev_PHPUnit_Model_Mysql4_Fixture_Complex_Abstract
*/
public function setOptions(array $options)
{
$this->_options = $options;
return $this;
}
}
......@@ -21,19 +21,19 @@
*
*
*/
abstract class EcomDev_PHPUnit_Model_Mysql4_Fixture_Eav_Catalog_Abstract extends EcomDev_PHPUnit_Model_Mysql4_Fixture_Eav_Abstract
abstract class EcomDev_PHPUnit_Model_Mysql4_Fixture_Eav_Catalog_Abstract
extends EcomDev_PHPUnit_Model_Mysql4_Fixture_AbstractEav
{
const SCOPE_TYPE_STORE = 'stores';
const SCOPE_TYPE_WEBSITE = 'websites';
/**
* Overriden to add GWS implementation for attribute records
* Overridden to add GWS implementation for attribute records
*
* @param array $row
* @param Mage_Catalog_Model_Resource_Eav_Attribute $attribute
* @param array $tableColumns
* @return array
* (non-PHPdoc)
* @see EcomDev_PHPUnit_Model_Mysql4_Fixture_Eav_Abstract::_getAttributeRecords()
*/
protected function _getAttributeRecords($row, $attribute, $tableColumns)
......@@ -43,7 +43,7 @@ abstract class EcomDev_PHPUnit_Model_Mysql4_Fixture_Eav_Catalog_Abstract extends
// If the attribute is not global,
// then walk over all websites and stores scopes for attribute value
if ($attribute->isScopeStore() || $attribute->isScopeWebsite()) {
// Search for website values and fullfil data per website's store
// Search for website values and populate data per website's store
$storeValues = array();
foreach ($this->_getGwsCodes($row, self::SCOPE_TYPE_WEBSITE) as $websiteCode) {
$website = Mage::app()->getWebsite($websiteCode);
......@@ -96,6 +96,7 @@ abstract class EcomDev_PHPUnit_Model_Mysql4_Fixture_Eav_Catalog_Abstract extends
*
* @param array $row
* @param string $scopeType
* @return array
*/
protected function _getGwsCodes($row, $scopeType = self::SCOPE_TYPE_STORE)
{
......@@ -130,8 +131,8 @@ abstract class EcomDev_PHPUnit_Model_Mysql4_Fixture_Eav_Catalog_Abstract extends
}
/**
* Overriden to add default store id
* (non-PHPdoc)
* Overridden to add default store id
*
* @see EcomDev_PHPUnit_Model_Mysql4_Fixture_Eav_Abstract::_getAttributeValueInfo()
*/
protected function _getAttributeValueInfo($row, $attribute)
......
......@@ -28,7 +28,7 @@ class EcomDev_PHPUnit_Model_Mysql4_Fixture_Eav_Catalog_Category extends EcomDev_
);
/**
* Overriden to add easy fixture loading for product associations
* Overridden to add easy fixture loading for product associations
* (non-PHPdoc)
* @see EcomDev_PHPUnit_Model_Mysql4_Fixture_Eav_Abstract::_getCustomTableRecords()
*/
......
......@@ -31,8 +31,8 @@ class EcomDev_PHPUnit_Model_Mysql4_Fixture_Eav_Catalog_Product extends EcomDev_P
/**
* Overridden to fix issue with flat tables existance mark
* (non-PHPdoc)
* Overridden to fix issue with flat tables existence mark
*
* @see EcomDev_PHPUnit_Model_Mysql4_Fixture_Eav_Abstract::loadEntity()
*/
public function loadEntity($entityType, $values)
......@@ -49,7 +49,7 @@ class EcomDev_PHPUnit_Model_Mysql4_Fixture_Eav_Catalog_Product extends EcomDev_P
/**
* Overridden to add easy fixture loading for websites and categories associations
* (non-PHPdoc)
*
* @see EcomDev_PHPUnit_Model_Mysql4_Fixture_Eav_Abstract::_getCustomTableRecords()
*/
protected function _getCustomTableRecords($row, $entityTypeModel)
......@@ -66,8 +66,11 @@ class EcomDev_PHPUnit_Model_Mysql4_Fixture_Eav_Catalog_Product extends EcomDev_P
/**
* Changed to support price attribute type multi-scope
* (non-PHPdoc)
*
* @param array $row
* @param Mage_Eav_Model_Entity_Attribute $attribute
* @param array $tableColumns
* @return array
* @see EcomDev_PHPUnit_Model_Mysql4_Fixture_Eav_Catalog_Abstract::_getAttributeRecords()
*/
protected function _getAttributeRecords($row, $attribute, $tableColumns)
......@@ -123,8 +126,8 @@ class EcomDev_PHPUnit_Model_Mysql4_Fixture_Eav_Catalog_Product extends EcomDev_P
*
* @param array $row
* @param Mage_Eav_Model_Entity_Type $entityTypeModel
* @throws Exception
* @return array
* @throws RuntimeException
*/
protected function _getProductSuperRelations($row, $entityTypeModel)
{
......@@ -282,7 +285,7 @@ class EcomDev_PHPUnit_Model_Mysql4_Fixture_Eav_Catalog_Product extends EcomDev_P
/**
* Adding enabled and visibility indexes
*
* (non-PHPdoc)
*
* @see EcomDev_PHPUnit_Model_Mysql4_Fixture_Eav_Abstract::_customEntityAction()
*/
protected function _customEntityAction($entity, $entityTypeModel)
......
......@@ -21,7 +21,7 @@
*
*
*/
class EcomDev_PHPUnit_Model_Mysql4_Fixture_Eav_Default extends EcomDev_PHPUnit_Model_Mysql4_Fixture_Eav_Abstract
class EcomDev_PHPUnit_Model_Mysql4_Fixture_Eav_Default extends EcomDev_PHPUnit_Model_Mysql4_Fixture_AbstractEav
{
}
\ No newline at end of file
......@@ -32,11 +32,11 @@ class EcomDev_PHPUnit_Model_Observer
if ($helperClass && class_exists($helperClass)) {
$helper = new $helperClass();
if (!$helper instanceof EcomDev_PHPUnit_Helper_Interface) {
if (!$helper instanceof EcomDev_PHPUnit_HelperInterface) {
throw new RuntimeException(
sprintf(
'Test helpers should implement %s, but %s is not implementing it.',
'EcomDev_PHPUnit_Helper_Interface',
'EcomDev_PHPUnit_HelperInterface',
$helperClass
)
);
......
......@@ -17,30 +17,11 @@
*/
/**
* Interface for loadable test environment data
*
* @deprecated since 0.4.0
*/
interface EcomDev_PHPUnit_Model_Test_Loadable_Interface
interface EcomDev_PHPUnit_Model_Test_LoadableInterface
extends EcomDev_PHPUnit_Model_LoadableInterface
{
/**
* Loads external data by test case instance
*
* @param PHPUnit_Framework_TestCase $testCase
* @return EcomDev_PHPUnit_Model_Test_Loadable_Interface
*/
public function loadByTestCase(PHPUnit_Framework_TestCase $testCase);
/**
* Applies external data
*
* @return EcomDev_PHPUnit_Model_Test_Loadable_Interface
*/
public function apply();
/**
* Reverts applied data
*
* @return EcomDev_PHPUnit_Model_Test_Loadable_Interface
*/
public function discard();
}
<?php
/**
* PHP Unit test suite for Magento
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
*
* @category EcomDev
* @package EcomDev_PHPUnit
* @copyright Copyright (c) 2013 EcomDev BV (http://www.ecomdev.org)
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* @author Ivan Chepurnyi <ivan.chepurnyi@ecomdev.org>
*/
abstract class EcomDev_PHPUnit_Model_Yaml_AbstractLoader
implements EcomDev_PHPUnit_Model_Yaml_LoaderInterface
{
const DATA_DIR = '_data';
protected $_typeMap = array(
'fixtures' => 'fx',
'providers' => 'dp',
'expectations' => 'ex'
);
/**
* Resolves YAML file path based on its filename,
* if file is not found, it should return false
*
* @param string $fileName name of the file
* @param string $relatedClassName class name from which load of yaml file is invoked
* @param string $type type of Yaml file (provider, fixture, expectation)
* @return string|bool
*/
public function resolveFilePath($fileName, $relatedClassName, $type)
{
if (strrpos($fileName, '.yaml') !== strlen($fileName) - 5) {
$fileName .= '.yaml';
}
$filePath = $this->_getFilePath($fileName, $relatedClassName, $type);
if ($filePath && file_exists($filePath)) {
return $filePath;
}
return false;
}
/**
* Returns processed file path
*
* @param string $fileName
* @param string $relatedClassName
* @param string $type
* @return string
*/
abstract protected function _getFilePath($fileName, $relatedClassName, $type);
/**
* Looks in path for possible existent fixture
*
* @param string|array $path
* @param string $fileName
* @param string $type
* @return bool|string
*/
protected function _checkFilePath($path, $fileName, $type)
{
if (is_array($path)) {
foreach ($path as $value) {
if ($filePath = $this->_checkFilePath($value, $fileName, $type)) {
return $filePath;
}
}
return false;
}
if (isset($this->_typeMap[$type])
&& file_exists($filePath = $path . DS . self::DATA_DIR . DS . $this->_typeMap[$type] . '-' . $fileName)) {
return $filePath;
}
if (file_exists($filePath = $path . DS . $type . DS . $fileName)) {
return $filePath;
}
return false;
}
}
......@@ -31,14 +31,14 @@ class EcomDev_PHPUnit_Model_Yaml_Loader
/**
* YAML file loaders
*
* @var EcomDev_PHPUnit_Model_Yaml_Loader_Interface[]
* @var EcomDev_PHPUnit_Model_Yaml_LoaderInterface[]
*/
protected $_loaders = array();
/**
* Returns arrays of loaders
*
* @return EcomDev_PHPUnit_Model_Yaml_Loader_Interface[]
* @return EcomDev_PHPUnit_Model_Yaml_LoaderInterface[]
*/
public function getLoaders()
{
......@@ -50,12 +50,12 @@ class EcomDev_PHPUnit_Model_Yaml_Loader
}
/**
* Adds a loader to list of loders
* Adds a loader to list of loaders
*
* @param EcomDev_PHPUnit_Model_Yaml_Loader_Interface $loader
* @param EcomDev_PHPUnit_Model_Yaml_LoaderInterface $loader
* @return EcomDev_PHPUnit_Model_Yaml_Loader
*/
public function addLoader(EcomDev_PHPUnit_Model_Yaml_Loader_Interface $loader)
public function addLoader(EcomDev_PHPUnit_Model_Yaml_LoaderInterface $loader)
{
$this->_loaders[] = $loader;
return $this;
......
......@@ -16,79 +16,11 @@
* @author Ivan Chepurnyi <ivan.chepurnyi@ecomdev.org>
*/
abstract class EcomDev_PHPUnit_Model_Yaml_Loader_Abstract implements EcomDev_PHPUnit_Model_Yaml_Loader_Interface
{
const DATA_DIR = '_data';
protected $_typeMap = array(
'fixtures' => 'fx',
'providers' => 'dp',
'expectations' => 'ex'
);
/**
* Resolves YAML file path based on its filename,
* if file is not found, it should return false
*
* @param string $fileName name of the file
* @param string $relatedClassName class name from which load of yaml file is invoked
* @param string $type type of Yaml file (provider, fixture, expectation)
* @return string|bool
*/
public function resolveFilePath($fileName, $relatedClassName, $type)
{
if (strrpos($fileName, '.yaml') !== strlen($fileName) - 5) {
$fileName .= '.yaml';
}
$filePath = $this->_getFilePath($fileName, $relatedClassName, $type);
if ($filePath && file_exists($filePath)) {
return $filePath;
}
return false;
}
/**
* Returns processed file path
*
* @param string $fileName
* @param string $relatedClassName
* @param string $type
* @return string
*/
abstract protected function _getFilePath($fileName, $relatedClassName, $type);
/**
* Looks in path for possible existent fixture
*
* @param string|array $path
* @param string $fileName
* @param string $type
* @return bool|string
/**
* @deprecated since 0.4.0
*/
protected function _checkFilePath($path, $fileName, $type)
{
if (is_array($path)) {
foreach ($path as $value) {
if ($filePath = $this->_checkFilePath($value, $fileName, $type)) {
return $filePath;
}
}
return false;
}
if (isset($this->_typeMap[$type])
&& file_exists($filePath = $path . DS . self::DATA_DIR . DS . $this->_typeMap[$type] . '-' . $fileName)) {
return $filePath;
}
if (file_exists($filePath = $path . DS . $type . DS . $fileName)) {
return $filePath;
}
abstract class EcomDev_PHPUnit_Model_Yaml_Loader_Abstract
extends EcomDev_PHPUnit_Model_Yaml_AbstractLoader
{
return false;
}
}
\ No newline at end of file
......@@ -16,7 +16,7 @@
* @author Ivan Chepurnyi <ivan.chepurnyi@ecomdev.org>
*/
class EcomDev_PHPUnit_Model_Yaml_Loader_Default extends EcomDev_PHPUnit_Model_Yaml_Loader_Abstract
class EcomDev_PHPUnit_Model_Yaml_Loader_Default extends EcomDev_PHPUnit_Model_Yaml_AbstractLoader
{
/**
* Returns processed file path
......
......@@ -16,7 +16,7 @@
* @author Ivan Chepurnyi <ivan.chepurnyi@ecomdev.org>
*/
class EcomDev_PHPUnit_Model_Yaml_Loader_Global extends EcomDev_PHPUnit_Model_Yaml_Loader_Abstract
class EcomDev_PHPUnit_Model_Yaml_Loader_Global extends EcomDev_PHPUnit_Model_Yaml_AbstractLoader
{
/**
* Returns processed file path
......
......@@ -16,16 +16,11 @@
* @author Ivan Chepurnyi <ivan.chepurnyi@ecomdev.org>
*/
/**
* @deprecated since 0.4.0
*/
interface EcomDev_PHPUnit_Model_Yaml_Loader_Interface
extends EcomDev_PHPUnit_Model_Yaml_LoaderInterface
{
/**
* Resolves YAML file path based on its filename,
* if file is not found, it should return false
*
* @param string $fileName name of the file
* @param string $relatedClassName class name from which load of yaml file is invoked
* @param string $type type of Yaml file (provider, fixture, expectation)
* @return string|bool
*/
public function resolveFilePath($fileName, $relatedClassName, $type);
}
\ No newline at end of file
......@@ -16,7 +16,7 @@
* @author Colin Mollenhour <http://colin.mollenhour.com>
* @author Ivan Chepurnyi <ivan.chepurnyi@ecomdev.org>
*/
class EcomDev_PHPUnit_Model_Yaml_Loader_Module extends EcomDev_PHPUnit_Model_Yaml_Loader_Abstract
class EcomDev_PHPUnit_Model_Yaml_Loader_Module extends EcomDev_PHPUnit_Model_Yaml_AbstractLoader
{
/**
* Returns processed file path based on module test directory
......
<?php
/**
* PHP Unit test suite for Magento
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
*
* @category EcomDev
* @package EcomDev_PHPUnit
* @copyright Copyright (c) 2013 EcomDev BV (http://www.ecomdev.org)
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* @author Ivan Chepurnyi <ivan.chepurnyi@ecomdev.org>
*/
interface EcomDev_PHPUnit_Model_Yaml_LoaderInterface
{
/**
* Resolves YAML file path based on its filename,
* if file is not found, it should return false
*
* @param string $fileName name of the file
* @param string $relatedClassName class name from which load of yaml file is invoked
* @param string $type type of Yaml file (provider, fixture, expectation)
* @return string|bool
*/
public function resolveFilePath($fileName, $relatedClassName, $type);
}
\ No newline at end of file
......@@ -239,13 +239,13 @@ abstract class EcomDev_PHPUnit_Test_Case extends PHPUnit_Framework_TestCase
}
/**
* Assert that JSON string doesn't matches expected value,
* Assert that JSON string does not matches expected value,
* Can accept different match type for matching logic.
*
* @param string $string
* @param array $expectedValue
* @param string $message
* @param strign $matchType
* @param string $matchType
*/
public static function assertJsonNotMatch($string, array $expectedValue, $message = '',
$matchType = EcomDev_PHPUnit_Constraint_Json::MATCH_AND)
......@@ -334,6 +334,7 @@ abstract class EcomDev_PHPUnit_Test_Case extends PHPUnit_Framework_TestCase
* @param string $type
* @param string $classAlias
* @param PHPUnit_Framework_MockObject_MockObject|PHPUnit_Framework_MockObject_MockBuilder $mock
* @return $this
*/
protected function replaceByMock($type, $classAlias, $mock)
{
......@@ -533,6 +534,7 @@ abstract class EcomDev_PHPUnit_Test_Case extends PHPUnit_Framework_TestCase
*
* @param string $type block/model/helper/resource_model
* @param string $classAlias
* @return string
*/
protected function getGroupedClassName($type, $classAlias)
{
......@@ -678,7 +680,7 @@ abstract class EcomDev_PHPUnit_Test_Case extends PHPUnit_Framework_TestCase
* @param string $type type of YAML data (fixtures,expectations,dataproviders)
* @param string $name the file name for loading
* @return string|boolean
* @depracated since 0.3.0
* @deprecated since 0.3.0
*/
public static function getYamlFilePathByClass($className, $type, $name)
{
......
......@@ -26,12 +26,12 @@ abstract class EcomDev_PHPUnit_Test_Case_Config extends EcomDev_PHPUnit_Test_Cas
/**
* Returns a new instance of EcomDev_PHPUnit_Constraint_Config
*
* @param EcomDev_PHPUnit_Constraint_Config_Interface $configContstraint
* @param EcomDev_PHPUnit_Constraint_ConfigInterface $configConstraint
* @return EcomDev_PHPUnit_Constraint_Config
*/
public static function config($configContstraint)
public static function config($configConstraint)
{
return new EcomDev_PHPUnit_Constraint_Config($configContstraint);
return new EcomDev_PHPUnit_Constraint_Config($configConstraint);
}
/**
......@@ -173,7 +173,7 @@ abstract class EcomDev_PHPUnit_Test_Case_Config extends EcomDev_PHPUnit_Test_Cas
* @return EcomDev_PHPUnit_Constraint_Config
*/
public static function configEventObserver($area, $eventName, $observerClassAlias, $observerMethod,
$type = EcomDev_PHPUnit_Constraint_Config_EventObserver::TYPE_DEFINDED, $observerName = null)
$type = EcomDev_PHPUnit_Constraint_Config_EventObserver::TYPE_DEFINED, $observerName = null)
{
return self::config(
new EcomDev_PHPUnit_Constraint_Config_EventObserver($area, $eventName, $observerClassAlias, $observerMethod, $type, $observerName)
......@@ -385,8 +385,7 @@ abstract class EcomDev_PHPUnit_Test_Case_Config extends EcomDev_PHPUnit_Test_Cas
* @param string|null $from
* @param string|null $to
* @param string|null $moduleName
* @param string|null $moduleName
* @param mixed $expectedResourceName
* @param string|null $resourceName
* @param string $message
*/
public static function assertSchemeSetupScriptVersions($from = null, $to = null,
......@@ -402,8 +401,7 @@ abstract class EcomDev_PHPUnit_Test_Case_Config extends EcomDev_PHPUnit_Test_Cas
* @param string|null $from
* @param string|null $to
* @param string|null $moduleName
* @param string|null $moduleName
* @param mixed $expectedResourceName
* @param string|null $resourceName
* @param string $message
*/
public static function assertDataSetupScriptVersions($from = null, $to = null,
......@@ -1200,6 +1198,8 @@ abstract class EcomDev_PHPUnit_Test_Case_Config extends EcomDev_PHPUnit_Test_Cas
*
* @param string $area (frontend|adminhtml)
* @param string $expectedFileName
* @param string $theme
* @param string|null $designPackage
* @param string $message
*/
public static function assertLayoutFileExistsInTheme($area, $expectedFileName, $theme,
......@@ -1236,7 +1236,7 @@ abstract class EcomDev_PHPUnit_Test_Case_Config extends EcomDev_PHPUnit_Test_Cas
self::assertThatConfig(
self::configEventObserver(
$area, $eventName, $observerClassAlias, $observerMethod,
EcomDev_PHPUnit_Constraint_Config_EventObserver::TYPE_DEFINDED,
EcomDev_PHPUnit_Constraint_Config_EventObserver::TYPE_DEFINED,
$observerName
),
$message
......@@ -1262,7 +1262,7 @@ abstract class EcomDev_PHPUnit_Test_Case_Config extends EcomDev_PHPUnit_Test_Cas
self::logicalNot(
self::configEventObserver(
$area, $eventName, $observerClassAlias, $observerMethod,
EcomDev_PHPUnit_Constraint_Config_EventObserver::TYPE_DEFINDED,
EcomDev_PHPUnit_Constraint_Config_EventObserver::TYPE_DEFINED,
$observerName
)
),
......
......@@ -86,7 +86,7 @@ abstract class EcomDev_PHPUnit_Test_Case_Controller extends EcomDev_PHPUnit_Test
}
/**
* Layout handle functionality constaint
* Layout handle functionality constraint
*
* @param string $handle handle name
* @param string $type
......@@ -112,7 +112,7 @@ abstract class EcomDev_PHPUnit_Test_Case_Controller extends EcomDev_PHPUnit_Test
}
/**
* Layout block action calls functionality constaint
* Layout block action calls functionality constraint
*
* @param string $blockName
* @param string $method
......@@ -197,7 +197,7 @@ abstract class EcomDev_PHPUnit_Test_Case_Controller extends EcomDev_PHPUnit_Test
}
/**
* Assert that controller request doesn't matches assertion type
* Assert that controller request does not matches assertion type
*
* @param string $type type of assertion
* @param string|null $expectedValue
......@@ -437,7 +437,7 @@ abstract class EcomDev_PHPUnit_Test_Case_Controller extends EcomDev_PHPUnit_Test
/**
* Assert shortcut for response assertions
*
* @param EcomDev_PHPUnit_Constraint_Controller_Response_Abstract $constraint
* @param PHPUnit_Framework_Constraint $constraint
* @param string $message
*/
public static function assertThatResponse(PHPUnit_Framework_Constraint $constraint, $message)
......@@ -779,7 +779,7 @@ abstract class EcomDev_PHPUnit_Test_Case_Controller extends EcomDev_PHPUnit_Test
*
* @param array $expectedValue
* @param string $message
* @param strign $matchType
* @param string $matchType
*/
public static function assertResponseBodyJsonMatch(array $expectedValue, $message = '',
$matchType = EcomDev_PHPUnit_Constraint_Json::MATCH_AND)
......@@ -797,7 +797,7 @@ abstract class EcomDev_PHPUnit_Test_Case_Controller extends EcomDev_PHPUnit_Test
*
* @param array $expectedValue
* @param string $message
* @param strign $matchType
* @param string $matchType
*/
public static function assertResponseBodyJsonNotMatch(array $expectedValue, $message = '',
$matchType = EcomDev_PHPUnit_Constraint_Json::MATCH_AND)
......@@ -813,6 +813,7 @@ abstract class EcomDev_PHPUnit_Test_Case_Controller extends EcomDev_PHPUnit_Test
* Assert HTTP response code value
*
* @param int $code
* @param string $message
*/
public static function assertResponseHttpCode($code, $message = '')
{
......@@ -828,7 +829,8 @@ abstract class EcomDev_PHPUnit_Test_Case_Controller extends EcomDev_PHPUnit_Test
* Assert that controller response is redirect
*
* @param string $message
* @param int|null $code
* @param int|null $responseCode
* @internal param int|null $code
*/
public static function assertRedirect($message = '', $responseCode = null)
{
......@@ -860,7 +862,7 @@ abstract class EcomDev_PHPUnit_Test_Case_Controller extends EcomDev_PHPUnit_Test
* to a specific url
*
* @param string $route route path
* @param string $params route params
* @param array $params route params
* @param string $message
*/
public static function assertRedirectTo($route, array $params = array(), $message = '')
......@@ -937,8 +939,9 @@ abstract class EcomDev_PHPUnit_Test_Case_Controller extends EcomDev_PHPUnit_Test
/**
* Assert shortcut for layout constaints
*
* @param EcomDev_PHPUnit_Constraint_Layout_Abstract|PHPUnit_Framework_Constraint $constaint
* @param PHPUnit_Framework_Constraint $constraint
* @param string $message
* @internal param \EcomDev_PHPUnit_Constraint_AbstractLayout|\PHPUnit_Framework_Constraint $constaint
*/
public static function assertThatLayout(PHPUnit_Framework_Constraint $constraint, $message)
{
......@@ -1042,6 +1045,7 @@ abstract class EcomDev_PHPUnit_Test_Case_Controller extends EcomDev_PHPUnit_Test
*
*
* @param string $handle
* @param string $after
* @param string $message
*/
public static function assertLayoutHandleLoadedAfter($handle, $after, $message = '')
......@@ -1061,6 +1065,7 @@ abstract class EcomDev_PHPUnit_Test_Case_Controller extends EcomDev_PHPUnit_Test
*
*
* @param string $handle
* @param string $before
* @param string $message
*/
public static function assertLayoutHandleLoadedBefore($handle, $before, $message = '')
......@@ -1427,8 +1432,9 @@ abstract class EcomDev_PHPUnit_Test_Case_Controller extends EcomDev_PHPUnit_Test
* @param string $blockName
* @param string $method
* @param string $message
* @param array|null $params
* @param array $arguments
* @param string $searchType
* @internal param array|null $params
*/
public static function assertLayoutBlockActionInvoked($blockName, $method, $message = '',
array $arguments = null, $searchType = EcomDev_PHPUnit_Constraint_Layout_Block_Action::SEARCH_TYPE_AND)
......@@ -1450,7 +1456,7 @@ abstract class EcomDev_PHPUnit_Test_Case_Controller extends EcomDev_PHPUnit_Test
* @param string $blockName
* @param string $method
* @param string $message
* @param array|null $params
* @param array|null $arguments
* @param string $searchType
*/
public static function assertLayoutBlockActionNotInvoked($blockName, $method, $message = '',
......@@ -1474,18 +1480,20 @@ abstract class EcomDev_PHPUnit_Test_Case_Controller extends EcomDev_PHPUnit_Test
*
* @param string $blockName
* @param string $method
* @param int $invocationCount
* @param string $message
* @param array|null $params
* @param array $arguments
* @param string $searchType
* @internal param array|null $params
*/
public static function assertLayoutBlockActionInvokedAtLeast($blockName, $method, $invokationCount,
public static function assertLayoutBlockActionInvokedAtLeast($blockName, $method, $invocationCount,
$message = '', array $arguments = null,
$searchType = EcomDev_PHPUnit_Constraint_Layout_Block_Action::SEARCH_TYPE_AND)
{
self::assertThatLayout(
self::layoutBlockAction(
$blockName, $method,
EcomDev_PHPUnit_Constraint_Layout_Block_Action::TYPE_INVOKED_AT_LEAST, $invokationCount,
EcomDev_PHPUnit_Constraint_Layout_Block_Action::TYPE_INVOKED_AT_LEAST, $invocationCount,
$arguments, $searchType
),
$message
......@@ -1498,18 +1506,20 @@ abstract class EcomDev_PHPUnit_Test_Case_Controller extends EcomDev_PHPUnit_Test
*
* @param string $blockName
* @param string $method
* @param int $invocationCount
* @param string $message
* @param array|null $params
* @param array $arguments
* @param string $searchType
* @internal param array|null $params
*/
public static function assertLayoutBlockActionInvokedExactly($blockName, $method, $invokationCount,
public static function assertLayoutBlockActionInvokedExactly($blockName, $method, $invocationCount,
$message = '', array $arguments = null,
$searchType = EcomDev_PHPUnit_Constraint_Layout_Block_Action::SEARCH_TYPE_AND)
{
self::assertThatLayout(
self::layoutBlockAction(
$blockName, $method,
EcomDev_PHPUnit_Constraint_Layout_Block_Action::TYPE_INVOKED_EXACTLY, $invokationCount,
EcomDev_PHPUnit_Constraint_Layout_Block_Action::TYPE_INVOKED_EXACTLY, $invocationCount,
$arguments, $searchType
),
$message
......@@ -1559,7 +1569,7 @@ abstract class EcomDev_PHPUnit_Test_Case_Controller extends EcomDev_PHPUnit_Test
* @param string $propertyName
* @param mixed $expectedValue
* @param string $message
* @param float $delta
* @param float|int $delta
* @param integer $maxDepth
* @param boolean $canonicalize
* @param boolean $ignoreCase
......@@ -1582,7 +1592,7 @@ abstract class EcomDev_PHPUnit_Test_Case_Controller extends EcomDev_PHPUnit_Test
* @param string $propertyName
* @param mixed $expectedValue
* @param string $message
* @param float $delta
* @param float|int $delta
* @param integer $maxDepth
* @param boolean $canonicalize
* @param boolean $ignoreCase
......@@ -1950,6 +1960,11 @@ abstract class EcomDev_PHPUnit_Test_Case_Controller extends EcomDev_PHPUnit_Test
/**
* A callback that is invoked when a cookie is deleted
*
* @param string $name
* @param string $path
* @param string $domain
* @param int $secure
* @param int $httponly
* @return EcomDev_PHPUnit_Test_Case_Controller
*/
public function deleteCookieCallback($name, $path = null, $domain = null, $secure = null, $httponly = null)
......
......@@ -24,7 +24,7 @@ use EcomDev_PHPUnit_Test_Case_Util as TestUtil;
*
*
*/
class EcomDev_PHPUnit_Test_Case_Helper_Customer extends EcomDev_PHPUnit_Helper_Abstract
class EcomDev_PHPUnit_Test_Case_Helper_Customer extends EcomDev_PHPUnit_AbstractHelper
{
/**
* Logs in as a customer by customer id and store id
......
......@@ -24,7 +24,7 @@ use EcomDev_PHPUnit_Test_Case_Util as TestUtil;
*
*
*/
class EcomDev_PHPUnit_Test_Case_Helper_Guest extends EcomDev_PHPUnit_Helper_Abstract
class EcomDev_PHPUnit_Test_Case_Helper_Guest extends EcomDev_PHPUnit_AbstractHelper
{
/**
* Start session as guest.
......
......@@ -22,7 +22,7 @@ use EcomDev_PHPUnit_Test_Case_Util as TestUtil;
* Mock helper for Test Case
*
*/
class EcomDev_PHPUnit_Test_Case_Helper_Mock extends EcomDev_PHPUnit_Helper_Abstract
class EcomDev_PHPUnit_Test_Case_Helper_Mock extends EcomDev_PHPUnit_AbstractHelper
{
/**
* Creates a mockery for a class alias of particular type
......
......@@ -21,7 +21,7 @@
*
*
*/
class EcomDev_PHPUnit_Test_Case_Helper_Observer extends EcomDev_PHPUnit_Helper_Abstract
class EcomDev_PHPUnit_Test_Case_Helper_Observer extends EcomDev_PHPUnit_AbstractHelper
{
/**
* Generates observer object
......
......@@ -23,8 +23,8 @@ use EcomDev_PHPUnit_Test_Case_Util as TestUtil;
*
*/
class EcomDev_PHPUnit_Test_Case_Helper_Session
extends EcomDev_PHPUnit_Helper_Abstract
implements EcomDev_PHPUnit_Helper_Listener_Interface
extends EcomDev_PHPUnit_AbstractHelper
implements EcomDev_PHPUnit_Helper_ListenerInterface
{
/**
* Loaded ACL model for admin session mocks
......
......@@ -142,8 +142,8 @@ class EcomDev_PHPUnit_Test_Case_Util
$fixture = Mage::getSingleton(self::$fixtureModelAlias);
if (!$fixture instanceof EcomDev_PHPUnit_Model_Fixture_Interface) {
throw new RuntimeException('Fixture model should implement EcomDev_PHPUnit_Model_Fixture_Interface interface');
if (!$fixture instanceof EcomDev_PHPUnit_Model_FixtureInterface) {
throw new RuntimeException('Fixture model should implement EcomDev_PHPUnit_Model_FixtureInterface interface');
}
$storage = Mage::registry(EcomDev_PHPUnit_Model_App::REGISTRY_PATH_SHARED_STORAGE);
......@@ -317,7 +317,7 @@ class EcomDev_PHPUnit_Test_Case_Util
$annotation = array();
// Walkthrough sources for annotation retrieval
// Iterate over sources for annotation retrieval
foreach ($sources as $source) {
if (isset($allAnnotations[$source][$name])) {
$annotation = array_merge(
......@@ -418,9 +418,8 @@ class EcomDev_PHPUnit_Test_Case_Util
* @param string $type
* @param string $classAlias
* @param PHPUnit_Framework_MockObject_MockObject|PHPUnit_Framework_MockObject_MockBuilder $mock
* @throws PHPUnit_Framework_Exception
* @return void
*
* @throws InvalidArgumentException
*/
public static function replaceByMock($type, $classAlias, $mock)
{
......
......@@ -74,7 +74,7 @@ class EcomDev_PHPUnit_Test_Listener implements PHPUnit_Framework_TestListener
'listener' => $this
));
EcomDev_PHPUnit_Test_Case_Util::getFixture($suite->getName())
->setScope(EcomDev_PHPUnit_Model_Fixture_Interface::SCOPE_SHARED)
->setScope(EcomDev_PHPUnit_Model_FixtureInterface::SCOPE_SHARED)
->loadForClass($suite->getName());
$annotations = PHPUnit_Util_Test::parseTestMethodAnnotations(
......@@ -104,7 +104,7 @@ class EcomDev_PHPUnit_Test_Listener implements PHPUnit_Framework_TestListener
'listener' => $this
));
EcomDev_PHPUnit_Test_Case_Util::getFixture($suite->getName())
->setScope(EcomDev_PHPUnit_Model_Fixture_Interface::SCOPE_SHARED)
->setScope(EcomDev_PHPUnit_Model_FixtureInterface::SCOPE_SHARED)
->discard();
Mage::dispatchEvent('phpunit_test_case_end_after', array(
'suite' => $suite,
......@@ -143,7 +143,7 @@ class EcomDev_PHPUnit_Test_Listener implements PHPUnit_Framework_TestListener
if ($test instanceof PHPUnit_Framework_TestCase) {
EcomDev_PHPUnit_Helper::setTestCase($test);
EcomDev_PHPUnit_Test_Case_Util::getFixture(get_class($test))
->setScope(EcomDev_PHPUnit_Model_Fixture_Interface::SCOPE_LOCAL)
->setScope(EcomDev_PHPUnit_Model_FixtureInterface::SCOPE_LOCAL)
->loadByTestCase($test);
$annotations = $test->getAnnotations();
EcomDev_PHPUnit_Test_Case_Util::getFixture()
......@@ -174,7 +174,7 @@ class EcomDev_PHPUnit_Test_Listener implements PHPUnit_Framework_TestListener
if ($test instanceof PHPUnit_Framework_TestCase) {
EcomDev_PHPUnit_Test_Case_Util::getFixture(get_class($test))
->setScope(EcomDev_PHPUnit_Model_Fixture_Interface::SCOPE_LOCAL)
->setScope(EcomDev_PHPUnit_Model_FixtureInterface::SCOPE_LOCAL)
->discard(); // Clear applied fixture
if (EcomDev_PHPUnit_Test_Case_Util::getExpectation(get_class($test))->isLoaded()) {
......
......@@ -93,6 +93,7 @@ class EcomDev_PHPUnit_Test_Suite extends PHPUnit_Framework_TestSuite
* @param string $searchPath path for searching files with tests
* @param string $moduleCodeDir path where the module files are placed (e.g. app/code/local),
* used for determining the class name
* @return array
*/
protected static function _loadTestCases($searchPath, $moduleCodeDir)
{
......
......@@ -33,10 +33,9 @@ class EcomDev_PHPUnit_Test_Suite_Group extends PHPUnit_Framework_TestSuite
protected $suiteName = null;
/**
* Contructor adds test groups defined on global level
* Constructor adds test groups defined on global level
* and adds additional logic for test names retrieval
*
* (non-PHPdoc)
* @see PHPUnit_Framework_TestSuite::__construct()
*/
public function __construct($theClass = '', $groups = array())
......@@ -66,8 +65,8 @@ class EcomDev_PHPUnit_Test_Suite_Group extends PHPUnit_Framework_TestSuite
if ($test instanceof PHPUnit_Framework_TestSuite) {
/* @todo
* Post an issue into PHPUnit bugtracker for
* impossiblity for specifying group by parent test case
* Becuase it is a very dirty hack :(
* impossibility for specifying group by parent test case
* Because it is a very dirty hack :(
**/
$testGroups = array();
foreach ($groups as $group) {
......@@ -80,7 +79,7 @@ class EcomDev_PHPUnit_Test_Suite_Group extends PHPUnit_Framework_TestSuite
}
}
// Remove ungrouped tests group, if it exists
// Remove un grouped tests group, if it exists
if (isset($this->groups[self::NO_GROUP_KEYWORD])) {
unset($this->groups[self::NO_GROUP_KEYWORD]);
}
......@@ -89,7 +88,6 @@ class EcomDev_PHPUnit_Test_Suite_Group extends PHPUnit_Framework_TestSuite
/**
* Outputs test suite name from annotations
*
* (non-PHPdoc)
* @see PHPUnit_Framework_TestSuite::toString()
*/
public function toString()
......
......@@ -63,7 +63,7 @@
<global>ecomdev_phpunit/yaml_loader_global</global>
</loaders>
</yaml>
<!-- The names of directories inside Test for recognizion of tests per group -->
<!-- The names of directories inside Test for recognition of tests per group -->
<groups>
<models>Model</models>
<helpers>Helper</helpers>
......
......@@ -19,7 +19,7 @@
class EcomDev_PHPUnitTest_Test_Helper_Call extends EcomDev_PHPUnit_Test_Case
{
/**
* @var EcomDev_PHPUnit_Helper_Interface|PHPUnit_Framework_MockObject_MockObject
* @var EcomDev_PHPUnit_HelperInterface|PHPUnit_Framework_MockObject_MockObject
*/
protected $helper;
......@@ -28,7 +28,7 @@ class EcomDev_PHPUnitTest_Test_Helper_Call extends EcomDev_PHPUnit_Test_Case
*/
protected function setUp()
{
$this->helper = $this->getMockForAbstractClass('EcomDev_PHPUnit_Helper_Interface');
$this->helper = $this->getMockForAbstractClass('EcomDev_PHPUnit_HelperInterface');
$this->helper->expects($this->any())
->method('invoke')
->with($this->equalTo('someCustomHelper'))
......
......@@ -17,7 +17,7 @@ class EcomDev_PHPUnitTest_Test_Helper_Session extends EcomDev_PHPUnit_Test_Case_
}
/**
* Tests stubing of admin session
* Tests stub of admin session
*
*/
public function testAdminSessionAllRights()
......
<?php
class EcomDev_PHPUnitTest_Test_Lib_Constraint_Abstract extends PHPUnit_Framework_TestCase
class EcomDev_PHPUnitTest_Test_Lib_AbstractConstraint extends PHPUnit_Framework_TestCase
{
/**
* Test compare values functionality for constraint
......@@ -14,9 +14,9 @@ class EcomDev_PHPUnitTest_Test_Lib_Constraint_Abstract extends PHPUnit_Framework
public function testCompareValues($expectedValue, $actualValue, $expectedResult)
{
/**
* @var $constraint EcomDev_PHPUnit_Constraint_Abstract
* @var $constraint EcomDev_PHPUnit_AbstractConstraint
*/
$constraint = $this->getMockForAbstractClass('EcomDev_PHPUnit_Constraint_Abstract', array(), '', false);
$constraint = $this->getMockForAbstractClass('EcomDev_PHPUnit_AbstractConstraint', array(), '', false);
$this->assertSame(
$expectedResult,
$constraint->compareValues($expectedValue, $actualValue)
......
......@@ -16,18 +16,18 @@
* @author Ivan Chepurnyi <ivan.chepurnyi@ecomdev.org>
*/
class EcomDev_PHPUnitTest_Test_Lib_Helper_Abstract extends PHPUnit_Framework_TestCase
class EcomDev_PHPUnitTest_Test_Lib_AbstractHelper extends PHPUnit_Framework_TestCase
{
/**
*
*
* @var EcomDev_PHPUnit_Helper_Abstract|PHPUnit_Framework_MockObject_MockObject
* @var EcomDev_PHPUnit_AbstractHelper|PHPUnit_Framework_MockObject_MockObject
*/
protected $helper = null;
protected function setUp()
{
$this->helper = $this->getMockBuilder('EcomDev_PHPUnit_Helper_Abstract')
$this->helper = $this->getMockBuilder('EcomDev_PHPUnit_AbstractHelper')
->setMethods(array('hasMethod', 'callMethod'))
->enableArgumentCloning()
->getMockForAbstractClass();
......
......@@ -45,7 +45,7 @@ class EcomDev_PHPUnitTest_Test_Lib_Constraint_Config_Resource_Script extends Eco
/**
*
* @param $directory
* @param $directories
* @dataProvider dataProvider
*/
public function testParseVersions($directories)
......
......@@ -25,7 +25,7 @@ class EcomDev_PHPUnitTest_Test_Lib_Helper extends PHPUnit_Framework_TestCase
* Preserved array of already set helpers,
* to return them back when test case finished its run
*
* @var EcomDev_PHPUnit_Helper_Interface[]
* @var EcomDev_PHPUnit_HelperInterface[]
*/
protected $initializedHelpers;
......@@ -54,15 +54,15 @@ class EcomDev_PHPUnitTest_Test_Lib_Helper extends PHPUnit_Framework_TestCase
*
* @param int $count
* @param bool $setThem
* @return EcomDev_PHPUnit_Helper_Interface[]|PHPUnit_Framework_MockObject_MockObject[]
* @return EcomDev_PHPUnit_HelperInterface[]|PHPUnit_Framework_MockObject_MockObject[]
*/
protected function getHelpersForTest($count = 2, $setThem = false)
{
$result = array();
$helperInterfaces = array(
true => 'EcomDev_PHPUnit_Helper_Interface',
false => 'EcomDev_PHPUnit_Helper_Listener_Interface'
true => 'EcomDev_PHPUnit_HelperInterface',
false => 'EcomDev_PHPUnit_Helper_ListenerInterface'
);
for ($i = 0; $i < $count; $i ++) {
......@@ -261,7 +261,7 @@ class EcomDev_PHPUnitTest_Test_Lib_Helper extends PHPUnit_Framework_TestCase
/**
* Creates invoke method tests stub
*
* @return EcomDev_PHPUnit_Helper_Interface[]|PHPUnit_Framework_MockObject_MockObject[]
* @return EcomDev_PHPUnit_HelperInterface[]|PHPUnit_Framework_MockObject_MockObject[]
*/
protected function invokeStub()
{
......
......@@ -28,7 +28,7 @@ class EcomDev_PHPUnitTest_Test_Lib_Mock_Proxy extends PHPUnit_Framework_TestCase
*/
protected function setUp()
{
$this->mockProxy = new EcomDev_PHPUnit_Mock_Proxy($this, 'EcomDev_PHPUnit_Constraint_Abstract');
$this->mockProxy = new EcomDev_PHPUnit_Mock_Proxy($this, 'EcomDev_PHPUnit_AbstractConstraint');
$this->mockProxy->disableOriginalConstructor();
}
......@@ -77,7 +77,7 @@ class EcomDev_PHPUnitTest_Test_Lib_Mock_Proxy extends PHPUnit_Framework_TestCase
);
$this->assertInstanceOf(
'EcomDev_PHPUnit_Constraint_Abstract',
'EcomDev_PHPUnit_AbstractConstraint',
$mockInstance
);
......@@ -99,7 +99,7 @@ class EcomDev_PHPUnitTest_Test_Lib_Mock_Proxy extends PHPUnit_Framework_TestCase
'PHPUnit_Framework_MockObject_Builder_InvocationMocker',
$this->mockProxy->expects($this->any())->method('compareValues')
);
$this->assertAttributeInstanceOf('EcomDev_PHPUnit_Constraint_Abstract', 'mockInstance', $this->mockProxy);
$this->assertAttributeInstanceOf('EcomDev_PHPUnit_AbstractConstraint', 'mockInstance', $this->mockProxy);
}
public function testStaticExpects()
......@@ -115,7 +115,7 @@ class EcomDev_PHPUnitTest_Test_Lib_Mock_Proxy extends PHPUnit_Framework_TestCase
'PHPUnit_Framework_MockObject_Builder_InvocationMocker',
$this->mockProxy->staticExpectsProxy($this->any())->method('compareValues')
);
$this->assertAttributeInstanceOf('EcomDev_PHPUnit_Constraint_Abstract', 'mockInstance', $this->mockProxy);
$this->assertAttributeInstanceOf('EcomDev_PHPUnit_AbstractConstraint', 'mockInstance', $this->mockProxy);
}
public function testGetInvocationMocker()
......
......@@ -12,7 +12,7 @@
*
* @category EcomDev
* @package EcomDev_PHPUnit
* @copyright Copyright (c) 2010 Ecommerce Developers (http://www.ecomdev.org)
* @copyright Copyright (c) 2013 EcomDev B.V. (http://www.ecomdev.org)
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* @author Ivan Chepurnyi <ivan.chepurnyi@ecomdev.org>
*/
......
<?php
/**
* PHP Unit test suite for Magento
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
*
* @category EcomDev
* @package EcomDev_PHPUnit
* @copyright Copyright (c) 2013 EcomDev BV (http://www.ecomdev.org)
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* @author Ivan Chepurnyi <ivan.chepurnyi@ecomdev.org>
*/
/**
* Abstract constraint for EcomDev_PHPUnit constraints
* Contains flexible constraint types implementation
*
*/
abstract class EcomDev_PHPUnit_AbstractConstraint
extends PHPUnit_Framework_Constraint
{
/**
* List of validation rules for expected value
* It is an associative array with key as type and value
* as an array of rules.
*
* First item of the rule array is mandatory indicator,
* second is function name for checking the type,
* third one is the type that will be displayed in invalid argument expception
* each of them can be ommited or if it between other ones just by specifying null value
*
* @var array
*/
protected $_expectedValueValidation = array();
/**
* List of types that will use diff for displaying fail result
*
* @var array
*/
protected $_typesWithDiff = array();
/**
* Comparison type defined in the constructor
*
* @var string
*/
protected $_type = null;
/**
* Expected value defined in the constructor
*
* @var mixed
*/
protected $_expectedValue = null;
/**
* Custom actual value
*
* @var mixed
*/
protected $_actualValue = null;
/**
* Flag for using of actual value in failure description
*
* @var boolean
*/
protected $_useActualValue = false;
/**
* Comparison failure for nice failure messages
*
* @var PHPUnit_Framework_ComparisonFailure
*/
protected $_comparisonFailure = null;
/**
* Abstract cnstraint constructor,
* provides unified interface for working with multiple types of evalation
*
* @param string $type
* @param mixed $expectedValue
*
* @throws PHPUnit_Framework_Exception
*/
public function __construct($type, $expectedValue = null)
{
$reflection = EcomDev_Utils_Reflection::getReflection(get_class($this));
$types = array();
foreach ($reflection->getConstants() as $name => $constant) {
if (strpos($name, 'TYPE_') === 0) {
$types[] = $constant;
}
}
if (empty($type) || !is_string($type) || !in_array($type, $types)) {
throw PHPUnit_Util_InvalidArgumentHelper::factory(1, 'string', $type);
}
if (isset($this->_expectedValueValidation[$type])) {
$expectedValueType = (isset($this->_expectedValueValidation[$type][2]) ?
$this->_expectedValueValidation[$type][2] :
'');
// Mandatory check
if (isset($this->_expectedValueValidation[$type][0])
&& $this->_expectedValueValidation[$type][0]
&& $expectedValue === null) {
throw PHPUnit_Util_InvalidArgumentHelper::factory(2, $expectedValueType, $expectedValue);
}
// Type check
if (isset($this->_expectedValueValidation[$type][1])
&& $expectedValue !== null
&& !$this->_expectedValueValidation[$type][1]($expectedValue)) {
throw PHPUnit_Util_InvalidArgumentHelper::factory(2, $expectedValueType, $expectedValue);
}
}
$this->_type = $type;
$this->_expectedValue = $expectedValue;
}
/**
* Set actual value that will be used in the fail message
*
* @param mixed $actual
* @return EcomDev_PHPUnit_AbstractConstraint
*/
protected function setActualValue($actual)
{
$this->_useActualValue = true;
$this->_actualValue = $actual;
return $this;
}
/**
* Calls internal protected method by defined constraint type
* Also can be passed a single argument
*
* @param string $prefix
* @param mixed|null $argument
* @return mixed
*/
protected function callProtectedByType($prefix, $argument = null)
{
$camelizedType = uc_words($this->_type, '');
$methodName = $prefix . $camelizedType;
return $this->$methodName($argument);
}
/**
* Evaluates value by type.
*
* @see PHPUnit_Framework_Constraint::evaluate()
*
* @param mixed $other Value or object to evaluate.
* @param string $description Additional information about the test
* @param bool $returnResult Whether to return a result or throw an exception
* @return mixed
*/
public function evaluate($other, $description = '', $returnResult = false)
{
$success = false;
if ($this->callProtectedByType('evaluate', $other)) {
$success = true;
}
if ($returnResult) {
return $success;
}
if (!$success) {
$this->fail($other, $description);
}
}
/**
* Generates a failure exception based on exception type
*
* (non-PHPdoc)
* @see PHPUnit_Framework_Constraint::fail()
*/
public function fail($other, $description, PHPUnit_Framework_ComparisonFailure $comparisonFailure = NULL)
{
$failureDescription = sprintf('Failed asserting that %s', $this->failureDescription($other));
if (in_array($this->_type, $this->_typesWithDiff)) {
throw new EcomDev_PHPUnit_Constraint_Exception(
$failureDescription,
$this->getComparisonFailure($this->getExpectedValue(), $this->getActualValue($other)),
$description
);
} else {
throw new EcomDev_PHPUnit_Constraint_Exception(
$failureDescription, $this->getActualValue($other), $description
);
}
}
/**
* Adds compatibility to PHPUnit 3.6
*
* @param mixed $other
* @return string
*/
protected function failureDescription($other)
{
if (method_exists($this, 'customFailureDescription')) {
return $this->customFailureDescription($other);
}
return parent::failureDescription($other);
}
/**
* Returns a scalar representation of actual value,
* Returns $other if internal acutal value is not set
*
* @param Varien_Simplexml_Element $other
* @return scalar
*/
protected function getActualValue($other = null)
{
if ($this->_useActualValue) {
return $this->_actualValue;
}
return $other;
}
/**
* Returns a scalar representation of expected value
*
* @return scalar
*/
protected function getExpectedValue()
{
return $this->_expectedValue;
}
/**
* Text reperesentation of constraint
* (non-PHPdoc)
* @see PHPUnit_Framework_SelfDescribing::toString()
*/
public function toString()
{
return $this->callProtectedByType('text');
}
/**
* Exports value as string
*
* @param mixed $value
* @return string
*/
public function exportAsString($value)
{
if (is_array($value) && preg_match('/^\d+$/', implode('', array_keys($value)))) {
$stringValue = '';
foreach ($value as $val) {
$stringValue .= (is_string($val) ? $val : PHPUnit_Util_Type::export($val)) . "\n";
}
return $stringValue;
} else {
return PHPUnit_Util_Type::export($value);
}
}
/**
* Compares two values by using correct comparator for two types
*
* @param mixed $expectedValue
* @param mixed $actualValue
* @return bool
*/
public function compareValues($expectedValue, $actualValue)
{
$comparatorFactory = PHPUnit_Framework_ComparatorFactory::getDefaultInstance();
try {
$comparator = $comparatorFactory->getComparatorFor(
$expectedValue, $actualValue
);
$comparator->assertEquals(
$expectedValue,
$actualValue
);
}
catch (PHPUnit_Framework_ComparisonFailure $f) {
$this->_comparisonFailure = $f;
return false;
}
return true;
}
/**
* Retrieve comparison failure exception.
*
* Is used for generation of the failure messages
*
* @param mixed $expectedValue
* @param mixed $actualValue
*
* @return PHPUnit_Framework_ComparisonFailure
*/
public function getComparisonFailure($expectedValue, $actualValue)
{
if ($this->_comparisonFailure !== null) {
$failure = $this->_comparisonFailure;
$this->_comparisonFailure = null;
return $failure;
}
return new PHPUnit_Framework_ComparisonFailure(
$expectedValue,
$actualValue,
$this->exportAsString($expectedValue),
$this->exportAsString($actualValue)
);
}
}
<?php
/**
* PHP Unit test suite for Magento
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
*
* @category EcomDev
* @package EcomDev_PHPUnit
* @copyright Copyright (c) 2013 EcomDev BV (http://www.ecomdev.org)
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* @author Ivan Chepurnyi <ivan.chepurnyi@ecomdev.org>
*/
/**
* Base helper implementation
*/
abstract class EcomDev_PHPUnit_AbstractHelper
implements EcomDev_PHPUnit_HelperInterface
{
/**
* @var PHPUnit_Framework_TestCase
*/
protected $testCase;
/**
* Checks existence of helper action
*
* @param string $action
* @return bool
*/
public function has($action)
{
return $this->hasMethod('helper' . ucfirst($action));
}
/**
* Invokes defined helper action
*
* @param string $action
* @param array $args
*
* @throws RuntimeException
* @return mixed
*/
public function invoke($action, array $args)
{
if (!$this->has($action)) {
throw new RuntimeException(sprintf('Helper "%s" is not invokable.', $action));
}
$methodName = 'helper' . ucfirst($action);
return $this->callMethod($methodName, $args);
}
/**
* Call method to make testable of the invoke method
*
* @param $method
* @param $args
* @return mixed
*/
protected function callMethod($method, $args)
{
return call_user_func_array(array($this, $method), $args);
}
/**
* Has method for making abstract testable
*
* @param array $method
* @return bool
*/
protected function hasMethod($method)
{
$reflection = EcomDev_Utils_Reflection::getReflection($this);
return $reflection->hasMethod($method);
}
/**
* Sets test case property for helper
*
* @param PHPUnit_Framework_TestCase $testCase
*
* @return $this
*/
public function setTestCase(PHPUnit_Framework_TestCase $testCase)
{
$this->testCase = $testCase;
return $this;
}
}
\ No newline at end of file
......@@ -17,321 +17,11 @@
*/
/**
* Abstract constraint for EcomDev_PHPUnit constraints
* Contains flexible constaint types implementation
* @deprecated since 0.4.0
*
*/
abstract class EcomDev_PHPUnit_Constraint_Abstract
extends PHPUnit_Framework_Constraint
extends EcomDev_PHPUnit_AbstractConstraint
{
/**
* List of valiadation rules for expected value
* It is an associative array with key as type and value
* as an array of rules.
*
* First item of the rule array is mandatory indicator,
* second is function name for checking the type,
* third one is the type that will be displayed in invalid argument expception
* each of them can be ommited or if it between other ones just by specifying null value
*
* @var array
*/
protected $_expectedValueValidation = array();
/**
* List of types that will use diff for displaying fail result
*
* @var array
*/
protected $_typesWithDiff = array();
/**
* Comparisment type defined in the constructor
*
* @var string
*/
protected $_type = null;
/**
* Expected value defined in the constructor
*
* @var mixed
*/
protected $_expectedValue = null;
/**
* Custom actual value
*
* @var mixed
*/
protected $_actualValue = null;
/**
* Flag for using of actual value in failure description
*
* @var boolean
*/
protected $_useActualValue = false;
/**
* Comparison failure for nice failure messages
*
* @var PHPUnit_Framework_ComparisonFailure
*/
protected $_comparisonFailure = null;
/**
* Abstract cnstraint constructor,
* provides unified interface for working with multiple types of evalation
*
* @param string $type
* @param mixed $expectedValue
*
* @throws PHPUnit_Framework_Exception
*/
public function __construct($type, $expectedValue = null)
{
$reflection = EcomDev_Utils_Reflection::getReflection(get_class($this));
$types = array();
foreach ($reflection->getConstants() as $name => $constant) {
if (strpos($name, 'TYPE_') === 0) {
$types[] = $constant;
}
}
if (empty($type) || !is_string($type) || !in_array($type, $types)) {
throw PHPUnit_Util_InvalidArgumentHelper::factory(1, 'string', $type);
}
if (isset($this->_expectedValueValidation[$type])) {
$expectedValueType = (isset($this->_expectedValueValidation[$type][2]) ?
$this->_expectedValueValidation[$type][2] :
'');
// Mandatory check
if (isset($this->_expectedValueValidation[$type][0])
&& $this->_expectedValueValidation[$type][0]
&& $expectedValue === null) {
throw PHPUnit_Util_InvalidArgumentHelper::factory(2, $expectedValueType, $expectedValue);
}
// Type check
if (isset($this->_expectedValueValidation[$type][1])
&& $expectedValue !== null
&& !$this->_expectedValueValidation[$type][1]($expectedValue)) {
throw PHPUnit_Util_InvalidArgumentHelper::factory(2, $expectedValueType, $expectedValue);
}
}
$this->_type = $type;
$this->_expectedValue = $expectedValue;
}
/**
* Set actual value that will be used in the fail message
*
* @param mixed $actual
* @return EcomDev_PHPUnit_Constraint_Abstract
*/
protected function setActualValue($actual)
{
$this->_useActualValue = true;
$this->_actualValue = $actual;
return $this;
}
/**
* Calls internal protected method by defined constraint type
* Also can be passed a single argument
*
* @param string $prefix
* @return mixed
*/
protected function callProtectedByType($prefix, $argument = null)
{
$camelizedType = uc_words($this->_type, '');
$methodName = $prefix . $camelizedType;
return $this->$methodName($argument);
}
/**
* Evaluates value by type.
*
* @see PHPUnit_Framework_Constraint::evaluate()
*
* @param mixed $other Value or object to evaluate.
* @param string $description Additional information about the test
* @param bool $returnResult Whether to return a result or throw an exception
* @return mixed
*/
public function evaluate($other, $description = '', $returnResult = false)
{
$success = false;
if ($this->callProtectedByType('evaluate', $other)) {
$success = true;
}
if ($returnResult) {
return $success;
}
if (!$success) {
$this->fail($other, $description);
}
}
/**
* Generates a failure exception based on exception type
*
* (non-PHPdoc)
* @see PHPUnit_Framework_Constraint::fail()
*/
public function fail($other, $description, PHPUnit_Framework_ComparisonFailure $comparisonFailure = NULL)
{
$failureDescription = sprintf('Failed asserting that %s', $this->failureDescription($other));
if (in_array($this->_type, $this->_typesWithDiff)) {
throw new EcomDev_PHPUnit_Constraint_Exception(
$failureDescription,
$this->getComparisonFailure($this->getExpectedValue(), $this->getActualValue($other)),
$description
);
} else {
throw new EcomDev_PHPUnit_Constraint_Exception(
$failureDescription, $this->getActualValue($other), $description
);
}
}
/**
* Adds compatibility to PHPUnit 3.6
*
* @param mixed $other
* @param mixed $description (custom description)
* @param boolean $not
* @return string
*/
protected function failureDescription($other)
{
if (method_exists($this, 'customFailureDescription')) {
return $this->customFailureDescription($other);
}
return parent::failureDescription($other);
}
/**
* Returns a scalar representation of actual value,
* Returns $other if internal acutal value is not set
*
* @param Varien_Simplexml_Element $other
* @return scalar
*/
protected function getActualValue($other = null)
{
if ($this->_useActualValue) {
return $this->_actualValue;
}
return $other;
}
/**
* Returns a scalar representation of expected value
*
* @return scalar
*/
protected function getExpectedValue()
{
return $this->_expectedValue;
}
/**
* Text reperesentation of constraint
* (non-PHPdoc)
* @see PHPUnit_Framework_SelfDescribing::toString()
*/
public function toString()
{
return $this->callProtectedByType('text');
}
/**
* Exports value as string
*
* @param mixed $value
* @return string
*/
public function exportAsString($value)
{
if (is_array($value) && preg_match('/^\d+$/', implode('', array_keys($value)))) {
$stringValue = '';
foreach ($value as $val) {
$stringValue .= (is_string($val) ? $val : PHPUnit_Util_Type::export($val)) . "\n";
}
return $stringValue;
} else {
return PHPUnit_Util_Type::export($value);
}
}
/**
* Compares two values by using correct comparator for two types
*
* @param mixed $expectedValue
* @param mixed $actualValue
* @return bool
*/
public function compareValues($expectedValue, $actualValue)
{
$comparatorFactory = PHPUnit_Framework_ComparatorFactory::getDefaultInstance();
try {
$comparator = $comparatorFactory->getComparatorFor(
$expectedValue, $actualValue
);
$comparator->assertEquals(
$expectedValue,
$actualValue
);
}
catch (PHPUnit_Framework_ComparisonFailure $f) {
$this->_comparisonFailure = $f;
return false;
}
return true;
}
/**
* Retrieve comparison failure exception.
*
* Is used for generation of the failure messages
*
* @param mixed $actualValue
* @param mixed $expectedValue
*
* @return PHPUnit_Framework_ComparisonFailure
*/
public function getComparisonFailure($actualValue, $expectedValue)
{
if ($this->_comparisonFailure !== null) {
$failure = $this->_comparisonFailure;
$this->_comparisonFailure = null;
return $failure;
}
return new PHPUnit_Framework_ComparisonFailure(
$expectedValue,
$actualValue,
$this->exportAsString($expectedValue),
$this->exportAsString($actualValue)
);
}
}
<?php
/**
* PHP Unit test suite for Magento
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
*
* @category EcomDev
* @package EcomDev_PHPUnit
* @copyright Copyright (c) 2013 EcomDev BV (http://www.ecomdev.org)
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* @author Ivan Chepurnyi <ivan.chepurnyi@ecomdev.org>
*/
/**
* Abstract class for constraints based on configuration
*
*/
abstract class EcomDev_PHPUnit_Constraint_AbstractConfig
extends EcomDev_PHPUnit_AbstractConstraint
implements EcomDev_PHPUnit_Constraint_ConfigInterface
{
/**
* Config node path defined in the constructor
*
* @var string
*/
protected $_nodePath = null;
/**
* Constraint constructor
*
* @param string $nodePath
* @param string $type
* @param mixed $expectedValue
* @throws PHPUnit_Framework_Exception
*/
public function __construct($nodePath, $type, $expectedValue = null)
{
if (empty($nodePath) || !is_string($nodePath)) {
throw PHPUnit_Util_InvalidArgumentHelper::factory(1, 'string', $type);
}
$this->_nodePath = $nodePath;
parent::__construct($type, $expectedValue);
}
/**
* Returns node path for checking
*
* (non-PHPdoc)
* @see EcomDev_PHPUnit_Constraint_ConfigInterface::getNodePath()
*/
public function getNodePath()
{
return $this->_nodePath;
}
/**
* Automatically evaluate to false if the node was not found
*
* (non-PHPdoc)
* @see EcomDev_PHPUnit_ConstraintAbstract::evaluate()
*/
public function evaluate($other, $description = '', $returnResult = false)
{
if ($other === false) {
// If node was not found, than evaluation fails
return false;
}
return parent::evaluate($other, $description, $returnResult);
}
/**
* Returns a scalar representation of actual value,
* Returns $other if internal acutal value is not set
*
* @param Varien_Simplexml_Element $other
* @return scalar
*/
protected function getActualValue($other = null)
{
if (!$this->_useActualValue && $other->hasChildren()) {
return $this->getXmlAsDom($other);
} elseif (!$this->_useActualValue) {
return (string) $other;
}
return parent::getActualValue($other);
}
/**
* Returns a scalar representation of expected value
*
* @return string
*/
protected function getExpectedValue()
{
if ($this->_expectedValue instanceof Varien_Simplexml_Element) {
return $this->getXmlAsDom($this->_expectedValue);
}
return parent::getExpectedValue();
}
/**
* Converts xml to dom object
*
* @param $xmlValue
* @return DOMDocument
*/
protected function getXmlAsDom($xmlValue)
{
if ($xmlValue instanceof SimpleXMLElement) {
$xmlValue = $xmlValue->asXML();
}
$domValue = new DOMDocument;
$domValue->preserveWhiteSpace = FALSE;
$domValue->loadXML($xmlValue);
return $domValue;
}
}
\ No newline at end of file
......@@ -40,23 +40,26 @@ class EcomDev_PHPUnit_Constraint_Config extends PHPUnit_Framework_Constraint
/**
* Creates configuration constraint for config object
*
* @param Varien_Simplexml_Config $config
* @param $constraint
* @throws PHPUnit_Framework_Exception
* @internal param \Varien_Simplexml_Config $config
*/
public function __construct($constraint)
{
if (!$constraint instanceof EcomDev_PHPUnit_Constraint_Config_Interface) {
if (!$constraint instanceof EcomDev_PHPUnit_Constraint_ConfigInterface) {
throw PHPUnit_Util_InvalidArgumentHelper::factory(
1, 'EcomDev_PHPUnit_Constraint_Config_Interface'
1, 'EcomDev_PHPUnit_Constraint_ConfigInterface'
);
}
$this->constraint = $constraint;
}
/**
* Failure generator
*
* @param mixed $other
* @param string $description
* @param boolean $not
* @param PHPUnit_Framework_ComparisonFailure $comparisonFailure
*/
public function fail($other, $description, PHPUnit_Framework_ComparisonFailure $comparisonFailure = NULL)
{
......@@ -69,7 +72,10 @@ class EcomDev_PHPUnit_Constraint_Config extends PHPUnit_Framework_Constraint
* Retrives a node value from configuration by child constraint path
*
*
* @param Varien_Simplexml_Config $other
* @param $config
* @throws EcomDev_PHPUnit_Constraint_Exception
* @return
* @internal param \Varien_Simplexml_Config $other
*/
protected function getNodeValue($config)
{
......@@ -90,6 +96,9 @@ class EcomDev_PHPUnit_Constraint_Config extends PHPUnit_Framework_Constraint
* Evalutes constraint that is passed in the parameter
*
* @param Varien_Simplexml_Config $config
* @param string $description
* @param bool $returnResult
* @return bool
* @see PHPUnit_Framework_Constraint::evaluate()
*/
public function evaluate($config, $description = '', $returnResult = false)
......
......@@ -17,113 +17,11 @@
*/
/**
* Abstract class for constraints based on configuration
* @deprecated since 0.4.0
*
*/
abstract class EcomDev_PHPUnit_Constraint_Config_Abstract
extends EcomDev_PHPUnit_Constraint_Abstract
implements EcomDev_PHPUnit_Constraint_Config_Interface
extends EcomDev_PHPUnit_Constraint_AbstractConfig
{
/**
* Config node path defined in the constructor
*
* @var string
*/
protected $_nodePath = null;
/**
* Constraint constructor
*
* @param string $nodePath
* @param string $type
* @param mixed $expectedValue
*/
public function __construct($nodePath, $type, $expectedValue = null)
{
if (empty($nodePath) || !is_string($nodePath)) {
throw PHPUnit_Util_InvalidArgumentHelper::factory(1, 'string', $type);
}
$this->_nodePath = $nodePath;
parent::__construct($type, $expectedValue);
}
/**
* Returns node path for checking
*
* (non-PHPdoc)
* @see EcomDev_PHPUnit_Constraint_Config_Interface::getNodePath()
*/
public function getNodePath()
{
return $this->_nodePath;
}
/**
* Automatically evaluate to false if the node was not found
*
* (non-PHPdoc)
* @see EcomDev_PHPUnit_Constraint_Abstract::evaluate()
*/
public function evaluate($other, $description = '', $returnResult = false)
{
if ($other === false) {
// If node was not found, than evaluation fails
return false;
}
return parent::evaluate($other, $description, $returnResult);
}
/**
* Returns a scalar representation of actual value,
* Returns $other if internal acutal value is not set
*
* @param Varien_Simplexml_Element $other
* @return scalar
*/
protected function getActualValue($other = null)
{
if (!$this->_useActualValue && $other->hasChildren()) {
return $this->getXmlAsDom($other);
} elseif (!$this->_useActualValue) {
return (string) $other;
}
return parent::getActualValue($other);
}
/**
* Returns a scalar representation of expected value
*
* @return string
*/
protected function getExpectedValue()
{
if ($this->_expectedValue instanceof Varien_Simplexml_Element) {
return $this->getXmlAsDom($this->_expectedValue);
}
return parent::getExpectedValue();
}
/**
* Converts xml to dom object
*
* @param $xmlValue
* @return DOMDocument
*/
protected function getXmlAsDom($xmlValue)
{
if ($xmlValue instanceof SimpleXMLElement) {
$xmlValue = $xmlValue->asXML();
}
$domValue = new DOMDocument;
$domValue->preserveWhiteSpace = FALSE;
$domValue->loadXML($xmlValue);
return $domValue;
}
}
......@@ -5,7 +5,7 @@
*
*/
class EcomDev_PHPUnit_Constraint_Config_ClassAlias
extends EcomDev_PHPUnit_Constraint_Config_Abstract
extends EcomDev_PHPUnit_Constraint_AbstractConfig
{
const XML_PATH_CLASS_ALIAS = 'global/%s/%s';
......@@ -56,6 +56,7 @@ class EcomDev_PHPUnit_Constraint_Config_ClassAlias
* @param string $classAlias
* @param string $expectedClassName
* @param string $type
* @throws PHPUnit_Framework_Exception
*/
public function __construct($group, $classAlias, $expectedClassName, $type = self::TYPE_CLASS_ALIAS)
{
......
......@@ -22,11 +22,11 @@
*
*/
class EcomDev_PHPUnit_Constraint_Config_EventObserver
extends EcomDev_PHPUnit_Constraint_Config_Abstract
extends EcomDev_PHPUnit_Constraint_AbstractConfig
{
const XML_PATH_EVENTS = '%s/events';
const TYPE_DEFINDED = 'defined';
const TYPE_DEFINED = 'defined';
const OBSERVER_TYPE_DISABLED = 'disabled';
const OBSERVER_TYPE_SINGLETON = 'singleton';
......@@ -75,9 +75,11 @@ class EcomDev_PHPUnit_Constraint_Config_EventObserver
* @param string $eventName
* @param string $observerClassAlias
* @param string $observerMethod
* @param string $type
* @param string|null $observerName
* @throws PHPUnit_Framework_Exception
*/
public function __construct($area, $eventName, $observerClassAlias, $observerMethod, $type = self::TYPE_DEFINDED, $observerName = null)
public function __construct($area, $eventName, $observerClassAlias, $observerMethod, $type = self::TYPE_DEFINED, $observerName = null)
{
if (empty($area) || !is_string($area)) {
throw PHPUnit_Util_InvalidArgumentHelper::factory(1, 'string', $area);
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment