/** * Test that index is deleted afer deleting a model * @return [type] [description] */ public function testDeleteIndexAfterDelete() { $ModelClass = new ModelClass(); $ModelClass->Behaviors->Indexable->settings['ModelClass']['request']['uri']['host'] = ELASTIC_HOST; $ModelClass->Behaviors->Indexable->settings['ModelClass']['request']['uri']['port'] = ELASTIC_PORT; $id = rand(0, 1000); $ModelClass->query("INSERT INTO model_classes (id, title) VALUES(" . $id . ", 'test')"); $this->HttpSocket->request(array('method' => 'PUT', 'uri' => array('host' => ELASTIC_HOST, 'port' => ELASTIC_PORT, 'path' => 'test_song/model_class/' . $id), 'body' => json_encode(array('id' => $id)))); $this->HttpSocket->request(array('method' => 'PUT', 'uri' => array('host' => ELASTIC_HOST, 'port' => ELASTIC_PORT, 'path' => 'test_song/model_class/25'), 'body' => json_encode(array('id' => 25)))); $response = $this->HttpSocket->request(array('method' => 'GET', 'uri' => array('host' => ELASTIC_HOST, 'port' => ELASTIC_PORT, 'path' => 'test_song/model_class/' . $id))); $response = json_decode($response, true); $this->assertTrue($response['exists']); $this->assertEquals(array('id' => $id), $response['_source']); $ModelClass->id = $id; $ModelClass->delete($id); $response = $this->HttpSocket->request(array('method' => 'GET', 'uri' => array('host' => ELASTIC_HOST, 'port' => ELASTIC_PORT, 'path' => 'test_song/model_class/' . $id))); $response = json_decode($response, true); // Deleting the index $this->assertFalse($response['exists']); // Don't delete other index $response = $this->HttpSocket->request(array('method' => 'GET', 'uri' => array('host' => ELASTIC_HOST, 'port' => ELASTIC_PORT, 'path' => 'test_song/model_class/25'))); $response = json_decode($response, true); $this->assertTrue($response['exists']); }