create recompose method + test (skipped), fix tests for dateParse

This commit is contained in:
Julien Fastré 2015-01-06 20:34:27 +01:00
parent 5289ad9c2c
commit a48a0be187
2 changed files with 33 additions and 13 deletions

View File

@ -52,4 +52,27 @@ abstract class AbstractSearch implements SearchInterface
}
}
protected function recomposePattern(array $terms, array $supportedTerms, $domain = '')
{
$recomposed = '';
if ($domain !== '')
{
$recomposed .= '@'.$domain.' ';
}
foreach ($supportedTerms as $term) {
if (array_key_exists($term, $terms) && $term !== '_default') {
$recomposed .= ' '.$term.':';
$recomposed .= (mb_stristr(' ', $terms[$term]) === FALSE) ? $terms[$term] : '('.$terms[$term].')';
}
}
if ($terms['_default'] !== '') {
$recomposed .= ' '.$terms['_default'];
}
return $recomposed;
}
}

View File

@ -28,31 +28,28 @@ namespace Chill\MainBundle\Tests\Search;
class AbstractSearchTest extends \PHPUnit_Framework_TestCase
{
/**
* @var Ab
* @var type
* @var typestractS
* @var \Chill\MainBundle\Search\AbstractSearch
*/
private $stub;
public function setUp()
{
$this->stub = $this->getMockForAbstractClass('Chill\MainBundle\Search\AbstractSearch',
array(),
'',
true,
true,
true,
array('parseDate'));
$this->stub = $this->getMockForAbstractClass('Chill\MainBundle\Search\AbstractSearch');
}
public function testParseDateRegular()
{
$this->markTestSkipped('We have to learn how to mock concret methods for abstract class');
$date = $this->stub->parseDate('2014-05-01');
//var_dump($this->stub);
$date = $this->stub->parseDate('2014-05-01');
$this->assertEquals('2014', $date->format('Y'));
$this->assertEquals('05', $date->format('m'));
$this->assertEquals('01', $date->format('d'));
}
public function testRecompose()
{
$this->markTestSkipped();
}
}