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:
@@ -21,15 +21,153 @@ use Meritoo\Common\ValueObject\Version;
|
||||
* @copyright Meritoo <http://www.meritoo.pl>
|
||||
*
|
||||
* @internal
|
||||
* @covers \Meritoo\Common\ValueObject\Version
|
||||
* @covers \Meritoo\Common\ValueObject\Version
|
||||
*/
|
||||
class VersionTest extends BaseTestCase
|
||||
{
|
||||
/**
|
||||
* Provide version as array and expected instance of version
|
||||
*
|
||||
* @return Generator
|
||||
*/
|
||||
public function provideAsArray()
|
||||
{
|
||||
yield [
|
||||
[],
|
||||
null,
|
||||
];
|
||||
|
||||
yield [
|
||||
[
|
||||
1,
|
||||
0,
|
||||
],
|
||||
null,
|
||||
];
|
||||
|
||||
yield [
|
||||
[
|
||||
10,
|
||||
],
|
||||
null,
|
||||
];
|
||||
|
||||
yield [
|
||||
[
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
],
|
||||
new Version(0, 0, 0),
|
||||
];
|
||||
|
||||
yield [
|
||||
[
|
||||
1,
|
||||
0,
|
||||
2,
|
||||
],
|
||||
new Version(1, 0, 2),
|
||||
];
|
||||
|
||||
yield [
|
||||
[
|
||||
10,
|
||||
5,
|
||||
41,
|
||||
],
|
||||
new Version(10, 5, 41),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Provide version as string and expected instance of version
|
||||
*
|
||||
* @return Generator
|
||||
*/
|
||||
public function provideAsString()
|
||||
{
|
||||
yield [
|
||||
'',
|
||||
null,
|
||||
];
|
||||
|
||||
yield [
|
||||
'1.0',
|
||||
null,
|
||||
];
|
||||
|
||||
yield [
|
||||
'10',
|
||||
null,
|
||||
];
|
||||
|
||||
yield [
|
||||
'0.0.0',
|
||||
new Version(0, 0, 0),
|
||||
];
|
||||
|
||||
yield [
|
||||
'1.0.2',
|
||||
new Version(1, 0, 2),
|
||||
];
|
||||
|
||||
yield [
|
||||
'10.5.41',
|
||||
new Version(10, 5, 41),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Provide instance of version and expected version converted to string
|
||||
*
|
||||
* @return Generator
|
||||
*/
|
||||
public function provideConvertedToString()
|
||||
{
|
||||
yield [
|
||||
new Version(0, 0, 0),
|
||||
'0.0.0',
|
||||
];
|
||||
|
||||
yield [
|
||||
new Version(1, 0, 2),
|
||||
'1.0.2',
|
||||
];
|
||||
|
||||
yield [
|
||||
new Version(10, 5, 41),
|
||||
'10.5.41',
|
||||
];
|
||||
}
|
||||
|
||||
public function testConstructor()
|
||||
{
|
||||
static::assertConstructorVisibilityAndArguments(Version::class, OopVisibilityType::IS_PUBLIC, 3, 3);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $version The version
|
||||
* @param Version $expected (optional) Expected version
|
||||
*
|
||||
* @dataProvider provideAsArray
|
||||
*/
|
||||
public function testFromArray(array $version, Version $expected = null)
|
||||
{
|
||||
static::assertEquals($expected, Version::fromArray($version));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $version The version
|
||||
* @param Version $expected (optional) Expected version
|
||||
*
|
||||
* @dataProvider provideAsString
|
||||
*/
|
||||
public function testFromString($version, Version $expected = null)
|
||||
{
|
||||
static::assertEquals($expected, Version::fromString($version));
|
||||
}
|
||||
|
||||
public function testNewInstance()
|
||||
{
|
||||
$version = new Version(1, 0, 2);
|
||||
@@ -48,144 +186,6 @@ class VersionTest extends BaseTestCase
|
||||
*/
|
||||
public function testToString(Version $version, $expected)
|
||||
{
|
||||
static::assertSame($expected, (string)$version);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $version The version
|
||||
* @param Version $expected (optional) Expected version
|
||||
*
|
||||
* @dataProvider provideAsString
|
||||
*/
|
||||
public function testFromString($version, Version $expected = null)
|
||||
{
|
||||
static::assertEquals($expected, Version::fromString($version));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $version The version
|
||||
* @param Version $expected (optional) Expected version
|
||||
*
|
||||
* @dataProvider provideAsArray
|
||||
*/
|
||||
public function testFromArray(array $version, Version $expected = null)
|
||||
{
|
||||
static::assertEquals($expected, Version::fromArray($version));
|
||||
}
|
||||
|
||||
/**
|
||||
* Provide instance of version and expected version converted to string
|
||||
*
|
||||
* @return Generator
|
||||
*/
|
||||
public function provideConvertedToString()
|
||||
{
|
||||
yield[
|
||||
new Version(0, 0, 0),
|
||||
'0.0.0',
|
||||
];
|
||||
|
||||
yield[
|
||||
new Version(1, 0, 2),
|
||||
'1.0.2',
|
||||
];
|
||||
|
||||
yield[
|
||||
new Version(10, 5, 41),
|
||||
'10.5.41',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Provide version as string and expected instance of version
|
||||
*
|
||||
* @return Generator
|
||||
*/
|
||||
public function provideAsString()
|
||||
{
|
||||
yield[
|
||||
'',
|
||||
null,
|
||||
];
|
||||
|
||||
yield[
|
||||
'1.0',
|
||||
null,
|
||||
];
|
||||
|
||||
yield[
|
||||
'10',
|
||||
null,
|
||||
];
|
||||
|
||||
yield[
|
||||
'0.0.0',
|
||||
new Version(0, 0, 0),
|
||||
];
|
||||
|
||||
yield[
|
||||
'1.0.2',
|
||||
new Version(1, 0, 2),
|
||||
];
|
||||
|
||||
yield[
|
||||
'10.5.41',
|
||||
new Version(10, 5, 41),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Provide version as array and expected instance of version
|
||||
*
|
||||
* @return Generator
|
||||
*/
|
||||
public function provideAsArray()
|
||||
{
|
||||
yield[
|
||||
[],
|
||||
null,
|
||||
];
|
||||
|
||||
yield[
|
||||
[
|
||||
1,
|
||||
0,
|
||||
],
|
||||
null,
|
||||
];
|
||||
|
||||
yield[
|
||||
[
|
||||
10,
|
||||
],
|
||||
null,
|
||||
];
|
||||
|
||||
yield[
|
||||
[
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
],
|
||||
new Version(0, 0, 0),
|
||||
];
|
||||
|
||||
yield[
|
||||
[
|
||||
1,
|
||||
0,
|
||||
2,
|
||||
],
|
||||
new Version(1, 0, 2),
|
||||
];
|
||||
|
||||
yield[
|
||||
[
|
||||
10,
|
||||
5,
|
||||
41,
|
||||
],
|
||||
new Version(10, 5, 41),
|
||||
];
|
||||
static::assertSame($expected, (string) $version);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user