public function testRedactSecrets() { $this->assertEquals('XXXXXX', $this->_sut->redactSecrets('abdcefabcdef')); $this->assertEquals('XXXXXX', $this->_sut->redactSecrets('123456789012')); $this->assertEquals('XXXXXX', $this->_sut->redactSecrets('abCDEF789012')); $this->assertEquals('abCDEF78901', $this->_sut->redactSecrets('abCDEF78901')); }
public function onSetup() { $this->_mockLogger = $this->mock(tubepress_api_log_LoggerInterface::_); $this->_mockLangUtils = $this->mock(tubepress_api_util_LangUtilsInterface::_); $this->_mockUrlFactory = $this->mock(tubepress_api_url_UrlFactoryInterface::_); $this->_mockStringUtils = $this->mock(tubepress_api_util_StringUtilsInterface::_); $this->_mockLangUtils->shouldReceive('isAssociativeArray')->andReturnUsing(function ($candidate) { $util = new tubepress_util_impl_LangUtils(); return $util->isAssociativeArray($candidate); }); $this->_mockLangUtils->shouldReceive('isSimpleArrayOfStrings')->andReturnUsing(function ($candidate) { $util = new tubepress_util_impl_LangUtils(); return $util->isSimpleArrayOfStrings($candidate); }); $this->_mockUrlFactory->shouldReceive('fromString')->andReturnUsing(function ($candidate) { $factory = new tubepress_url_impl_puzzle_UrlFactory(); return $factory->fromString($candidate); }); $this->_mockStringUtils->shouldReceive('endsWith')->andReturnUsing(function ($haystack, $needle) { $utils = new tubepress_util_impl_StringUtils(); return $utils->endsWith($haystack, $needle); }); $this->_mockLogger->shouldReceive('isEnabled')->atLeast(1)->andReturn(true); $this->_mockLogger->shouldReceive('debug'); $this->_sut = $this->buildSut($this->_mockLogger, $this->_mockUrlFactory, $this->_mockLangUtils, $this->_mockStringUtils); }
public function testFlushTo() { $mockLogger = $this->mock(tubepress_api_log_LoggerInterface::_); $mockLogger->shouldReceive('debug')->once()->with(Mockery::on(function ($m) { $utils = new tubepress_util_impl_StringUtils(); return $utils->endsWith($m, 'something'); }), array()); $this->_sut->debug('something'); $this->_sut->flushTo($mockLogger); $this->assertTrue(true); }
public function testBootException() { $this->setExpectedException('RuntimeException', 'hellooo!'); $this->_mockContainerSupplier->shouldReceive('getServiceContainer')->once()->andThrow(new RuntimeException('hellooo!')); $this->_mockBootLogger->shouldReceive('handleBootException')->once(); $this->_mockBootLogger->shouldReceive('onBootComplete')->once(); $validator = function ($arg) { $stringUtils = new tubepress_util_impl_StringUtils(); return $stringUtils->startsWith($arg, '<code>'); }; $this->_mockBootLogger->shouldReceive('error')->atLeast(1)->with(Mockery::on($validator)); $this->_bootSettings->shouldReceive('shouldClearCache')->once()->andReturn(false); $this->_sut->getServiceContainer(); }
private function _getExpectedClassMap(array $original) { $toReturn = array(); $pathExcludePattern = $this->_getPathExcludeRegex(); $stringUtils = new tubepress_util_impl_StringUtils(); foreach ($original as $className => $path) { if (!$className) { continue; } if (preg_match_all($pathExcludePattern, $path, $matches) !== 0) { continue; } if ($stringUtils->endsWith($path, 'vendor/tedivm/stash/src/Stash/Session/SessionHandlerInterface_Legacy.php')) { $path = str_replace('_Legacy.php', '.php', $path); } if ($stringUtils->endsWith($path, 'vendor/tedivm/stash/src/Stash/Session/SessionHandlerInterface_Modern.php')) { $path = str_replace('_Modern.php', '.php', $path); } $toReturn[$className] = $path; } ksort($toReturn); return $toReturn; }