public function importOne(ImportSpecification $specification) { $results = $this->import($specification); if (!$results->valid()) { return; } $one = $results->current(); if ($results->next() || $results->valid()) { throw new ImportException('Cannot import one: more than one record imported.'); } return $one; }
public function testImportOneOfMany() { $this->setExpectedException(ImportException::class); $this->provider->shouldReceive('fetch')->andReturn(new \ArrayIterator(['foo', 'bar'])); $this->porter->importOne($this->specification); }