Skip to content
This repository was archived by the owner on May 27, 2023. It is now read-only.

allow to change existing scope models #82

Closed
wants to merge 14 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .travis/composer.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"require": {
"ecomdev/mage-ci": "*"
"ecomdev/mage-ci": "*",
"mikey179/vfsStream": "*"
},
"config": {
"bin-dir": "bin"
Expand Down
1 change: 0 additions & 1 deletion app/code/community/EcomDev/PHPUnit/Controller/Front.php
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
27 changes: 15 additions & 12 deletions app/code/community/EcomDev/PHPUnit/Controller/Request/Http.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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()
Expand All @@ -63,7 +62,7 @@ public function initForward()

/**
* Returns only request uri that was set before
* (non-PHPdoc)
*
* @see Zend_Controller_Request_Http::getRequestUri()
*/
public function getRequestUri()
Expand Down Expand Up @@ -119,7 +118,7 @@ public function resetQuery()
}

/**
* Resets $_POST superglobal for test request
* Resets $_POST super global for test request
*
* @return EcomDev_PHPUnit_Controller_Request_Http
*/
Expand Down Expand Up @@ -225,7 +224,6 @@ public function setHeaders(array $headers)
/**
* Returns header from test request parameters
*
* (non-PHPdoc)
* @see Zend_Controller_Request_Http::getHeader()
*/
public function getHeader($header)
Expand Down Expand Up @@ -261,7 +259,7 @@ protected function headerName($name)
}

/**
* 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
*
Expand All @@ -281,7 +279,7 @@ public function setServer($name, $value)
}

/**
* 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
Expand All @@ -295,7 +293,7 @@ public function setServers(array $values)
}

/**
* Resets $_SERVER superglobal to previous state
* Resets $_SERVER super global to previous state
*
* @return EcomDev_PHPUnit_Controller_Request_Http
*/
Expand All @@ -306,7 +304,7 @@ public function resetServer()
$_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]);
}
}
Expand Down Expand Up @@ -343,12 +341,18 @@ public function setIsSecure($flag = true)
/**
* 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)
{
$baseUrl = $this->getBaseUrl();

if (!$baseUrl) {
$baseUrl = Mage::app()->getConfig()->getNode(
EcomDev_PHPUnit_Model_Config::XML_PATH_UNSECURE_BASE_URL
);
}

$parts = parse_url($baseUrl);

if (!isset($parts['host'])) {
Expand All @@ -366,7 +370,6 @@ public function getHttpHost($trimPort = false)
/**
* Returns only base url that was set before
*
* (non-PHPdoc)
* @see Mage_Core_Controller_Request_Http::getBaseUrl()
*/
public function getBaseUrl()
Expand Down
14 changes: 7 additions & 7 deletions app/code/community/EcomDev/PHPUnit/Controller/Response/Http.php
Original file line number Diff line number Diff line change
Expand Up @@ -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";

Expand All @@ -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
Expand Down Expand Up @@ -80,7 +80,6 @@ public function reset()
/**
* Implementation of sending the headers to output
*
* (non-PHPdoc)
* @see Mage_Core_Controller_Response_Http::sendHeaders()
*/
public function sendHeaders()
Expand All @@ -91,6 +90,7 @@ public function sendHeaders()
$this->_sentHeaders[null] = 'HTTP/1.1 ' . $this->_httpResponseCode;

