File: StringStreamTest.php

package info (click to toggle)
php-async-aws-core 1.27.0-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 988 kB
  • sloc: php: 6,837; makefile: 32
file content (62 lines) | stat: -rw-r--r-- 1,472 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
<?php

declare(strict_types=1);

namespace AsyncAws\Core\Tests\Unit\Stream;

use AsyncAws\Core\Stream\StringStream;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;

class StringStreamTest extends TestCase
{
    /**
     * @dataProvider provideLengths
     */
    #[DataProvider('provideLengths')]
    public function testLength(string $content, ?int $expected): void
    {
        $stream = StringStream::create($content);

        self::assertSame($expected, $stream->length());
    }

    /**
     * @dataProvider provideStrings
     */
    #[DataProvider('provideStrings')]
    public function testStringify(string $content, string $expected): void
    {
        $stream = StringStream::create($content);

        self::assertSame($expected, $stream->stringify());
    }

    /**
     * @dataProvider provideChunks
     */
    #[DataProvider('provideChunks')]
    public function testChunk(string $content, array $expected): void
    {
        $stream = StringStream::create($content);

        self::assertSame($expected, iterator_to_array($stream));
    }

    public static function provideLengths(): iterable
    {
        yield ['Hello world', 11];
        yield ['H', 1];
        yield ['é', 2];
    }

    public static function provideStrings(): iterable
    {
        yield ['Hello world', 'Hello world'];
    }

    public static function provideChunks(): iterable
    {
        yield ['Hello world', ['Hello world']];
    }
}