Tests > increase code coverage

This commit is contained in:
Meritoo
2018-05-06 17:22:45 +02:00
parent 96bdb6eb60
commit 52e74c8b48
2 changed files with 134 additions and 83 deletions

View File

@@ -28,6 +28,7 @@ class MiscellaneousTest extends BaseTestCase
private $stringSmall;
private $stringCommaSeparated;
private $stringDotSeparated;
private $stringWithoutSpaces;
/**
* @throws ReflectionException
@@ -365,6 +366,7 @@ class MiscellaneousTest extends BaseTestCase
{
self::assertEquals('Lorem ipsum dolor sit<br>amet, consectetur<br>adipiscing<br>elit', Miscellaneous::breakLongText($this->stringCommaSeparated, 20));
self::assertEquals('Lorem ipsum dolor sit---amet, consectetur---adipiscing---elit', Miscellaneous::breakLongText($this->stringCommaSeparated, 20, '---'));
self::assertEquals('LoremIpsum<br>DolorSitAm<br>etConsecte<br>turAdipisc<br>ingElit', Miscellaneous::breakLongText($this->stringWithoutSpaces, 10));
}
public function testRemoveDirectoryUsingNotExistingDirectory()
@@ -768,6 +770,21 @@ class MiscellaneousTest extends BaseTestCase
self::assertNotEmpty(Miscellaneous::getProjectRootPath());
}
/**
* @param int $headerSize Length of HTTP headers in content
* @dataProvider provideHeaderSizeForEmptyCurlResponse
*/
public function testGetCurlResponseWithHeadersUsingEmptyResponse($headerSize)
{
$expected = [
'headers' => [],
'cookies' => [],
'content' => '',
];
self::assertEquals($expected, Miscellaneous::getCurlResponseWithHeaders('', $headerSize));
}
/**
* Provides string to convert characters to latin characters and not lower cased and not human-readable
*
@@ -1178,6 +1195,30 @@ class MiscellaneousTest extends BaseTestCase
];
}
/**
* Provides length/size of HTTP headers for an empty response
*
* @return Generator
*/
public function provideHeaderSizeForEmptyCurlResponse()
{
yield[
-10,
];
yield[
-1,
];
yield[
0,
];
yield[
10,
];
}
/**
* {@inheritdoc}
*/
@@ -1188,6 +1229,7 @@ class MiscellaneousTest extends BaseTestCase
$this->stringSmall = 'Lorem ipsum dolor sit amet.';
$this->stringCommaSeparated = 'Lorem ipsum dolor sit amet, consectetur adipiscing elit';
$this->stringDotSeparated = 'Etiam ullamcorper. Suspendisse a pellentesque dui, non felis.';
$this->stringWithoutSpaces = 'LoremIpsumDolorSitAmetConsecteturAdipiscingElit';
}
/**
@@ -1200,5 +1242,6 @@ class MiscellaneousTest extends BaseTestCase
unset($this->stringSmall);
unset($this->stringCommaSeparated);
unset($this->stringDotSeparated);
unset($this->stringWithoutSpaces);
}
}