コード例 #1
0
ファイル: ElasticSearchTest.php プロジェクト: spira/api-core
 public function setUp()
 {
     parent::setUp();
     if (!TestEntity::indexExists()) {
         TestEntity::createIndex();
     }
     TestEntity::flushEventListeners();
     TestEntity::boot();
     //run event listeners
     TestEntity::removeAllFromIndex();
 }
コード例 #2
0
ファイル: EntityTest.php プロジェクト: spira/api-core
 public function testEntitySearch()
 {
     TestEntity::removeAllFromIndex();
     $searchEntity = factory(TestEntity::class)->create(['varchar' => 'searchforthisstring']);
     sleep(1);
     //give the elastic search agent time to index
     $this->getJson('/test/entities/pages?q=searchforthisstring', ['Range' => 'entities=0-9']);
     $collection = json_decode($this->response->getContent());
     $this->assertResponseStatus(206);
     $this->shouldReturnJson();
     $this->assertJsonArray();
     $this->assertCount(1, $collection);
     $this->assertEquals($searchEntity->entity_id, $collection[0]->entityId);
 }