1
0
mirror of https://github.com/halaxa/json-machine.git synced 2025-01-17 21:18:23 +01:00

Tests radability

This commit is contained in:
Filip Halaxa 2022-01-27 12:51:13 +01:00
parent aac5ad3547
commit d804498649
6 changed files with 32 additions and 33 deletions

View File

@ -26,16 +26,16 @@ class ItemsOptionsTest extends TestCase
}
/**
* @dataProvider dataOptionNames
* @dataProvider defaultOptionNames
*/
public function testThrowsOnInvalidOptionType($option)
public function testThrowsOnInvalidOptionType($optionName)
{
$this->expectException(InvalidArgumentException::class);
new ItemsOptions([$option => new InvalidValue()]);
new ItemsOptions([$optionName => new InvalidValue()]);
}
public function dataOptionNames()
public function defaultOptionNames()
{
foreach ($this->defaultOptions() as $name => $ignore) {
yield [$name];

View File

@ -8,7 +8,7 @@ use JsonMachine\JsonDecoder\PassThruDecoder;
class ItemsTest extends \PHPUnit_Framework_TestCase
{
/**
* @dataProvider dataFactories
* @dataProvider data_testFactories
*/
public function testFactories($expected, $methodName, ...$args)
{
@ -31,7 +31,7 @@ class ItemsTest extends \PHPUnit_Framework_TestCase
}
}
public function dataFactories()
public function data_testFactories()
{
$extJsonResult = ['key' => 'value'];
$passThruResult = ['key' => '"value"'];

View File

@ -9,7 +9,7 @@ use PHPUnit_Framework_TestCase;
class ExtJsonDecodersTest extends PHPUnit_Framework_TestCase
{
/**
* @dataProvider dataPassesOptionsToJsonDecode
* @dataProvider data_testPassesOptionsToJsonDecode
*/
public function testPassesOptionsToJsonDecode($className, $methodName)
{
@ -39,7 +39,7 @@ class ExtJsonDecodersTest extends PHPUnit_Framework_TestCase
$this->assertSame('123123123123123123123', $bigintResult->getValue());
}
public function dataPassesOptionsToJsonDecode()
public function data_testPassesOptionsToJsonDecode()
{
return [
[PassThruDecoder::class, 'decodeKey'],

View File

@ -3,6 +3,7 @@
namespace JsonMachineTest;
use JsonMachine\DebugLexer;
use JsonMachine\FileChunks;
use JsonMachine\Lexer;
use JsonMachine\StreamChunks;
use JsonMachine\StringChunks;
@ -145,7 +146,7 @@ class LexerTest extends \PHPUnit_Framework_TestCase
/**
* @param string $formattedJsonFilePath
* @dataProvider dataProvidesLocationalData
* @dataProvider jsonFilesWithDifferentLineEndings
*/
public function testProvidesLocationalDataWhenDebugEnabled($formattedJsonFilePath)
{
@ -165,13 +166,11 @@ class LexerTest extends \PHPUnit_Framework_TestCase
}
/**
* @param string $formattedJsonFilePath
* @dataProvider dataProvidesLocationalData
* @dataProvider jsonFilesWithDifferentLineEndings
*/
public function testProvidesLocationalDataWhenDebugDisabled($formattedJsonFilePath)
public function testProvidesLocationalDataWhenDebugDisabled(string $jsonFilePath)
{
$json = file_get_contents($formattedJsonFilePath);
$lexer = new Lexer(new StringChunks($json));
$lexer = new Lexer(new FileChunks($jsonFilePath));
$expectedTokens = $this->expectedTokens();
$i = 0;
@ -185,7 +184,7 @@ class LexerTest extends \PHPUnit_Framework_TestCase
}
}
public function dataProvidesLocationalData()
public function jsonFilesWithDifferentLineEndings()
{
return [
'cr new lines' => [__DIR__.'/formatted-cr.json'],

View File

@ -14,7 +14,7 @@ use JsonMachine\StringChunks;
class ParserTest extends \PHPUnit_Framework_TestCase
{
/**
* @dataProvider dataSyntax
* @dataProvider data_testSyntax
*
* @param string $jsonPointer
* @param string $json
@ -30,7 +30,7 @@ class ParserTest extends \PHPUnit_Framework_TestCase
$this->assertSame($expectedResult, $result);
}
public function dataSyntax()
public function data_testSyntax()
{
return [
['', '{}', []],
@ -100,7 +100,7 @@ class ParserTest extends \PHPUnit_Framework_TestCase
}
/**
* @dataProvider dataThrowsOnNotFoundJsonPointer
* @dataProvider data_testThrowsOnNotFoundJsonPointer
*
* @param string $json
* @param string $jsonPointer
@ -113,7 +113,7 @@ class ParserTest extends \PHPUnit_Framework_TestCase
iterator_to_array($parser);
}
public function dataThrowsOnNotFoundJsonPointer()
public function data_testThrowsOnNotFoundJsonPointer()
{
return [
'non existing pointer' => ['{}', '/not/found'],
@ -124,7 +124,7 @@ class ParserTest extends \PHPUnit_Framework_TestCase
}
/**
* @dataProvider dataGetJsonPointerPath
* @dataProvider data_testGetJsonPointerPath
*
* @param string $jsonPointer
*/
@ -134,7 +134,7 @@ class ParserTest extends \PHPUnit_Framework_TestCase
$this->assertEquals($expectedJsonPointerPath, $parser->getJsonPointerPath());
}
public function dataGetJsonPointerPath()
public function data_testGetJsonPointerPath()
{
return [
['/', ['']],
@ -146,7 +146,7 @@ class ParserTest extends \PHPUnit_Framework_TestCase
}
/**
* @dataProvider dataSyntaxError
* @dataProvider data_testSyntaxError
*
* @param string $malformedJson
*/
@ -157,7 +157,7 @@ class ParserTest extends \PHPUnit_Framework_TestCase
iterator_to_array($this->createParser($malformedJson));
}
public function dataSyntaxError()
public function data_testSyntaxError()
{
return [
['[}'],
@ -184,7 +184,7 @@ class ParserTest extends \PHPUnit_Framework_TestCase
}
/**
* @dataProvider dataUnexpectedEndError
* @dataProvider data_testUnexpectedEndError
*
* @param string $malformedJson
*/
@ -195,7 +195,7 @@ class ParserTest extends \PHPUnit_Framework_TestCase
iterator_to_array($this->createParser($malformedJson));
}
public function dataUnexpectedEndError()
public function data_testUnexpectedEndError()
{
return [
['['],
@ -322,7 +322,7 @@ class ParserTest extends \PHPUnit_Framework_TestCase
}
/**
* @dataProvider dataGetCurrentJsonPointer
* @dataProvider data_testGetCurrentJsonPointer
*/
public function testGetCurrentJsonPointer($jsonPointer, string $json, array $currentJsonPointers)
{
@ -335,7 +335,7 @@ class ParserTest extends \PHPUnit_Framework_TestCase
}
}
public function dataGetCurrentJsonPointer()
public function data_testGetCurrentJsonPointer()
{
return [
['', '{"c":1,"d":2}', ['', '']],
@ -361,7 +361,7 @@ class ParserTest extends \PHPUnit_Framework_TestCase
}
/**
* @dataProvider dataGetMatchedJsonPointer
* @dataProvider data_testGetMatchedJsonPointer
*/
public function testGetMatchedJsonPointer($jsonPointer, string $json, array $matchedJsonPointers)
{
@ -374,7 +374,7 @@ class ParserTest extends \PHPUnit_Framework_TestCase
}
}
public function dataGetMatchedJsonPointer()
public function data_testGetMatchedJsonPointer()
{
return [
['', '{"c":1,"d":2}', ['', '']],

View File

@ -8,7 +8,7 @@ use JsonMachine\ValidJsonPointers;
class ValidJsonPointersTest extends \PHPUnit_Framework_TestCase
{
/**
* @dataProvider dataIntersectingPaths
* @dataProvider data_testThrowsOnIntersectingPaths
*
* @param $jsonPointers
* @param ParserTest $parserTest
@ -20,7 +20,7 @@ class ValidJsonPointersTest extends \PHPUnit_Framework_TestCase
(new ValidJsonPointers($jsonPointers))->toArray();
}
public function dataIntersectingPaths()
public function data_testThrowsOnIntersectingPaths()
{
return [
[['/companies/-/id', '/companies/0/id']],
@ -33,7 +33,7 @@ class ValidJsonPointersTest extends \PHPUnit_Framework_TestCase
}
/**
* @dataProvider dataThrowsOnMalformedJsonPointer
* @dataProvider data_testThrowsOnMalformedJsonPointer
*/
public function testThrowsOnMalformedJsonPointer(array $jsonPointer)
{
@ -42,7 +42,7 @@ class ValidJsonPointersTest extends \PHPUnit_Framework_TestCase
(new ValidJsonPointers($jsonPointer))->toArray();
}
public function dataThrowsOnMalformedJsonPointer()
public function data_testThrowsOnMalformedJsonPointer()
{
return [
[['apple']],