assertEquals( $expected, StatsFormatter::getStatsFromFlatKey( $stats ) ); } /** * @dataProvider formatProvider */ public function testFormat( $stats, $format, $expected ) { $this->assertInternalType( $expected, StatsFormatter::format( $stats, $format ) ); } public function formatProvider() { $provider[] = [ [ 'Foo' => 1, 'Bar' => 1 ], StatsFormatter::FORMAT_PLAIN, 'string' ]; $provider[] = [ [ 'Foo' => 1, 'Bar' => 1 ], StatsFormatter::FORMAT_HTML, 'string' ]; $provider[] = [ [ 'Foo' => 1, 'Bar' => 1 ], StatsFormatter::FORMAT_JSON, 'string' ]; $provider[] = [ [ 'Foo' => 1, 'Bar' => 1 ], null, 'array' ]; return $provider; } public function statsProvider() { $provider[] = [ [ 'Foo' => 1, 'Bar' => 1 ], [ 'Foo' => 1, 'Bar' => 1 ] ]; $provider[] = [ [ 'Foo.foobar' => 1, 'Bar' => 1 ], [ 'Foo' => [ 'foobar' => 1 ], 'Bar' => 1 ] ]; $provider[] = [ [ 'Foo.foobar' => 5, 'Bar' => 1, 'Foo.foobar.baz' => 1 ], [ 'Foo' => [ 'foobar' => [ 5, 'baz' => 1 ] ], 'Bar' => 1 ] ]; return $provider; } }