public function testDelete() { // Setup mocks $serviceMock = $this->getServiceMock(); self::$index->setService($serviceMock); // Delete the live record (not the stage) Versioned::reading_stage('Stage'); Phockito::reset($serviceMock); $item = new SearchVariantVersionedTest_Item(array('Title' => 'Too')); $item->write(); $item->publish('Stage', 'Live'); Versioned::reading_stage('Live'); $id = $item->ID; $item->delete(); SearchUpdater::flush_dirty_indexes(); Phockito::verify($serviceMock, 1)->deleteById($this->getExpectedDocumentId($id, 'Live')); Phockito::verify($serviceMock, 0)->deleteById($this->getExpectedDocumentId($id, 'Stage')); // Delete the stage record Versioned::reading_stage('Stage'); Phockito::reset($serviceMock); $item = new SearchVariantVersionedTest_Item(array('Title' => 'Too')); $item->write(); $item->publish('Stage', 'Live'); $id = $item->ID; $item->delete(); SearchUpdater::flush_dirty_indexes(); Phockito::verify($serviceMock, 1)->deleteById($this->getExpectedDocumentId($id, 'Stage')); Phockito::verify($serviceMock, 0)->deleteById($this->getExpectedDocumentId($id, 'Live')); }