Example #1
0
 /**
  * Constructor
  *
  * @param string $class
  * @param string $name
  */
 public function __construct($class, $name)
 {
     $this->class = $class;
     $this->name = $name;
     $this->reflection = new \ReflectionProperty($class, $name);
     $this->reflection->setAccessible(true);
 }
Example #2
0
 /**
  * setup mocks for all functions
  */
 public function setUp()
 {
     $this->_objectHelper = new \Magento\TestFramework\Helper\ObjectManager($this);
     $this->_orderMock = $this->getMockBuilder('\\Magento\\Sales\\Model\\Order')->disableOriginalConstructor()->setMethods(array('__wakeup', 'getRealOrderId'))->getMock();
     $this->_messageMock = $this->getMockBuilder('\\Magento\\Framework\\Message')->disableOriginalConstructor()->setMethods(array('addError'))->getMock();
     $titleMock = $this->getMock('\\Magento\\Framework\\App\\Action\\Title', array('__wakeup', 'add'), array(), '', false);
     $viewMock = $this->getMockForAbstractClass('\\Magento\\Framework\\App\\ViewInterface');
     /**
      * @TODO:
      *  - Methods of object under test MUST NOT be mocked
      *  - Protected properties MUST NOT be set from outside, inject via context passed to constructor instead
      */
     $this->_controllerMock = $this->getMockBuilder('\\Magento\\Sales\\Controller\\Adminhtml\\Order\\View')->disableOriginalConstructor()->setMethods(array('__wakeup', '_initOrder', '_initAction', '__', 'renderLayout', '_redirect'))->getMock();
     $this->_controllerMock->expects($this->any())->method('__')->will($this->returnArgument(0));
     $reflectionProperty = new \ReflectionProperty('\\Magento\\Sales\\Controller\\Adminhtml\\Order', '_title');
     $reflectionProperty->setAccessible(true);
     $reflectionProperty->setValue($this->_controllerMock, $titleMock);
     $reflectionProperty->setAccessible(false);
     $reflectionProperty = new \ReflectionProperty('\\Magento\\Sales\\Controller\\Adminhtml\\Order', '_view');
     $reflectionProperty->setAccessible(true);
     $reflectionProperty->setValue($this->_controllerMock, $viewMock);
     $reflectionProperty->setAccessible(false);
     $reflectionProperty = new \ReflectionProperty('\\Magento\\Sales\\Controller\\Adminhtml\\Order', 'messageManager');
     $reflectionProperty->setAccessible(true);
     $reflectionProperty->setValue($this->_controllerMock, $this->_messageMock);
     $reflectionProperty->setAccessible(false);
 }
 /**
  * @param callable $callback
  */
 public function __construct(callable $callback)
 {
     $this->objects = new ArrayObject();
     $this->callback = $callback;
     $this->dataObjectRecordProperty = new ReflectionProperty('DataObject', 'record');
     $this->dataObjectRecordProperty->setAccessible(true);
 }
 /**
  * Force connection setter injection on setup model using reflection
  * 
  * @param $setup
  * @param $connection
  */
 protected function _setConnectionOnInstaller($setup, $connection)
 {
     $prop = new ReflectionProperty($setup, '_conn');
     $prop->setAccessible(true);
     $prop->setValue($setup, $connection);
     $prop->setAccessible(false);
 }
 /**
  * @param int $batchSize
  */
 public function __construct($batchSize = 100)
 {
     $this->batch = new Batch();
     $this->batchSize = $batchSize;
     $this->dataObjectRecordProperty = new ReflectionProperty('DataObject', 'record');
     $this->dataObjectRecordProperty->setAccessible(true);
 }
 /**
  *
  */
 public function __construct()
 {
     $this->connProperty = new ReflectionProperty('MySQLDatabase', 'dbConn');
     $this->connProperty->setAccessible(true);
     $this->dataObjectRecordProperty = new ReflectionProperty('DataObject', 'record');
     $this->dataObjectRecordProperty->setAccessible(true);
 }
Example #7
0
 protected function resetProperty($name, $value = null)
 {
     $prop = new ReflectionProperty('Valitron\\Validator', $name);
     $prop->setAccessible(true);
     $prop->setValue($value);
     $prop->setAccessible(false);
 }
