Skip to content

Commit

Permalink
Fix error: `Argument 1 passed to Jojo1981\DataResolver\Resolver\Conte…
Browse files Browse the repository at this point in the history
…xt::pushPathPart() must be of the type string, int given, called in...`
  • Loading branch information
jojo1981 committed Sep 6, 2021
1 parent 8a1f5ef commit a372188
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/Resolver/Context.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,12 @@ public function getPath(): string
}

/**
* @param string $pathPart
* @param int|string $pathPart
* @return $this
*/
public function pushPathPart(string $pathPart): self
public function pushPathPart($pathPart): self
{
$this->pathParts[] = $pathPart;
$this->pathParts[] = (string) $pathPart;

return $this;
}
Expand Down
57 changes: 57 additions & 0 deletions tests/Integration/Resolver/FlattenTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
<?php declare(strict_types=1);
/*
* This file is part of the jojo1981/data-resolver package
*
* Copyright (c) 2021 Joost Nijhuis <jnijhuis81@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed in the root of the source code
*/
namespace tests\Jojo1981\DataResolver\Integration\Resolver;

use Jojo1981\DataResolver\Extractor\Exception\ExtractorException;
use Jojo1981\DataResolver\Handler\Exception\HandlerException;
use Jojo1981\DataResolver\Predicate\Exception\PredicateException;
use PHPUnit\Framework\Exception as PHPUnitException;
use PHPUnit\Framework\ExpectationFailedException;
use SebastianBergmann\RecursionContext\InvalidArgumentException;
use tests\Jojo1981\DataResolver\Integration\AbstractIntegrationTestCase;

/**
* @package tests\Jojo1981\DataResolver\Integration\Resolver
*/
final class FlattenTest extends AbstractIntegrationTestCase
{
/**
* @test
* @coversNothing
*
* @return void
* @throws ExtractorException
* @throws HandlerException
* @throws InvalidArgumentException
* @throws PredicateException
* @throws PHPUnitException
* @throws ExpectationFailedException
*/
public function checkFlatten(): void
{
$resolver = $this->getResolverBuilderFactory()->create()
->flatten($this->getResolverBuilderFactory()->get('name'))
->build();

self::assertEquals(['John Doe', 'Jane Doe'], $resolver->resolve($this->getTestData()));

}

/**
* @return array[]
*/
private function getTestData(): array
{
return [
['name' => 'John Doe'],
['name' => 'Jane Doe']
];
}
}

0 comments on commit a372188

Please sign in to comment.