function testExcludeVariantState()
 {
     $index = singleton('SearchVariantVersionedTest_IndexNoStage');
     FullTextSearch::force_index_list($index);
     // Check that write doesn't update stage
     $item = new SearchVariantVersionedTest_Item(array('TestText' => 'Foo'));
     $item->write();
     SearchUpdater::flush_dirty_indexes();
     $this->assertEquals($index->getAdded(array('ID', '_versionedstage')), array());
     // Check that publish updates Live
     $index->reset();
     $item->publish("Stage", "Live");
     SearchUpdater::flush_dirty_indexes();
     $this->assertEquals($index->getAdded(array('ID', '_versionedstage')), array(array('ID' => $item->ID, '_versionedstage' => 'Live')));
 }
 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'));
 }