本文整理汇总了PHP中EcomDev_Utils_Reflection类的典型用法代码示例。如果您正苦于以下问题:PHP EcomDev_Utils_Reflection类的具体用法?PHP EcomDev_Utils_Reflection怎么用?PHP EcomDev_Utils_Reflection使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了EcomDev_Utils_Reflection类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _handleScopeRow
/**
* Handle scope row data
*
* @param string $type
* @param array $row
* @param EcomDev_PHPUnit_Model_FixtureInterface $fixture
* @return boolean|Mage_Core_Model_Abstract
*/
protected function _handleScopeRow($type, $row, EcomDev_PHPUnit_Model_FixtureInterface $fixture)
{
$previousScope = array();
if ($fixture->isScopeLocal() && $fixture->getStorageData(self::STORAGE_KEY, EcomDev_PHPUnit_Model_FixtureInterface::SCOPE_SHARED) !== null) {
$previousScope = $fixture->getStorageData(self::STORAGE_KEY, EcomDev_PHPUnit_Model_FixtureInterface::SCOPE_SHARED);
}
if (isset($previousScope[$type][$row[$type . '_id']])) {
return false;
}
$scopeModel = Mage::getModel($this->modelByType[$type]);
$scopeModel->setData($row);
// Change property for saving new objects with specified ids
EcomDev_Utils_Reflection::setRestrictedPropertyValues($scopeModel->getResource(), array('_isPkAutoIncrement' => false));
try {
$scopeModel->isObjectNew(true);
$scopeModel->save();
} catch (Exception $e) {
Mage::logException($e);
// Skip duplicated key violation, since it might be a problem
// of previous run with fatal error
// Revert changed property
EcomDev_Utils_Reflection::setRestrictedPropertyValues($scopeModel->getResource(), array('_isPkAutoIncrement' => true));
// Load to make possible deletion
$scopeModel->load($row[$type . '_id']);
}
// Revert changed property
EcomDev_Utils_Reflection::setRestrictedPropertyValues($scopeModel->getResource(), array('_isPkAutoIncrement' => true));
return $scopeModel;
}
示例2: 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);
}
示例3: testSdkExceptionHandling
/**
* GIVEN An <sdkApi> that will thrown an <exception> of <exceptionType> when making a request.
* WHEN A request is made.
* THEN The <exception> will be caught.
* AND An exception of <expectedExceptionType> will be thrown.
*
* @param string
* @param string
* @dataProvider provideSdkExceptions
*/
public function testSdkExceptionHandling($exceptionType, $expectedExceptionType)
{
$exception = new $exceptionType(__METHOD__ . ': Test Exception');
$this->api->method('send')->will($this->throwException($exception));
$this->setExpectedException($expectedExceptionType);
EcomDev_Utils_Reflection::invokeRestrictedMethod($this->allocator, 'makeRequest', [$this->api]);
}
示例4: testGetCookiesString
/**
* verify the cookie array is converted to a string
* @dataProvider provideCookieArray
*/
public function testGetCookiesString(array $arr, $expected)
{
$helper = Mage::helper('eb2cfraud/http');
EcomDev_Utils_Reflection::setRestrictedPropertyValues($helper, ['_request' => $this->_requestStub, '_cookie' => $this->_cookieStub]);
$this->_cookieStub->expects($this->any())->method('get')->will($this->returnValue($arr));
$this->assertSame($expected, $helper->getCookiesString());
}
示例5: 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());
}
示例6: testLogResultCodeWithError
/**
* will log a warning when the result code is
* for an error or is unknown
* @dataProvider provideFailureResultCodes
*/
public function testLogResultCodeWithError($code)
{
$response = $this->getModelMockBuilder('ebayenterprise_address/validation_response')->setConstructorArgs([['api' => $this->getMock('\\eBayEnterprise\\RetailOrderManagement\\Api\\IBidirectionalApi'), 'logger' => $this->logger, 'context' => $this->context]])->setMethods(['extractResponseData'])->getMock();
$response->setResultCode($code);
$this->logger->expects($this->once())->method('warning');
EcomDev_Utils_Reflection::invokeRestrictedMethod($response, 'logResultCode');
}
示例7: testGetVersionScriptsDiff
/**
* Test version
*
* @param string[]|string $directories
* @param string $type
* @param string $from
* @param string $to
*
* @return void
* @dataProvider dataProvider
*/
public function testGetVersionScriptsDiff($directories, $type, $from, $to)
{
$virtualPath = $this->getVirtualPath($directories);
$versions = EcomDev_Utils_Reflection::invokeRestrictedMethod($this->constraint, 'parseVersions', array($virtualPath));
$result = EcomDev_Utils_Reflection::invokeRestrictedMethod($this->constraint, 'getVersionScriptsDiff', array($versions[$type], $from, $to, $type === 'data' ? 'data-' : ''));
$this->assertEquals($this->expected('auto')->getDiff(), $result);
}
示例8: 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);
}
示例9: __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]);
}
}
示例10: testReturnsCorrectImageProcessorClass
public function testReturnsCorrectImageProcessorClass()
{
/** @var $image Varien_Image */
$image = $this->_model->getImageProcessor();
$adapterClass = EcomDev_Utils_Reflection::invokeRestrictedMethod($image, '_getAdapter');
$this->assertInstanceOf('Varien_Image_Adapter_Abstract', $adapterClass);
}
示例11: testGetItemColorAndSizeInfo
/**
* verify
* - the localized and default values are returned
* - if the option does not exist, null is returned
* for both default and localized values
*
* @param string $method
* @param string $localizedValue
* @param string $defaultValue
* @dataProvider provideForSizeColorInfo
*/
public function testGetItemColorAndSizeInfo($method, $localizedValue, $defaultValue)
{
$this->replaceByMock('resource_model', 'eav/entity_attribute_option_collection', $this->optionValueCollectionStub);
$this->optionValueCollectionStub->addItem(Mage::getModel('eav/entity_attribute_option', ['attribute_code' => 'color', 'option_id' => 15, 'value' => 'Black', 'default_value' => '2']));
$handler = Mage::getModel('ebayenterprise_order/create_orderitem');
$this->assertSame([$localizedValue, $defaultValue], EcomDev_Utils_Reflection::invokeRestrictedMethod($handler, $method, [$this->itemStub]));
}
示例12: testFeedFields
/**
* Test getting the fields to include in the feed. Should be pulling the
* comma-separated list of fields from config.xml and splitting it to produce
* an array of fields.
* @return array
*/
public function testFeedFields()
{
$config = $this->getHelperMock('eems_affiliate/config', array('getItemizedOrderFeedFields'));
$config->expects($this->any())->method('getItemizedOrderFeedFields')->will($this->returnValue('one,two,three'));
$this->replaceByMock('helper', 'eems_affiliate/config', $config);
$feed = Mage::getModel('eems_affiliate/feed_order_itemized');
$this->assertSame(array('one', 'two', 'three'), EcomDev_Utils_Reflection::invokeRestrictedMethod($feed, '_getFeedFields'));
}
示例13: 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);
}
示例14: testGetGiftCardType
/**
* Test _getGiftCardType method for the following expectations
* Expectation 1: when this test invoked the method EbayEnterprise_Catalog_Helper_Map_Giftcard::_getGiftCardType
* with string of each giftcard constant type it will return the gift card constant value
*/
public function testGetGiftCardType()
{
$testData = array(array('expect' => Enterprise_GiftCard_Model_Giftcard::TYPE_VIRTUAL, 'type' => EbayEnterprise_Catalog_Helper_Map_Giftcard::GIFTCARD_VIRTUAL), array('expect' => Enterprise_GiftCard_Model_Giftcard::TYPE_PHYSICAL, 'type' => EbayEnterprise_Catalog_Helper_Map_Giftcard::GIFTCARD_PHYSICAL), array('expect' => Enterprise_GiftCard_Model_Giftcard::TYPE_COMBINED, 'type' => EbayEnterprise_Catalog_Helper_Map_Giftcard::GIFTCARD_COMBINED));
$giftcard = Mage::helper('ebayenterprise_catalog/map_giftcard');
foreach ($testData as $data) {
$this->assertSame($data['expect'], EcomDev_Utils_Reflection::invokeRestrictedMethod($giftcard, '_getGiftCardType', array($data['type'])));
}
}
示例15: testBeforeSave
/**
* Before an item is saved, if the item has an associated order address
* with a valid id, the id of the order address should be set on the item.
*/
public function testBeforeSave()
{
$addressId = 8;
$address = Mage::getModel('sales/order_address', ['entity_id' => $addressId]);
$this->_item->setOrderAddress($address);
EcomDev_Utils_Reflection::invokeRestrictedMethod($this->_item, '_beforeSave');
$this->assertSame($addressId, $this->_item->getOrderAddressId());
}