-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
On type update throw an document not found error
- Loading branch information
Alexis Thinardon
committed
Dec 21, 2018
1 parent
2967d38
commit 1df7f4b
Showing
3 changed files
with
91 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<?php | ||
|
||
namespace Biig\Component\Elasticsearch\Exception; | ||
|
||
class DocumentNotFoundException extends \RuntimeException | ||
{ | ||
public function __construct(\Throwable $previous = null) | ||
{ | ||
parent::__construct( | ||
'Document not found', | ||
0, | ||
$previous | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
<?php | ||
|
||
namespace Biig\Component\Elasticsearch\Test\Indexation; | ||
|
||
use Biig\Component\Elasticsearch\Indexation\AbstractIndex; | ||
use Biig\Component\Elasticsearch\Indexation\AbstractType; | ||
use Biig\Component\Elasticsearch\Indexation\Doctrine\SimplePaginator; | ||
use Biig\Component\Elasticsearch\Indexation\Hydrator\Hydrator; | ||
use Biig\Component\Elasticsearch\Indexation\Hydrator\HydratorFactory; | ||
use Biig\Component\Elasticsearch\Indexation\IndexInterface; | ||
use Biig\Component\Elasticsearch\Mapping\IndexBuilder; | ||
use Elastica\Client; | ||
use Elastica\Exception\ElasticsearchException; | ||
use Elastica\Exception\ResponseException; | ||
use Elastica\Index; | ||
use Elastica\Response; | ||
use Elastica\Type; | ||
use PHPUnit\Framework\TestCase; | ||
use Prophecy\Argument; | ||
use Psr\Log\LoggerInterface; | ||
|
||
class AbstractTypeTest extends TestCase | ||
{ | ||
/** | ||
* @var LoggerInterface | ||
*/ | ||
private $logger; | ||
|
||
public function setUp() | ||
{ | ||
$this->logger = $this->prophesize(LoggerInterface::class); | ||
} | ||
|
||
/** | ||
* @expectedException \Biig\Component\Elasticsearch\Exception\DocumentNotFoundException | ||
*/ | ||
public function testItAcceptTypes() | ||
{ | ||
$type = $this->prophesize(Type::class); | ||
$response = $this->prophesize(Response::class); | ||
$exception = $this->prophesize(ResponseException::class); | ||
$exception->getResponse()->willReturn($response->reveal()); | ||
$response->getFullError()->willReturn(['type' => 'document_missing_exception']); | ||
|
||
$fooType = new FooType($this->logger->reveal()); | ||
$fooType->setType($type->reveal()); | ||
|
||
$type->updateDocument(Argument::any())->willThrow($exception->reveal()); | ||
|
||
$fooType->update(new \stdClass(), 'foo'); | ||
} | ||
|
||
} | ||
|
||
class FooType extends AbstractType | ||
{ | ||
public function getPaginator(): SimplePaginator | ||
{ | ||
} | ||
|
||
public function getName(): string | ||
{ | ||
return 'bar'; | ||
} | ||
} |