本文整理汇总了PHP中EcomDev_Utils_Reflection::getRestrictedPropertyValue方法的典型用法代码示例。如果您正苦于以下问题:PHP EcomDev_Utils_Reflection::getRestrictedPropertyValue方法的具体用法?PHP EcomDev_Utils_Reflection::getRestrictedPropertyValue怎么用?PHP EcomDev_Utils_Reflection::getRestrictedPropertyValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类EcomDev_Utils_Reflection
的用法示例。
在下文中一共展示了EcomDev_Utils_Reflection::getRestrictedPropertyValue方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setUp
/**
* setUp method
*/
public function setUp()
{
parent::setUp();
$this->_origApp = EcomDev_Utils_Reflection::getRestrictedPropertyValue('Mage', '_app');
$this->_payload = $this->getMock('eBayEnterprise\\RetailOrderManagement\\Payload\\OrderEvents\\ITestMessage');
$this->_configMap = $this->getModelMock('ebayenterprise_amqp/config');
}
示例2: getMockInstance
/**
* Proxied mock instance retrieval
*
* @return PHPUnit_Framework_MockObject_MockObject
*/
public function getMockInstance()
{
if ($this->mockInstance === null) {
$reflection = ReflectionUtil::getReflection(ReflectionUtil::getRestrictedPropertyValue($this, 'type'));
$this->mockInstance = $reflection->isAbstract() || $reflection->isInterface() ? $this->getMockForAbstractClass() : $this->getMock();
}
return $this->mockInstance;
}
示例3: setUp
/**
* Store the Mage::app before tests have run.
*/
public function setUp()
{
parent::setUp();
$this->_origApp = EcomDev_Utils_Reflection::getRestrictedPropertyValue('Mage', '_app');
// suppressing the real session from starting
$session = $this->getModelMockBuilder('core/session')->disableOriginalConstructor()->setMethods(null)->getMock();
$this->replaceByMock('singleton', 'core/session', $session);
}
示例4: setUp
protected function setUp()
{
$this->payloadHelper = Mage::helper('ebayenterprise_inventory/quantity_payload');
$this->inventoryHelper = $this->getHelperMock('ebayenterprise_inventory', ['getRomSku']);
$this->inventoryHelper->method('getRomSku')->will($this->returnArgument(0));
// Swap out the inventory helper instance referenced by the payload helper
// with the mock for consistent behavior during tests.
$this->origInventoryHelper = EcomDev_Utils_Reflection::getRestrictedPropertyValue($this->payloadHelper, 'inventoryHelper');
EcomDev_Utils_Reflection::setRestrictedPropertyValue($this->payloadHelper, 'inventoryHelper', $this->inventoryHelper);
}
示例5: setUp
public function setUp()
{
$this->helper = Mage::helper('ebayenterprise_tax');
// Mock log context to prevent session interactions while getting log meta data.
$logContext = $this->getHelperMock('ebayenterprise_magelog/context', ['getMetaData']);
$logContext->method('getMetaData')->will($this->returnValue([]));
// Swap out the log context used by the tax helper being tested, grabbing
// a reference to the original value so it can be restored later.
$this->origLogContext = EcomDev_Utils_Reflection::getRestrictedPropertyValue($this->helper, 'logContext');
EcomDev_Utils_Reflection::setRestrictedPropertyValue($this->helper, 'logContext', $logContext);
}
示例6: testGetConfigMapValue
/**
* Test _getConfigMapValue method for the following expectations
* Expectation 1: this test will invoked the method EbayEnterprise_Catalog_Model_Feed_Ack::_getConfigMapValue
* giving it a key for EbayEnterprise_Catalog_Model_Feed_Ack::_configMap array
* if this array is empty it will build it using the config registry and known class constant
* and then check if the given key exist in the configMap and return the value map to it
*/
public function testGetConfigMapValue()
{
$cfgKey = EbayEnterprise_Catalog_Model_Feed_Ack::CFG_EXPORT_ARCHIVE;
$configMap = array('feedExportArchive' => 'path/to/export/archive', 'feedImportArchive' => 'path/to/import/archive', 'feedOutboxDirectory' => 'path/to/outbox/directory', 'feedAckInbox' => 'path/to/ack/inbox', 'feedSentDirectory' => 'path/to/send/directory', 'ackResendTimeLimit' => 5, 'feedAckErrorDirectory' => 'path/to/ack/error/directory');
$map = array(EbayEnterprise_Catalog_Model_Feed_Ack::CFG_EXPORT_ARCHIVE => $configMap['feedExportArchive'], EbayEnterprise_Catalog_Model_Feed_Ack::CFG_IMPORT_ARCHIVE => $configMap['feedImportArchive'], EbayEnterprise_Catalog_Model_Feed_Ack::CFG_EXPORT_OUTBOX => $configMap['feedOutboxDirectory'], EbayEnterprise_Catalog_Model_Feed_Ack::CFG_IMPORTED_ACK_DIR => $configMap['feedAckInbox'], EbayEnterprise_Catalog_Model_Feed_Ack::CFG_EXPORTED_FEED_DIR => $configMap['feedSentDirectory'], EbayEnterprise_Catalog_Model_Feed_Ack::CFG_WAIT_TIME_LIMIT => $configMap['ackResendTimeLimit'], EbayEnterprise_Catalog_Model_Feed_Ack::CFG_ERROR_DIRECTORY => $configMap['feedAckErrorDirectory']);
$this->replaceCoreConfigRegistry($configMap);
$ackMock = Mage::getModel('ebayenterprise_catalog/feed_ack');
EcomDev_Utils_Reflection::setRestrictedPropertyValue($ackMock, '_configMap', []);
$this->assertSame($map[$cfgKey], EcomDev_Utils_Reflection::invokeRestrictedMethod($ackMock, '_getConfigMapValue', array($cfgKey)));
$this->assertSame($map, EcomDev_Utils_Reflection::getRestrictedPropertyValue($ackMock, '_configMap'));
}
示例7: testConstructor
/**
* Constructor should load and store the PIM feed mappings from the config
*/
public function testConstructor()
{
// mock mapping from the config.xml
$mappingConfig = array('sku' => array('xml_dest' => 'Some/Xpath'));
$defaultPimConfig = array('xml_dest' => 'ConfigurableAttributes/Attribute[@name="%s"]');
$configRegistryMock = $this->getModelMock('eb2ccore/config_registry', array('getConfigData'));
$configRegistryMock->expects($this->exactly(2))->method('getConfigData')->will($this->returnValueMap(array(array('ebayenterprise_catalog/feed_pim_mapping', $mappingConfig), array('ebayenterprise_catalog/default_pim_mapping', $defaultPimConfig))));
$this->replaceByMock('model', 'eb2ccore/config_registry', $configRegistryMock);
$factory = Mage::getModel('ebayenterprise_catalog/pim_attribute_factory');
$this->assertSame($mappingConfig, EcomDev_Utils_Reflection::getRestrictedPropertyValue($factory, '_attributeMappings'));
$this->assertSame($defaultPimConfig, EcomDev_Utils_Reflection::getRestrictedPropertyValue($factory, '_defaultMapping'));
}
示例8: testConstruction
/**
* Test constructing instances - should be invoked with an array of
* "feed details". The array of data the model is instantiated with
* must contain keys for 'error_file' and 'doc'. When instantiated with a
* proper set of file details, the array should be stored on the _feedDetails
* property. When given an invalid set of file details, an error should be triggered.
* @param array $fileDetails Argument to the constructor
* @param string $errorMessage Expected error message, if empty, no error is expected
* @dataProvider provideConstructorDetailsAndErrors
*/
public function testConstruction($fileDetails, $errorMessage)
{
if ($errorMessage) {
// Errors should be getting converted to PHPUnit_Framework_Error but
// they aren't...instead just getting plain ol' Exceptions...so at least the
// messages are rather explicit so hopefully no miscaught exceptions by this test.
$this->setExpectedException('Exception', $errorMessage);
}
$feedFile = Mage::getModel('ebayenterprise_catalog/feed_file', $fileDetails);
if (!$errorMessage) {
$this->assertSame($fileDetails, EcomDev_Utils_Reflection::getRestrictedPropertyValue($feedFile, '_feedDetails'));
}
}
示例9: testConstructor
/**
* Test the _construct method. When valid, should result in a model with
* a _coreFeed property. When invalid, should throw an exception.
* @param array $initialData
* @param bool $isValid
* @dataProvider provideConstructorInitialData
*/
public function testConstructor($initialData, $isValid)
{
$coreFeed = $this->getModelMockBuilder('ebayenterprise_catalog/feed_core')->disableOriginalConstructor()->getMock();
$this->replaceByMock('model', 'ebayenterprise_catalog/feed_core', $coreFeed);
$feed = $this->getModelMockBuilder('ebayenterprise_catalog/feed_abstract')->disableOriginalConstructor()->setMethods(array('processDom'))->getMock();
$feed->setData($initialData);
if (!$isValid) {
$this->setExpectedException('EbayEnterprise_Eb2cCore_Exception_Feed_Configuration');
}
EcomDev_Utils_Reflection::invokeRestrictedMethod($feed, '_construct');
if ($isValid) {
$this->assertSame($coreFeed, EcomDev_Utils_Reflection::getRestrictedPropertyValue($feed, '_coreFeed'));
}
}
示例10: endTestSuite
/**
* A test suite ended.
*
* @param PHPUnit_Framework_TestSuite $suite
*/
public function endTestSuite(PHPUnit_Framework_TestSuite $suite)
{
if (EcomDev_Utils_Reflection::getRestrictedPropertyValue($suite, 'testCase')) {
Mage::dispatchEvent('phpunit_test_case_end_before', array('suite' => $suite, 'listener' => $this));
EcomDev_PHPUnit_Test_Case_Util::getFixture($suite->getName())->setScope(EcomDev_PHPUnit_Model_FixtureInterface::SCOPE_SHARED)->discard();
Mage::dispatchEvent('phpunit_test_case_end_after', array('suite' => $suite, 'listener' => $this));
}
if ($this->firstLevelTestSuite === $suite) {
Mage::dispatchEvent('phpunit_suite_end_before', array('suite' => $suite, 'listener' => $this));
$this->firstLevelTestSuite = null;
// Discard test scope app
if ($this->getAppReflection()->hasMethod('discardTestScope')) {
$this->getAppReflection()->getMethod('discardTestScope')->invoke(null);
}
Mage::dispatchEvent('phpunit_suite_end_after', array('suite' => $suite, 'listener' => $this));
}
}
示例11: __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 = EcomDev_Utils_Reflection::getRestrictedPropertyValue($test, 'groups');
foreach ($groups as $group) {
if (!isset($testGroups[$group])) {
$testGroups[$group] = $test->tests();
} else {
foreach ($test->tests() as $subTest) {
if (!in_array($subTest, $testGroups[$group], true)) {
$testGroups[$group][] = $subTest;
}
}
}
}
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]);
}
}
示例12: testConstruct
/**
* The protected construct method should set up an array of core feed models,
* each loaded with the config data for one of the feed types handled by this
* model. Using those core feed models, it should then also create an array
* of event types used when sorting the feed files.
*/
public function testConstruct()
{
$eventType = 'SomeEvent';
$configKeys = array('itemFeed');
$config = $this->buildCoreConfigRegistry(array('itemFeed' => array('event_type' => $eventType, 'local_directory' => 'local')));
$prodHelper = $this->getHelperMock('ebayenterprise_catalog/data', array('getConfigModel'));
$this->replaceByMock('helper', 'ebayenterprise_catalog', $prodHelper);
$prodFeed = $this->getModelMockBuilder('ebayenterprise_catalog/feed')->disableOriginalConstructor()->getMock();
// setup the feed config keys used by the product feed model so only some
// expected subset of the feed types are worked with
EcomDev_Utils_Reflection::setRestrictedPropertyValue($prodFeed, '_feedConfigKeys', $configKeys);
$prodHelper->expects($this->once())->method('getConfigModel')->will($this->returnValue($config));
$coreFeed = $this->getModelMockBuilder('ebayenterprise_catalog/feed_core')->disableOriginalConstructor()->setMethods(array('getEventType'))->getMock();
$this->replaceByMock('model', 'ebayenterprise_catalog/feed_core', $coreFeed);
$coreFeed->expects($this->once())->method('getEventType')->will($this->returnValue($eventType));
EcomDev_Utils_Reflection::invokeRestrictedMethod($prodFeed, '_construct');
$this->assertSame(array($eventType), EcomDev_Utils_Reflection::getRestrictedPropertyValue($prodFeed, '_eventTypes'));
$this->assertSame(array($coreFeed), EcomDev_Utils_Reflection::getRestrictedPropertyValue($prodFeed, '_coreFeedTypes'));
}
示例13: setUp
public function setUp()
{
parent::setUp();
// keep a backup copy of all websites
$this->_oldWebsites = EcomDev_Utils_Reflection::getRestrictedPropertyValue(Mage::app(), '_websites');
// mock up a store for the default website
$this->_defaultStore = $this->getModelMockBuilder('core/store')->disableOriginalConstructor()->setMethods(array('getId'))->getMock();
$this->_defaultStore->expects($this->any())->method('getId')->will($this->returnValue(0));
$this->_defaultStores = array(0 => $this->_defaultStore);
// mock up a store for the non default website
$this->_store1 = $this->getModelMockBuilder('core/store')->disableOriginalConstructor()->setMethods(array('getId'))->getMock();
$this->_store1->expects($this->any())->method('getId')->will($this->returnValue(1));
$this->_store2 = $this->getModelMockBuilder('core/store')->disableOriginalConstructor()->setMethods(array('getId'))->getMock();
$this->_store2->expects($this->any())->method('getId')->will($this->returnValue(2));
$this->_web1Stores = array(1 => $this->_store1, 2 => $this->_store2);
// mock replacement websites with the store to use as the default.
$this->_website1 = $this->_stubWebsite(1, 'web1', $this->_store1);
$this->_defaultWebsite = $this->_stubWebsite(0, 'admin', $this->_defaultStore);
$this->_defaultWebsite->addData(Mage::app()->getWebsite(0)->getData());
$this->_batchContainer = $this->getModelMock('ebayenterprise_catalog/pim_batch_container', array('addBatch'));
$cutoffDate = 'a date string';
$this->_eventObserver = $this->_buildEventObserver(array('cutoff_date' => $cutoffDate, 'container' => $this->_batchContainer, 'feed_type_config' => $this->_feedConfig));
$this->_collectionDefault = $this->getResourceModelMock('catalog/product_collection', array('load', 'addWebsiteFilter', 'getColumnValues', 'addFieldToFilter'));
$this->_collectionWeb1 = $this->getResourceModelMock('catalog/product_collection', array('load', 'addWebsiteFilter', 'getColumnValues', 'addFieldToFilter'));
// setup which website filters will return which set of product ids.
$this->_websiteFilterValueMap = array(array(array(0), $this->_collectionDefault), array(array(1), $this->_collectionWeb1));
// stub the language helper to return stores for each website
$this->_getWebsiteStoresValueMap = array(array($this->_defaultWebsite, null, $this->_defaultStores), array($this->_website1, null, $this->_web1Stores));
$this->_languageHelper = $this->getHelperMock('eb2ccore/languages', array('getWebsiteStores'));
$this->_languageHelper->expects($this->any())->method('getWebsiteStores')->will($this->returnValueMap($this->_getWebsiteStoresValueMap));
$cutoffFilter = array('gteq' => $cutoffDate);
foreach (array($this->_collectionDefault, $this->_collectionWeb1) as $collectionMock) {
$collectionMock->expects($this->any())->method('addWebsiteFilter')->will($this->returnValueMap($this->_websiteFilterValueMap));
$collectionMock->expects($this->any())->method('load')->will($this->returnSelf());
$collectionMock->expects($this->any())->method('addFieldToFilter')->with($this->identicalTo('updated_at'), $this->identicalTo($cutoffFilter))->will($this->returnSelf());
}
}
示例14: testOrderCancelSendRequest
/**
* Test that the method ebayenterprise_order/cancel::_sendRequest()
* is invoked, and it will instantiate the class ebayenterprise_order/cancel_send_request
* passing to its constructor method an array with key 'request' mapped to a
* IOrderCancelRequest payload object. Then, it will invoke the method
* ebayenterprise_order/cancel_send_request::send(), which will return an instance
* of type IOrderCancelResponse. This instance of type IOrderCancelResponse will be
* assigned to the class property ebayenterprise_order/cancel::$_response.
* Finally, the method ebayenterprise_order/cancel::_sendRequest() will return itself.
*/
public function testOrderCancelSendRequest()
{
/** @var Mage_Sales_Model_Order */
$order = Mage::getModel('sales/order');
/** @var Mock_IOrderCancelRequest */
$request = $this->getMockBuilder(EbayEnterprise_Order_Model_Cancel_Build_IRequest::PAYLOAD_CLASS)->disableOriginalConstructor()->getMock();
/** @var Mock_IOrderCancelResponse */
$response = $this->getMockBuilder(static::RESPONSE_CLASS)->disableOriginalConstructor()->getMock();
/** @var EbayEnterprise_Order_Model_Cancel_Send_Request */
$cancelSendRequest = $this->getModelMock('ebayenterprise_order/cancel_send_request', ['send'], false, [['api' => $this->_api, 'request' => $request]]);
$cancelSendRequest->expects($this->once())->method('send')->will($this->returnValue($response));
/** @var EbayEnterprise_Order_Helper_Factory */
$factory = $this->getHelperMock('ebayenterprise_order/factory', ['getNewCancelSendRequest']);
$factory->expects($this->once())->method('getNewCancelSendRequest')->with($this->identicalTo($this->_api), $this->identicalTo($request))->will($this->returnValue($cancelSendRequest));
/** @var Mock_EbayEnterprise_Order_Model_Cancel */
$cancel = $this->getModelMock('ebayenterprise_order/cancel', ['foo'], false, [['order' => $order, 'factory' => $factory, 'core_helper' => $this->_coreHelper, 'order_cfg' => $this->_orderCfg]]);
// Set the class property ebayenterprise_order/cancel::$_api to a known state
EcomDev_Utils_Reflection::setRestrictedPropertyValue($cancel, '_api', $this->_api);
// Set the class property ebayenterprise_order/cancel::$_request to mock of IOrderCancelRequest.
EcomDev_Utils_Reflection::setRestrictedPropertyValue($cancel, '_request', $request);
// Proving that initial state of the class property ebayenterprise_order/cancel::$_response is null.
$this->assertNull(EcomDev_Utils_Reflection::getRestrictedPropertyValue($cancel, '_response'));
$this->assertSame($cancel, EcomDev_Utils_Reflection::invokeRestrictedMethod($cancel, '_sendRequest', []));
// Proving that after invoking the method ebayenterprise_order/cancel::_sendRequest()
// the class property ebayenterprise_order/cancel::$_response is now
// an instance of IOrderCancelResponse.
$this->assertSame($response, EcomDev_Utils_Reflection::getRestrictedPropertyValue($cancel, '_response'));
}
示例15: testGetCustomAttributeCodeSet
/**
* Test getCustomAttributeCodeSet the feed
*/
public function testGetCustomAttributeCodeSet()
{
$apiModelMock = $this->getModelMockBuilder('catalog/product_attribute_api')->disableOriginalConstructor()->setMethods(array('items'))->getMock();
$apiModelMock->expects($this->once())->method('items')->with($this->equalTo(172))->will($this->returnValue(array(array('code' => 'brand_name'), array('code' => 'brand_description'), array('code' => 'is_drop_shipped'), array('code' => 'drop_ship_supplier_name'))));
$this->replaceByMock('model', 'catalog/product_attribute_api', $apiModelMock);
$helper = Mage::helper('ebayenterprise_catalog');
// setting _customAttributeCodeSets property back to an empty array
EcomDev_Utils_Reflection::setRestrictedPropertyValue($helper, '_customAttributeCodeSets', array());
$this->assertSame(array('brand_name', 'brand_description', 'is_drop_shipped', 'drop_ship_supplier_name'), Mage::helper('ebayenterprise_catalog')->getCustomAttributeCodeSet(172));
$this->assertSame(array(172 => array('brand_name', 'brand_description', 'is_drop_shipped', 'drop_ship_supplier_name')), EcomDev_Utils_Reflection::getRestrictedPropertyValue($helper, '_customAttributeCodeSets'));
// resetting _customAttributeCodeSets property back to an empty array
EcomDev_Utils_Reflection::setRestrictedPropertyValue($helper, '_customAttributeCodeSets', array());
}