has() public method

public has ( UniqueValue $value ) : boolean
$value Nelmio\Alice\Definition\Value\UniqueValue
return boolean
Example #1
0
 /**
  * {@inheritdoc}
  *
  * @param UniqueValue $value
  *
  * @throws UniqueValueGenerationLimitReachedException
  */
 public function resolve(ValueInterface $value, FixtureInterface $fixture, ResolvedFixtureSet $fixtureSet, array $scope, GenerationContext $context, int $tryCounter = 0) : ResolvedValueWithFixtureSet
 {
     $this->checkResolver(__METHOD__);
     $tryCounter = $this->incrementCounter($tryCounter, $value, $this->limit);
     /**
      * @var UniqueValue        $generatedValue
      * @var ResolvedFixtureSet $fixtureSet
      */
     list($generatedValue, $fixtureSet) = $this->generateValue($value, $fixture, $fixtureSet, $scope, $context);
     if ($this->pool->has($generatedValue)) {
         return $this->resolve($value, $fixture, $fixtureSet, $scope, $context, $tryCounter);
     }
     $this->pool->add($generatedValue);
     return new ResolvedValueWithFixtureSet($generatedValue->getValue(), $fixtureSet);
 }
Example #2
0
 /**
  * @dataProvider provideHasValueSet
  */
 public function testHasObjectValue(UniqueValuesPool $pool, UniqueValue $value, bool $expected)
 {
     $this->assertEquals($expected, $pool->has($value));
     $pool->add($value);
     $this->assertTrue($pool->has($value));
 }