Example #8
0
 private function enableOpenSSL()
 {
     $ref = new \ReflectionProperty('Bitpay\\Util\\SecureRandom', 'hasOpenSSL');
     $ref->setAccessible(true);
     $ref->setValue(null);
     $ref->setAccessible(false);
 }
 /**
  * @param string|object $classOrObject
  * @param string        $attributeName
  * @param mixed         $attributeValue
  */
 public function writeAttribute($classOrObject, $attributeName, $attributeValue)
 {
     $rp = new \ReflectionProperty($classOrObject, $attributeName);
     $rp->setAccessible(true);
     $rp->setValue($classOrObject, $attributeValue);
     $rp->setAccessible(false);
 }
 protected function createRecurringOrder()
 {
     $order = new Order();
     $customer = new Partner();
     $order->setOwner($customer);
     $product1 = new Product();
     $product1->setName('product1');
     $context = new PricingContext();
     $recurringElement = new RecurringElement();
     $recurringElement->setCycles(-1);
     $recurringElement->setInterval('1 month');
     $recurringElement->setRecurringCharge('30');
     $pricingSet = new PricingSet(new TotalValueElement());
     $pricingSet->addPricingElement($recurringElement);
     $pricingSet->setProcessingState(PricingSet::PROCESSING_FINISHED);
     $pricingSet1 = $pricingSet->process($context);
     $orderItem1 = new Item($product1);
     $rp = new \ReflectionProperty($orderItem1, 'pricingSet');
     $rp->setAccessible(true);
     $rp->setValue($orderItem1, $pricingSet1);
     $rp->setAccessible(false);
     $rm = new \ReflectionMethod($order, 'addItem');
     $rm->setAccessible(true);
     $rm->invokeArgs($order, array($orderItem1));
     $rm->setAccessible(false);
     return $order;
 }
Example #11
0
 protected function setUp()
 {
     $this->cacheDataReflection = new \ReflectionProperty("Doctrine\\Common\\Cache\\ArrayCache", "data");
     $this->cacheDataReflection->setAccessible(true);
     $this->useModelSet('cms');
     parent::setUp();
 }
 private function checkAccess()
 {
     if (!$this->isAccessible) {
         $this->reflectionProperty->setAccessible(true);
     }
     $this->isAccessible = true;
 }
 public function tearDown()
 {
     $property = new \ReflectionProperty('\\Magento\\Setup\\Module\\I18n\\ServiceLocator', '_dictionaryGenerator');
     $property->setAccessible(true);
     $property->setValue(null);
     $property->setAccessible(false);
 }
Example #14
0
 private static function setConnAccessible()
 {
     if (!self::$connRefl) {
         self::$connRefl = new \ReflectionProperty('\\React\\Http\\Response', 'conn');
         self::$connRefl->setAccessible(true);
     }
 }
 /**
  * Constructor
  * @param \PHP_CodeSniffer_File $phpcsFile
  */
 public function __construct(PHP_CodeSniffer_File $phpcsFile)
 {
     $this->phpcsFile = $phpcsFile;
     $this->reflection = new ReflectionProperty($this->phpcsFile, 'ruleset');
     $this->reflection->setAccessible(true);
     $this->current = $this->reflection->getValue($this->phpcsFile);
     $this->backup = $this->current;
 }
Example #16
0
 /**
  * @return Writer
  */
 protected function getWriter()
 {
     if (null == $this->refField) {
         $this->refField = new \ReflectionProperty(get_parent_class($this), 'writer');
         $this->refField->setAccessible(true);
     }
     return $this->refField->getValue($this);
 }
 /**
  * @return QueryBuilder
  */
 protected function getQueryBuilder()
 {
     $reflectionProperty = new \ReflectionProperty(get_parent_class($this), 'queryBuilder');
     $reflectionProperty->setAccessible(true);
     $return = $reflectionProperty->getValue($this);
     $reflectionProperty->setAccessible(false);
     return $return;
 }
 public function setup()
 {
     $class = new \ReflectionClass('BsbFlysystemTest\\Assets\\SimpleAdapterFactory');
     $this->property = $class->getProperty('options');
     $this->property->setAccessible(true);
     $this->method = $class->getMethod('mergeMvcConfig');
     $this->method->setAccessible(true);
 }
 /**
  *
  */
 protected function setMockFields()
 {
     $this->webDirectory = $this->reflectionClass->getProperty('webDirectory');
     $this->webDirectory->setAccessible(true);
     $this->webDirectory->setValue($this->command, $this->webPath);
     $this->filesystemField = $this->reflectionClass->getProperty('filesystem');
     $this->filesystemField->setAccessible(true);
 }
