本文整理汇总了PHP中EcomDev_Utils_Reflection::setRestrictedPropertyValue方法的典型用法代码示例。如果您正苦于以下问题:PHP EcomDev_Utils_Reflection::setRestrictedPropertyValue方法的具体用法?PHP EcomDev_Utils_Reflection::setRestrictedPropertyValue怎么用?PHP EcomDev_Utils_Reflection::setRestrictedPropertyValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类EcomDev_Utils_Reflection
的用法示例。
在下文中一共展示了EcomDev_Utils_Reflection::setRestrictedPropertyValue方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setUp
public function setUp()
{
$this->_helper = $this->getHelperMock('ebayenterprise_giftcard/data');
$this->_helper->expects($this->any())->method('__')->with($this->isType('string'))->will($this->returnArgument(0));
// disable constructor to prevent having to mock dependencies
$this->_checkoutSession = $this->getModelMockBuilder('checkout/session')->disableOriginalConstructor()->setMethods(array('addError'))->getMock();
// disable constructor to prevent having to mock dependencies
$this->_giftCardSession = $this->getModelMockBuilder('ebayenterprise_giftcard/session')->disableOriginalConstructor()->setMethods(array('setEbayEnterpriseCurrentGiftCard'))->getMock();
// disable constructor to avoid mocking dependencies
$this->_request = $this->getMockBuilder('Mage_Core_Controller_Request_Http')->disableOriginalConstructor()->getMock();
$this->_request->expects($this->any())->method('getParam')->will($this->returnValueMap(array(array(self::CARDNUMBER_FIELD, '', $this->_giftCardNumber), array(self::PIN_FIELD, '', $this->_giftCardPin))));
$this->_giftCard = $this->getMock('EbayEnterprise_GiftCard_Model_IGiftcard');
$this->_giftCard->expects($this->any())->method('setPin')->with($this->isType('string'))->will($this->returnSelf());
// disable constructor to avoid mocking dependencies
$this->_container = $this->getMockBuilder('EbayEnterprise_GiftCard_Model_IContainer')->disableOriginalConstructor()->getMock();
// use value map so that if anything other than the giftcard number and pin are passed in,
// the function will return null. so tests should fail if a change breaks assumptions about
// getGiftCard's arguments.
$this->_container->expects($this->any())->method('getGiftCard')->will($this->returnValueMap(array(array($this->_giftCardNumber, $this->_giftCard))));
// disable constructor to avoid mocking dependencies
$this->_controller = $this->getMockBuilder('EbayEnterprise_GiftCard_Controller_Abstract')->disableOriginalConstructor()->setMethods(array('_redirect', 'loadLayout', 'renderLayout', 'setFlag'))->getMock();
// inject mocked dependencies
EcomDev_Utils_Reflection::setRestrictedPropertyValue($this->_controller, '_container', $this->_container);
EcomDev_Utils_Reflection::setRestrictedPropertyValue($this->_controller, '_helper', $this->_helper);
EcomDev_Utils_Reflection::setRestrictedPropertyValue($this->_controller, '_request', $this->_request);
}
示例2: tearDown
protected function tearDown()
{
// Restore the original inventory helper instance to the payload helper
// to prevent the mock form potentially polluting other tests with
// unexpected mock behavior.
EcomDev_Utils_Reflection::setRestrictedPropertyValue($this->payloadHelper, 'inventoryHelper', $this->origInventoryHelper);
}
示例3: testGetDefaultData
/**
*
*
* @param string $type
* @param array $requiredKeys
* @dataProvider dataProvider
* @loadFixture config
*/
public function testGetDefaultData($type, $requiredKeys)
{
EcomDev_Utils_Reflection::setRestrictedPropertyValue($this->processor, 'requiredKeys', $requiredKeys);
EcomDev_Utils_Reflection::setRestrictedPropertyValue($this->processor, 'type', $type);
$dataSet = $this->readAttribute($this, 'dataName');
$this->assertEquals($this->expected($dataSet)->getData(), $this->processor->getDefaultData());
}
示例4: __construct
/**
* Constructor adds test groups defined on global level
* and adds additional logic for test names retrieval
*
* @see PHPUnit_Framework_TestSuite::__construct()
*/
public function __construct($theClass = '', $groups = array())
{
if (!$theClass instanceof ReflectionClass) {
$theClass = EcomDev_Utils_Reflection::getReflection($theClass);
}
// Check annotations for test case name
$annotations = PHPUnit_Util_Test::parseTestMethodAnnotations($theClass->getName());
if (isset($annotations['name'])) {
$this->suiteName = $annotations['name'];
}
// Creates all test instances
parent::__construct($theClass);
// Just sort-out them by our internal groups
foreach ($groups as $group) {
$this->groups[$group] = $this->tests();
}
foreach ($this->tests() as $test) {
if ($test instanceof PHPUnit_Framework_TestSuite) {
/* @todo
* Post an issue into PHPUnit bugtracker for
* impossibility for specifying group by parent test case
* Because it is a very dirty hack :(
**/
$testGroups = array();
foreach ($groups as $group) {
$testGroups[$group] = $test->tests();
}
EcomDev_Utils_Reflection::setRestrictedPropertyValue($test, 'groups', $testGroups);
}
}
// Remove un grouped tests group, if it exists
if (isset($this->groups[self::NO_GROUP_KEYWORD])) {
unset($this->groups[self::NO_GROUP_KEYWORD]);
}
}
示例5: testRemoveMethod
public function testRemoveMethod()
{
EcomDev_Utils_Reflection::setRestrictedPropertyValue($this->mockProxy, 'methods', array('methodName', 'methodName2', 'methodName3'));
$this->mockProxy->removeMethod('methodName2');
$this->assertAttributeEquals(array('methodName', 'methodName3'), 'methods', $this->mockProxy);
$this->mockProxy->removeMethod('methodName');
$this->assertAttributeEquals(array('methodName3'), 'methods', $this->mockProxy);
}
示例6: removeMethod
/**
* Removes method name from a mock builder
*
* @param string $methodName
* @return $this
*/
public function removeMethod($methodName)
{
$methods = ReflectionUtil::getRestrictedPropertyValue($this, 'methods');
$methodIndex = array_search($methodName, $methods);
if ($methodIndex !== false) {
array_splice($methods, $methodIndex, 1);
}
ReflectionUtil::setRestrictedPropertyValue($this, 'methods', $methods);
return $this;
}
示例7: testGetStockMap
/**
* Test EbayEnterprise_Catalog_Helper_Map_Stock::_getStockMap method with the following expectations
* Expectation 1: when this test invoked this method EbayEnterprise_Catalog_Helper_Map_Stock::_getStockMap
* will set the class property EbayEnterprise_Catalog_Helper_Map_Stock::_StockMap with an
* array of ROM SalesClass values mapped to valid (we hope) Magento_CatalogInventory_Model_Stock::BACKORDER_xxx value
*/
public function testGetStockMap()
{
$mapData = array('advanceOrderOpen' => 1, 'advanceOrderLimited' => 2);
$configRegistryMock = $this->getModelMock('eb2ccore/config_registry', array('getConfigData'));
$configRegistryMock->expects($this->once())->method('getConfigData')->with($this->identicalTo(EbayEnterprise_Catalog_Helper_Map_Stock::STOCK_CONFIG_PATH))->will($this->returnValue($mapData));
$this->replaceByMock('model', 'eb2ccore/config_registry', $configRegistryMock);
$stock = Mage::helper('ebayenterprise_catalog/map_stock');
EcomDev_Utils_Reflection::setRestrictedPropertyValue($stock, '_stockMap', array());
$this->assertSame($mapData, EcomDev_Utils_Reflection::invokeRestrictedMethod($stock, '_getStockMap', array()));
}
示例8: testGetGiftCardMap
/**
* Test _getGiftCardMap method with the following expectations
* Expectation 1: when this test invoked this method EbayEnterprise_Catalog_Helper_Map_Giftcard::_getGiftCardMap
* will set the class property EbayEnterprise_Catalog_Helper_Map_Giftcard::_giftcardMap with an
* array of eb2c giftcard tender type key map to Magento giftcard type
*/
public function testGetGiftCardMap()
{
$mapData = array('SD' => 'virtual', 'SP' => 'physical', 'ST' => 'combined', 'SV' => 'virtual', 'SX' => 'combined');
$configRegistryMock = $this->getModelMock('eb2ccore/config_registry', array('getConfigData'));
$configRegistryMock->expects($this->once())->method('getConfigData')->with($this->identicalTo(EbayEnterprise_Catalog_Helper_Feed::GIFTCARD_TENDER_CONFIG_PATH))->will($this->returnValue($mapData));
$this->replaceByMock('model', 'eb2ccore/config_registry', $configRegistryMock);
$giftcard = Mage::helper('ebayenterprise_catalog/map_giftcard');
EcomDev_Utils_Reflection::setRestrictedPropertyValue($giftcard, '_giftcardMap', array());
$this->assertSame($mapData, EcomDev_Utils_Reflection::invokeRestrictedMethod($giftcard, '_getGiftCardMap', array()));
}
示例9: tearDown
public function tearDown()
{
$collection = $this->getProductSyncCronScheduleCollection();
foreach ($collection as $item) {
$item->delete();
}
$resource = Mage::getModel("core/resource");
$resource->getConnection("core_write")->delete($resource->getTableName("klevu_search/order_sync"));
EcomDev_Utils_Reflection::setRestrictedPropertyValue(Mage::getConfig(), "_classNameCache", array());
parent::tearDown();
}
示例10: resetTranslate
/**
* Resets translator data
*
* @return EcomDev_PHPUnit_Model_App_Area
*/
public function resetTranslate()
{
$translator = $this->_application->getTranslator();
EcomDev_Utils_Reflection::setRestrictedPropertyValue($translator, '_config', null);
EcomDev_Utils_Reflection::setRestrictedPropertyValue($translator, '_locale', null);
EcomDev_Utils_Reflection::setRestrictedPropertyValue($translator, '_cacheId', null);
EcomDev_Utils_Reflection::setRestrictedPropertyValue($translator, '_translateInline', null);
EcomDev_Utils_Reflection::setRestrictedPropertyValue($translator, '_dataScope', null);
EcomDev_Utils_Reflection::setRestrictedPropertyValue($translator, '_data', array());
return $this;
}
示例11: testItReplacesRegularLayoutWithCompilerOne
/**
* @singleton core/layout
*/
public function testItReplacesRegularLayoutWithCompilerOne()
{
$originalValue = Mage::app()->getLayout();
$manager = $this->mockModel('ecomdev_layoutcompiler/manager')->replaceByMock('singleton');
$manager->expects($this->once())->method('isEnabled')->willReturn(true);
$layout = $this->getMockForAbstractClass('EcomDev_LayoutCompiler_Contract_LayoutInterface');
$manager->expects($this->once())->method('getLayout')->willReturn($layout);
$this->observer->replaceLayout();
$this->assertSame($layout, Mage::registry('_singleton/core/layout'));
$this->assertSame($layout, Mage::app()->getLayout());
EcomDev_Utils_Reflection::setRestrictedPropertyValue(Mage::app(), '_layout', $originalValue);
}
示例12: testGetAttributeCollection
/**
* Test _getAttributeCollection method with the following assumptions
* Expectation 1: the class property EbayEnterprise_Catalog_Helper_Attribute::_attributeCollection
* will be set to a known value of null, so that when this test invoked the method
* EbayEnterprise_Catalog_Helper_Attribute::_getAttributeCollection the mocked
* methods Mage_Eav_Model_Resource_Entity_Attribute_Collection::addFieldToFilter and
* addExpressionFieldToSelect will be invoked with the specific arguments specified in this test.
*/
public function testGetAttributeCollection()
{
$entityTypeId = 4;
$collectionMock = $this->getResourceModelMockBuilder('eav/entity_attribute_collection')->disableOriginalConstructor()->setMethods(array('addFieldToFilter', 'addExpressionFieldToSelect'))->getMock();
$collectionMock->expects($this->once())->method('addFieldToFilter')->with($this->identicalTo('entity_type_id'), $this->identicalTo($entityTypeId))->will($this->returnSelf());
$collectionMock->expects($this->once())->method('addExpressionFieldToSelect')->with($this->identicalTo('lcase_attr_code'), $this->identicalTo('LCASE({{attrcode}})'), $this->identicalTo(array('attrcode' => 'attribute_code')))->will($this->returnSelf());
$this->replaceByMock('resource_model', 'eav/entity_attribute_collection', $collectionMock);
$attributeHelperMock = $this->getHelperMockBuilder('ebayenterprise_catalog/map_attribute')->disableOriginalConstructor()->setMethods(array('_getEntityTypeId'))->getMock();
$attributeHelperMock->expects($this->once())->method('_getEntityTypeId')->will($this->returnValue($entityTypeId));
EcomDev_Utils_Reflection::setRestrictedPropertyValue($attributeHelperMock, '_attributeCollection', null);
$this->assertSame($collectionMock, EcomDev_Utils_Reflection::invokeRestrictedMethod($attributeHelperMock, '_getAttributeCollection', array()));
}
示例13: testGetStartpageUri
/**
* Scenario: Get CSR Administrative user startup page URL
* When getting CSR Administrative user startup page URL
* Then get the user's configured startup URL path
* And get the full URL using the startup URL path
*/
public function testGetStartpageUri()
{
$adminUrl = 'admin/some/where';
$expectedUrl = "https://example-test.com/index.php/{$adminUrl}";
$url = $this->getModelMockBuilder('adminhtml/url')->disableOriginalConstructor()->setMethods(['getUrl'])->getMock();
$url->expects($this->once())->method('getUrl')->with($this->identicalTo($adminUrl))->will($this->returnValue($expectedUrl));
$user = $this->getModelMockBuilder('admin/user')->disableOriginalConstructor()->setMethods(['getStartupPageUrl'])->getMock();
$user->expects($this->once())->method('getStartupPageUrl')->will($this->returnValue($adminUrl));
$session = $this->getModelMockBuilder('admin/session')->disableOriginalConstructor()->setMethods(['getUser'])->getMock();
$session->expects($this->once())->method('getUser')->will($this->returnValue($user));
EcomDev_Utils_Reflection::setRestrictedPropertyValue($session, 'url', $url);
$this->assertSame($expectedUrl, EcomDev_Utils_Reflection::invokeRestrictedMethod($session, '_getStartpageUri'));
}
示例14: testValidateFeedConfig
/**
* Test validation of the feed config. Provider will give a set of feed config
* and if the config is expected to be invalid, the exception message that
* should be caught.
* @param array $feedConfig
* @param string $exceptionMessage
* @dataProvider provideFeedConfigForValidation
*/
public function testValidateFeedConfig($feedConfig, $exceptionMessage)
{
$feedModelMock = $this->getModelMockBuilder('ebayenterprise_catalog/feed_core')->disableOriginalConstructor()->setMethods(null)->getMock();
$feedModelMock->setFeedConfig($feedConfig);
// ensure the list of required config fields are set to an expected set of fields
EcomDev_Utils_Reflection::setRestrictedPropertyValue($feedModelMock, '_requiredConfigFields', array('local_directory', 'event_type'));
if ($exceptionMessage) {
$this->setExpectedException('EbayEnterprise_Catalog_Exception_Feed_File', $exceptionMessage);
EcomDev_Utils_Reflection::invokeRestrictedMethod($feedModelMock, '_validateFeedConfig');
} else {
$this->assertSame($feedModelMock, EcomDev_Utils_Reflection::invokeRestrictedMethod($feedModelMock, '_validateFeedConfig'));
}
}
示例15: testSearchProcessResponseCollectionSort
/**
* Test that the method ebayenterprise_order/search_process_response_collection::sort()
* is invoked, and call the PHP usort() function and pass it the class property
* ebayenterprise_order/search_process_response_collection::$_items as first parameter
* and an array with one element as the ebayenterprise_order/search_process_response_collection
* object and another element as the string literal for the method _sortOrdersMostRecentFirst.
* Then, the method ebayenterprise_order/search_process_response_collection::_sortOrdersMostRecentFirst()
* will be invoked and passed in the Varien_Object parameters in the class property
* ebayenterprise_order/search_process_response_collection::$_items. Finally, the method
* ebayenterprise_order/search_process_response_collection::sort() will return itself.
*/
public function testSearchProcessResponseCollectionSort()
{
/** @var Varien_Object */
$varienObjectA = new Varien_Object();
/** @var Varien_Object */
$varienObjectB = new Varien_Object();
/** @var EbayEnterprise_Order_Model_Search_Process_Response_ICollection */
$collection = $this->getModelMock('ebayenterprise_order/search_process_response_collection', ['_sortOrdersMostRecentFirst']);
$collection->expects($this->once())->method('_sortOrdersMostRecentFirst')->with($this->identicalTo($varienObjectB), $this->identicalTo($varienObjectA))->will($this->returnValue(true));
// Set the class property ebayenterprise_order/search_process_response_collection::$_items
// to an array of Varien_Object.
EcomDev_Utils_Reflection::setRestrictedPropertyValue($collection, '_items', [$varienObjectA, $varienObjectB]);
$this->assertSame($collection, $collection->sort());
}