File: src/Tests/Unit/BaseTestCase.php

Recommend this page to a friend!
  Classes of FN  >  PHP Base Converter  >  src/Tests/Unit/BaseTestCase.php  >  Download  
File: src/Tests/Unit/BaseTestCase.php
Role: Class source
Content type: text/plain
Description: Class source
Class: PHP Base Converter
Convert number representations between two bases
Author: By
Last change:
Date: 1 year ago
Size: 1,291 bytes
 

Contents

Class file image Download
<?php
/**
 * BaseConverter.
 *
 * @author Frank Nägler <mail@naegler.net>
 *
 * @link https://github.com/NeoBlack/BaseConverter
 */

namespace NeoBlack\BaseConverter\Tests\Unit;

/**
 * Class BaseTestCase.
 */
class BaseTestCase extends \PHPUnit_Framework_TestCase
{
   
/**
     * Call protected/private method of a class.
     *
     * @param mixed &$object Instantiated object that we will run method on.
     * @param string $methodName Method name to call
     * @param array $parameters Array of parameters to pass into method.
     *
     * @return mixed Method return.
     */
   
public function invokeMethod(&$object, $methodName, array $parameters = array())
    {
       
$reflection = new \ReflectionClass(get_class($object));
       
$method = $reflection->getMethod($methodName);
       
$method->setAccessible(true);

        return
$method->invokeArgs($object, $parameters);
    }

   
/**
     * @param \stdClass $object
     * @param string $property
     * @param mixed $value
     */
   
public function setProperty(&$object, $property, $value)
    {
       
$reflection = new \ReflectionClass(get_class($object));
       
$_property = $reflection->getProperty($property);
       
$_property->setAccessible(true);
       
$object->$property = $value;
    }
}


For more information send a message to info at phpclasses dot org.