public function testReturnSavedInstanceAtStart() { $stub = $this->getMockBuilder('Ignaszak\\Registry\\Scope\\IRegistry')->disableOriginalConstructor()->setMethods(['test'])->getMock(); $stub->method('test')->willReturn(true); MockTest::injectStatic('Ignaszak\\Registry\\RegistryFactory', 'registryArray', ['request' => $stub]); $result = RegistryFactory::start(); $this->assertTrue($result->test()); }
public function testLoadUserMessageWhenUserIsReporting() { // Clear counter to call again destructor MockTest::injectStatic($this->_controller, 'count'); MockTest::mockConf('userReporting', E_ALL); MockTest::inject($this->_controller, '_logFile', $this->mockLogFile("once")); MockTest::inject($this->_controller, '_display', $this->mockDisplay(2)); $this->_controller->__destruct(); }
public function testLoadLogDisplayWithBacktrace() { MockTest::injectStatic('Ignaszak\\Exception\\Controller\\IController', 'errorArray', [0 => ['type' => 'Warning', 'message' => 'anyMessage', 'file' => 'anyFile', 'line' => 1, 'trace' => [0 => ['message' => 'backtraceMEssage', 'file' => 'backtraceFile', 'arguments' => 'anyArguments']]]]); $result = MockTest::callMockMethod($this->_logFile, 'loadLogDisplay'); $this->assertEquals(['errors' => <<<EOT #1 [Warning] anyMessage in anyFile on line 1 [Backtrace]: backtraceMEssage IN: backtraceFile ARGUMENTS: anyArguments EOT , 'errorsCount' => 1], $result); MockTest::injectStatic('Ignaszak\\Exception\\Controller\\IController', 'errorArray', []); }
/** * Clear mock entity from \Conf\DB\DBDoctrine */ public static function clear() { MockTest::injectStatic('Conf\\DB\\DBDoctrine', 'em'); }
public function testGetSingleRefererDataByKey() { $referData = [5, 4, 3, 2, 1]; MockTest::injectStatic('App\\Resource\\Server', 'readReferDataArray', $referData); $this->assertEquals(4, $this->_form->getFormResponseData(1)); }
private function referData(array $data = null) { MockTest::injectStatic('App\\Resource\\Server', 'readReferDataArray', $data); }
public function testGetErrorArray() { MockTest::injectStatic('Ignaszak\\Exception\\Controller\\IController', 'errorArray', array(true)); $this->assertTrue(MockTest::callMockMethod($this->display, 'getErrorArray')[0]); }