foreach ($this->_headersRaw as $headerRaw) {
if (strpos($headerRaw, ':') === false) { continue; }
list($headerName, $headerValue) = explode(':', $headerRaw, 2);
$headerName = $this->_normalizeHeader($headerName);
if (isset($this->_sentHeaders[$headerName])) {
Expand Down Expand Up @@ -155,7 +155,7 @@ public function getSentHeader($headerName)

/**
* Implementation of sending response for test case
* (non-PHPdoc)
*
* @see Mage_Core_Controller_Response_Http::sendResponse()
*/
public function sendResponse()
Expand Down Expand Up @@ -212,7 +212,7 @@ public function getOutputBody()
/**
* Can send headers implementation for test case
*
* (non-PHPdoc)
*
* @see Zend_Controller_Response_Abstract::canSendHeaders()
*/
public function canSendHeaders($throw = false)
Expand All @@ -224,4 +224,4 @@ public function canSendHeaders($throw = false)

return $this->_sentHeaders === null;
}
}
}
11 changes: 7 additions & 4 deletions app/code/community/EcomDev/PHPUnit/Model/App.php
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -253,13 +253,14 @@ public function getCacheOptions()
'_allowedCacheOptions'
);
}

/**
* Retrieves a model from config and checks it on interface implementation
*
* @param string $configPath
* @param string $interface
* @param string $modelName
* @throws RuntimeException
* @return Mage_Core_Model_Abstract
*/
protected function _getModelFromConfig($configPath, $interface, $modelName = 'Model')
Expand Down Expand Up @@ -330,6 +331,7 @@ public function resetAreas()
*
* @param string $key
* @param string $value
* @return $this
*/
public function replaceRegistry($key, $value)
{
Expand All @@ -356,7 +358,7 @@ public function removeEventArea($code)

/**
* Returns request for test suite
* (non-PHPdoc)
*
* @see Mage_Core_Model_App::getRequest()
* @return EcomDev_PHPUnit_Controller_Request_Http
*/
Expand All @@ -374,7 +376,7 @@ public function getRequest()

/**
* Returns response for test suite
* (non-PHPdoc)
*
* @see Mage_Core_Model_App::getResponse()
* @return EcomDev_PHPUnit_Controller_Response_Http
*/
Expand All @@ -397,6 +399,7 @@ public function getResponse()
*
* @param string $configPath
* @param string $interface
* @throws RuntimeException
* @return string
*/
protected function _getClassNameFromConfig($configPath, $interface = null)
Expand Down
2 changes: 1 addition & 1 deletion app/code/community/EcomDev/PHPUnit/Model/App/Area.php
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
6 changes: 3 additions & 3 deletions app/code/community/EcomDev/PHPUnit/Model/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -118,9 +118,8 @@ public function flushReplaceInstanceCreation()
}

/**
* 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())
Expand All @@ -133,7 +132,7 @@ public function getModelInstance($modelClass='', $constructArguments=array())
}

/**
* Overriden for test case model instance creation mocking
* Overridden for test case model instance creation mocking
*
* (non-PHPdoc)
* @see Mage_Core_Model_Config::getModelInstance()
Expand Down Expand Up @@ -170,6 +169,7 @@ public function getRealResourceModelClassAlias($classAlias)
/**
* Loads scope snapshot
*
* @throws RuntimeException
* @return EcomDev_PHPUnit_Model_Config
*/
public function loadScopeSnapshot()
Expand Down
8 changes: 4 additions & 4 deletions app/code/community/EcomDev/PHPUnit/Model/Design/Package.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 5 additions & 5 deletions app/code/community/EcomDev/PHPUnit/Model/Expectation.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?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
Expand Down Expand Up @@ -38,7 +38,7 @@ public function getDataObjectClassAlias()
/**
* 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())
{
Expand Down Expand Up @@ -77,7 +77,7 @@ public function getDataObject($pathFormat = null, $args = array())
/**
* Applies loaded data
*
* @see EcomDev_PHPUnit_Model_Test_Loadable_Interface::apply()
* @see EcomDev_PHPUnit_Model_Test_LoadableInterface::apply()
*/
public function apply()
{
Expand All @@ -89,7 +89,7 @@ public function apply()
* 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()
{
Expand All @@ -116,7 +116,7 @@ public function isLoaded()
/**
* 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)
{
Expand Down
23 changes: 3 additions & 20 deletions app/code/community/EcomDev/PHPUnit/Model/Expectation/Interface.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Loading