PHPUnit > increase code coverage

This commit is contained in:
Meritoo
2019-04-06 08:14:48 +02:00
parent a13a629408
commit e05bc2302d
3 changed files with 128 additions and 7 deletions

View File

@@ -13,6 +13,7 @@ use Meritoo\Common\Exception\ValueObject\Template\InvalidContentException;
use Meritoo\Common\Exception\ValueObject\Template\NotEnoughValuesException;
use Meritoo\Common\Test\Base\BaseTestCase;
use Meritoo\Common\Type\OopVisibilityType;
use Meritoo\Common\Utilities\Reflection;
use Meritoo\Common\ValueObject\Template;
/**
@@ -50,6 +51,18 @@ class TemplateTest extends BaseTestCase
new Template($content);
}
/**
* @param string $description Description of test
* @param string $content Raw string with placeholders (content of the template)
*
* @dataProvider provideValidContent
*/
public function testIsValidUsingValidContent(string $description, string $content): void
{
$template = new Template($content);
static::assertSame($content, Reflection::getPropertyValue($template, 'content', true), $description);
}
/**
* @param Template $template Template to fill
* @param array $values Pairs of key-value where: key - name of placeholder, value - value of the
@@ -212,4 +225,22 @@ class TemplateTest extends BaseTestCase
'My name is Jane Brown and I live in NY, USA',
];
}
public function provideValidContent(): ?Generator
{
yield[
'Template with 1 placeholder',
'%test%',
];
yield[
'Template with 2 placeholders',
'My name is %name% and I am %profession%',
];
yield[
'Template with 2 placeholders that contains space',
'My name is %first name% %last name% and I live in %current location%',
];
}
}