mirror of
https://github.com/wiosna-dev/common-library.git
synced 2026-03-12 17:41:50 +01:00
Reformat code automatically
This commit is contained in:
@@ -24,6 +24,29 @@ use Meritoo\Common\Type\OopVisibilityType;
|
||||
*/
|
||||
class InvalidContentExceptionTest extends BaseTestCase
|
||||
{
|
||||
public function provideContent(): ?Generator
|
||||
{
|
||||
$template = 'Content of template \'%s\' is invalid. Did you use string with 1 placeholder at least?';
|
||||
|
||||
yield [
|
||||
'An empty string',
|
||||
'',
|
||||
sprintf($template, ''),
|
||||
];
|
||||
|
||||
yield [
|
||||
'Simple string',
|
||||
'Lorem ipsum',
|
||||
sprintf($template, 'Lorem ipsum'),
|
||||
];
|
||||
|
||||
yield [
|
||||
'One sentence',
|
||||
'Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh.',
|
||||
sprintf($template, 'Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh.'),
|
||||
];
|
||||
}
|
||||
|
||||
public function testConstructorVisibilityAndArguments(): void
|
||||
{
|
||||
static::assertConstructorVisibilityAndArguments(
|
||||
@@ -45,27 +68,4 @@ class InvalidContentExceptionTest extends BaseTestCase
|
||||
$exception = InvalidContentException::create($content);
|
||||
static::assertSame($expectedMessage, $exception->getMessage(), $description);
|
||||
}
|
||||
|
||||
public function provideContent(): ?Generator
|
||||
{
|
||||
$template = 'Content of template \'%s\' is invalid. Did you use string with 1 placeholder at least?';
|
||||
|
||||
yield[
|
||||
'An empty string',
|
||||
'',
|
||||
sprintf($template, ''),
|
||||
];
|
||||
|
||||
yield[
|
||||
'Simple string',
|
||||
'Lorem ipsum',
|
||||
sprintf($template, 'Lorem ipsum'),
|
||||
];
|
||||
|
||||
yield[
|
||||
'One sentence',
|
||||
'Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh.',
|
||||
sprintf($template, 'Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh.'),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
|
||||
namespace Meritoo\Test\Common\Exception\ValueObject\Template;
|
||||
|
||||
use Generator;
|
||||
use Meritoo\Common\Exception\ValueObject\Template\MissingPlaceholdersInValuesException;
|
||||
use Meritoo\Common\Test\Base\BaseTestCase;
|
||||
use Meritoo\Common\Type\OopVisibilityType;
|
||||
@@ -23,6 +24,39 @@ use Meritoo\Common\Type\OopVisibilityType;
|
||||
*/
|
||||
class MissingPlaceholdersInValuesExceptionTest extends BaseTestCase
|
||||
{
|
||||
public function provideContentAndMissingPlaceholders(): ?Generator
|
||||
{
|
||||
$template = 'Cannot fill template \'%s\', because of missing values for placeholder(s): %s. Did you provide all'
|
||||
.' required values?';
|
||||
|
||||
yield [
|
||||
'Missing 2nd placeholder',
|
||||
'%test1% - %test2%',
|
||||
[
|
||||
'test2',
|
||||
],
|
||||
sprintf(
|
||||
$template,
|
||||
'%test1% - %test2%',
|
||||
'test2'
|
||||
),
|
||||
];
|
||||
|
||||
yield [
|
||||
'Missing 2nd and 3rd placeholder',
|
||||
'%test1% / %test2% / %test3%',
|
||||
[
|
||||
'test2',
|
||||
'test3',
|
||||
],
|
||||
sprintf(
|
||||
$template,
|
||||
'%test1% / %test2% / %test3%',
|
||||
'test2, test3'
|
||||
),
|
||||
];
|
||||
}
|
||||
|
||||
public function testConstructorVisibilityAndArguments(): void
|
||||
{
|
||||
static::assertConstructorVisibilityAndArguments(
|
||||
@@ -49,37 +83,4 @@ class MissingPlaceholdersInValuesExceptionTest extends BaseTestCase
|
||||
$exception = MissingPlaceholdersInValuesException::create($content, $missingPlaceholders);
|
||||
static::assertSame($expectedMessage, $exception->getMessage(), $description);
|
||||
}
|
||||
|
||||
public function provideContentAndMissingPlaceholders(): ?\Generator
|
||||
{
|
||||
$template = 'Cannot fill template \'%s\', because of missing values for placeholder(s): %s. Did you provide all'
|
||||
. ' required values?';
|
||||
|
||||
yield[
|
||||
'Missing 2nd placeholder',
|
||||
'%test1% - %test2%',
|
||||
[
|
||||
'test2',
|
||||
],
|
||||
sprintf(
|
||||
$template,
|
||||
'%test1% - %test2%',
|
||||
'test2'
|
||||
),
|
||||
];
|
||||
|
||||
yield[
|
||||
'Missing 2nd and 3rd placeholder',
|
||||
'%test1% / %test2% / %test3%',
|
||||
[
|
||||
'test2',
|
||||
'test3',
|
||||
],
|
||||
sprintf(
|
||||
$template,
|
||||
'%test1% / %test2% / %test3%',
|
||||
'test2, test3'
|
||||
),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,6 +24,29 @@ use Meritoo\Common\Type\OopVisibilityType;
|
||||
*/
|
||||
class TemplateNotFoundExceptionTest extends BaseTestCase
|
||||
{
|
||||
public function provideIndexAndException(): ?Generator
|
||||
{
|
||||
$template = 'Template with \'%s\' index was not found. Did you provide all required templates?';
|
||||
|
||||
yield [
|
||||
'An empty string',
|
||||
'',
|
||||
new TemplateNotFoundException(sprintf($template, '')),
|
||||
];
|
||||
|
||||
yield [
|
||||
'Non-empty string',
|
||||
'test',
|
||||
new TemplateNotFoundException(sprintf($template, 'test')),
|
||||
];
|
||||
|
||||
yield [
|
||||
'Integer',
|
||||
'2',
|
||||
new TemplateNotFoundException(sprintf($template, 2)),
|
||||
];
|
||||
}
|
||||
|
||||
public function testConstructor(): void
|
||||
{
|
||||
static::assertConstructorVisibilityAndArguments(
|
||||
@@ -45,27 +68,4 @@ class TemplateNotFoundExceptionTest extends BaseTestCase
|
||||
$created = TemplateNotFoundException::create($index);
|
||||
static::assertEquals($expected, $created, $description);
|
||||
}
|
||||
|
||||
public function provideIndexAndException(): ?Generator
|
||||
{
|
||||
$template = 'Template with \'%s\' index was not found. Did you provide all required templates?';
|
||||
|
||||
yield[
|
||||
'An empty string',
|
||||
'',
|
||||
new TemplateNotFoundException(sprintf($template, '')),
|
||||
];
|
||||
|
||||
yield[
|
||||
'Non-empty string',
|
||||
'test',
|
||||
new TemplateNotFoundException(sprintf($template, 'test')),
|
||||
];
|
||||
|
||||
yield[
|
||||
'Integer',
|
||||
'2',
|
||||
new TemplateNotFoundException(sprintf($template, 2)),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user