Example #20
0
 protected function resetKeyCache()
 {
     // reset key cache for every testrun
     $keyCache = new \ReflectionProperty('\\OCA\\Files_Encryption\\Keymanager', 'key_cache');
     $keyCache->setAccessible(true);
     $keyCache->setValue(array());
     $keyCache->setAccessible(false);
 }
 public function tearDown()
 {
     $this->fileManagerMock = null;
     $ref = new \ReflectionProperty('oat\\taoMediaManager\\model\\fileManagement\\FileManager', 'fileManager');
     $ref->setAccessible(true);
     $ref->setValue(null, null);
     $ref->setAccessible(false);
 }
Example #22
0
 /**
  * @param string $name
  * @param mixed $value
  * @return $this
  */
 protected function setParentPrivatePropertyValue($name, $value)
 {
     $reflectionProperty = new \ReflectionProperty(get_parent_class($this), $name);
     $reflectionProperty->setAccessible(true);
     $reflectionProperty->setValue($this, $value);
     $reflectionProperty->setAccessible(false);
     return $this;
 }
 public function setUp()
 {
     $this->_condition = $this->getMockForAbstractClass('\\Magento\\Rule\\Model\\Condition\\Product\\AbstractProduct', [], '', false);
     $this->_entityAttributeValuesProperty = new \ReflectionProperty('Magento\\Rule\\Model\\Condition\\Product\\AbstractProduct', '_entityAttributeValues');
     $this->_entityAttributeValuesProperty->setAccessible(true);
     $this->_configProperty = new \ReflectionProperty('Magento\\Rule\\Model\\Condition\\Product\\AbstractProduct', '_config');
     $this->_configProperty->setAccessible(true);
 }
Example #24
0
 /**
  * @return EntityManagerInterface
  */
 protected function getParentEntityManager()
 {
     $reflectionProperty = new \ReflectionProperty(get_parent_class($this), 'em');
     $reflectionProperty->setAccessible(true);
     $entityManager = $reflectionProperty->getValue($this);
     $reflectionProperty->setAccessible(false);
     return $entityManager;
 }
 public function setup()
 {
     $class = new \ReflectionClass('BsbFlysystem\\Adapter\\Factory\\DropboxAdapterFactory');
     $this->property = $class->getProperty('options');
     $this->property->setAccessible(true);
     $this->method = $class->getMethod('validateConfig');
     $this->method->setAccessible(true);
 }
Example #26
0
 public function setUp()
 {
     $reflClass = new \ReflectionClass(UniqueValueResolver::class);
     $this->resolverRefl = $reflClass->getProperty('resolver');
     $this->resolverRefl->setAccessible(true);
     $this->poolRefl = $reflClass->getProperty('pool');
     $this->poolRefl->setAccessible(true);
 }
Example #27
0
 protected function getChanges()
 {
     $rp = new \ReflectionProperty($this->query, 'changes');
     $rp->setAccessible(true);
     $changes = $rp->getValue($this->query);
     $rp->setAccessible(false);
     return $changes;
 }
Example #28
0
 protected function updateInc($target, $field, $changes)
 {
     $rp = new \ReflectionProperty($target, $field);
     $rp->setAccessible(true);
     $value = $rp->getValue($target);
     $rp->setValue($target, $value + array_shift($changes));
     $rp->setAccessible(false);
 }
Example #29
0
 protected function getValue($object)
 {
     $refProp = new \ReflectionProperty($object, $this->getName());
     $refProp->setAccessible(true);
     $value = $refProp->getValue($object);
     $refProp->setAccessible(false);
     return $value;
 }
 /**
  * 
  * @param \AgNetSolutions\Common\Metadata\PropertyAnnotation $annotation
  * @param \ReflectionProperty $reflection
  */
 public function __construct(PropertyAnnotation $annotation, \ReflectionProperty $reflection)
 {
     $this->reflection = $reflection;
     $this->annotation = $annotation;
     if ($this->reflection->isPrivate() || $this->reflection->isProtected()) {
         $this->reflection->setAccessible(true);
     }
 }