Repository: symfony/symfony
File: src/Symfony/Component/Finder/Tests/FinderTest.php (PHP)

Code before:
        $finder = $finder->append($finder1);

        $this->assertIterator($this->toAbsolute(['foo', 'foo/bar.tmp', 'qux', 'toto']), $finder->getIterator());
    }

    public function testAppendWithAnArray()
    {
        $finder = $this->buildFinder();
        $finder->files()->in(self::$tmpDir.\DIRECTORY_SEPARATOR.'foo');

        $finder->append($this->toAbsolute(['foo', 'toto']));

        $this->assertIterator($this->toAbsolute(['foo', 'foo/bar.tmp', 'toto']), $finder->getIterator());
    }

    public function testAppendStandardizesItemsToBeSymfonySplFileInfo()
    {
        $finder1 = $this->buildFinder();
        $finder1->files()->in(self::$tmpDir.\DIRECTORY_SEPARATOR.'foo');

        $finder2 = $this->buildFinder();
        $finder2->directories()->in(self::$tmpDir);

        $finder1->append($finder2);
        $finder1->append($this->toAbsolute(['foo']));
        $finder1->append(array_map(fn (string $item): \SplFileInfo => new \SplFileInfo($item), $this->toAbsolute(['toto'])));

        foreach ($finder1 as $item) {
            $this->assertInstanceOf(SplFileInfo::class, $item);
        }
    }

    public function testRelativePathOfAppendedItems()
    {
        $finder1 = $this->buildFinder();
        $finder1->files()->in(self::$tmpDir.\DIRECTORY_SEPARATOR.'foo');

        $finder2 = $this->buildFinder();
        $finder2->directories()->in(self::$tmpDir);

        $finder1->append($finder2);
        $finder1->append($this->toAbsolute(['foo']));
        $finder1->append(array_map(fn (string $item): \SplFileInfo => new \SplFileInfo($item), $this->toAbsolute(['toto'])));

        $this->assertSame(
            [
                // $finder1's ->in()
                self::$tmpDir . '/foo/bar.tmp' => 'bar.tmp',
                // $finder2's ->in()
                self::$tmpDir . '/qux' => 'qux',
                // new \SplFileInfo('toto')

Review comment (suggestion):
```suggestion
        $finder1->append(array_map(static fn ($item) => new \SplFileInfo($item), $this->toAbsolute(['toto'])));
```

Code after:
        $finder = $finder->append($finder1);

        $this->assertIterator($this->toAbsolute(['foo', 'foo/bar.tmp', 'qux', 'toto']), $finder->getIterator());
    }

    public function testAppendWithAnArray()
    {
        $finder = $this->buildFinder();
        $finder->files()->in(self::$tmpDir.\DIRECTORY_SEPARATOR.'foo');

        $finder->append($this->toAbsolute(['foo', 'toto']));

        $this->assertIterator($this->toAbsolute(['foo', 'foo/bar.tmp', 'toto']), $finder->getIterator());
    }

    public function testAppendStandardizesItemsToBeSymfonySplFileInfo()
    {
        $finder1 = $this->buildFinder();
        $finder1->files()->in(self::$tmpDir.\DIRECTORY_SEPARATOR.'foo');

        $finder2 = $this->buildFinder();
        $finder2->directories()->in(self::$tmpDir);

        $finder1->append($finder2);
        $finder1->append($this->toAbsolute(['foo']));
        $finder1->append(array_map(static fn ($item) => new \SplFileInfo($item), $this->toAbsolute(['toto'])));

        foreach ($finder1 as $item) {
            $this->assertInstanceOf(SplFileInfo::class, $item);
        }
    }

    public function testRelativePathOfAppendedItems()
    {
        $this->setupVfsProvider([
            'a' => [
                'a1' => '',
                'a2' => '',
                'b' => [
                    'b1' => '',
                    'b2' => '',
                    'c' => [
                        'c1' => '',
                        'c2' => '',
                    ],
                ],
            ],
        ]);

        $formatForAssert = static function (Finder $finder) {
            $data = [];