public function testEndsWith() { $this->assertTrue($this->_sut->endsWith('something', 'thing')); $this->assertTrue($this->_sut->endsWith('some', 'some')); $this->assertFalse($this->_sut->endsWith(array(), 'some')); $this->assertFalse($this->_sut->endsWith('some', array())); }
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); }
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; }