public function testConcatenation() { $obj = new CustomMarkupFilter(); $token1 = M::mock('\\Org\\Heigl\\Hyphenator\\Tokenizer\\Token'); $token1->shouldReceive('getFilteredContent')->once()->andReturn('a'); $token2 = M::mock('\\Org\\Heigl\\Hyphenator\\Tokenizer\\Token'); $token2->shouldReceive('getFilteredContent')->once()->andReturn('b'); $tokenList = M::mock('\\Org\\Heigl\\Hyphenator\\Tokenizer\\TokenRegistry'); $tokenList->shouldReceive('rewind')->once(); $tokenList->shouldReceive('valid')->times(3)->andReturnValues(array(true, true, false)); $tokenList->shouldReceive('current')->twice()->andReturnValues(array($token1, $token2)); $tokenList->shouldReceive('next')->twice(); $tokenList->shouldReceive('key')->andReturnValues(array(0, 1)); $method = \UnitTestHelper::getMethod($obj, '_concatenate'); $result = $method->invoke($obj, $tokenList); $this->assertEquals('ab', $result); }
/** * @dataProvider localeUnificationProvider * * @param $parameter * @param $expected */ public function testLocaleUnification($parameter, $expected) { $obj = new \Org\Heigl\Hyphenator\Dictionary\Dictionary(); $method = \UnitTestHelper::getMethod($obj, '_unifyLocale'); $result = $method->invoke($obj, $parameter); $this->assertEquals($expected, $result); }
public function testPersistenceLayer() { $cache = M::mock('Phpug\\Entity\\Cache'); $cache->shouldReceive('setLastChangeDate'); $mockEm = M::mock('stdObject'); $mockEm->shouldReceive('persist')->once(); $mockEm->shouldReceive('flush')->once(); $sm = M::mock('\\Zend\\ServiceManager\\ServiceManager'); $sm->shouldReceive('get')->with('doctrine.entitymanager.orm_default')->andReturn($mockEm); $m = new Country($this->ug, $sm); $method = \UnitTestHelper::getMethod($m, 'makePersistent'); $result = $method->invoke($m, $cache); $this->assertSame($cache, $result); }