for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace Port\Elasticsearch\Tests;
use PHPUnit\Framework\TestCase;
use Elasticsearch\Client;
use Port\Elasticsearch\ScrollReader;
class ScrollReaderTest extends TestCase
{
protected function setup()
$this->client = $this->prophesize(Client::class);
client
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:
class MyClass { } $x = new MyClass(); $x->foo = true;
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:
class MyClass { public $foo; } $x = new MyClass(); $x->foo = true;
$this->reader = new ScrollReader($this->client, [
reader
'foo' => 'bar',
]);
}
public function testGetItems()
$this->client->search(['foo' => 'bar', 'scroll' => '1m'])
->willReturn([
'_scroll_id' => '1',
'hits' => [
'foo' => 'bar'
]
$this->client->search(['foo' => 'bar', 'scroll' => '1m', 'scroll_id' => '1'])
'_scroll_id' => '2',
'hits' => []
$response = $this->reader->getItems();
$items = [];
foreach ($response as $item) {
$items[] = $item;
$this->assertEquals(['foo' => 'bar'], $items);
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion: