/** * @return void */ protected function setUp() { $inputDir = Directory::getInputDataDir(); $this->tempDir = $inputDir . DIRECTORY_SEPARATOR . self::FUNCTIONAL_TEST_TEMP_DIR; $objFactory = new ObjectFactory(); $dirUtil = $objFactory->getFileUtil(); $dirUtil->createDirectoriesWhenNeeded($this->tempDir); $this->cleanUpFunctionalTestTempDir(); }
/** * @covers Box\TestScribe\Utils\ReflectionUtil */ public function test_execute_private_instance_method_in_a_mock() { $className = "\\Box\\TestScribe\\_fixture\\_input\\Calculator"; $methodName = 'privateAddOne'; $objectFactoryObj = new ObjectFactory(); $mockClassLoaderObj = $objectFactoryObj->getMockClassLoader(); $mockClass = $mockClassLoaderObj->createAndLoadMockClass($className, $methodName); $mockObjectFactoryObj = $objectFactoryObj->getMockObjectFactory(); $mockObj = $mockObjectFactoryObj->createMockObjectFromMockClass($mockClass, [1]); $phpClass = new PhpClass(new PhpClassName($className)); $methodHelper = new MethodHelper(); $methodObj = $methodHelper->createFromMethodName($phpClass, $methodName); $converterObj = $objectFactoryObj->getStringToInputValueConverter(); $inputValue = $converterObj->getValue('2'); $args = new Arguments([$inputValue]); $objectUnderTest = $objectFactoryObj->getReflectionUtil(); $executionResult = $objectUnderTest->invokeMethodRegardlessOfProtectionLevel($mockObj, $methodObj, $args); // Validate the execution result. $expected = 3; $this->assertSame($expected, $executionResult, 'Variable ( executionResult ) doesn\'t have the expected value.'); }