summaryrefslogtreecommitdiff
path: root/vendor/ruflin/elastica/test/lib/Elastica/Test/SnapshotTest.php
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/ruflin/elastica/test/lib/Elastica/Test/SnapshotTest.php')
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/SnapshotTest.php55
1 files changed, 26 insertions, 29 deletions
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/SnapshotTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/SnapshotTest.php
index 3ac5bfe2..fa190e8c 100644
--- a/vendor/ruflin/elastica/test/lib/Elastica/Test/SnapshotTest.php
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/SnapshotTest.php
@@ -1,8 +1,6 @@
<?php
-
namespace Elastica\Test;
-
use Elastica\Document;
use Elastica\Index;
use Elastica\Snapshot;
@@ -29,62 +27,62 @@ class SnapshotTest extends Base
parent::setUp();
$this->_snapshot = new Snapshot($this->_getClient());
- $this->_index = $this->_createIndex("test_snapshot");
+ $this->_index = $this->_createIndex();
$this->_docs = array(
- new Document("1", array("city" => "San Diego")),
- new Document("2", array("city" => "San Luis Obispo")),
- new Document("3", array("city" => "San Francisco")),
+ new Document('1', array('city' => 'San Diego')),
+ new Document('2', array('city' => 'San Luis Obispo')),
+ new Document('3', array('city' => 'San Francisco')),
);
- $this->_index->getType("test")->addDocuments($this->_docs);
+ $this->_index->getType('test')->addDocuments($this->_docs);
$this->_index->refresh();
}
- protected function tearDown()
- {
- parent::tearDown();
- $this->_index->delete();
- }
-
+ /**
+ * @group functional
+ */
public function testRegisterRepository()
{
- $name = "test_register";
- $location = "/tmp/test_register";
+ $name = 'test_register';
+ $location = '/tmp/test_register';
- $response = $this->_snapshot->registerRepository($name, "fs", array("location" => $location));
+ $response = $this->_snapshot->registerRepository($name, 'fs', array('location' => $location));
$this->assertTrue($response->isOk());
$response = $this->_snapshot->getRepository($name);
- $this->assertEquals($location, $response["settings"]["location"]);
+ $this->assertEquals($location, $response['settings']['location']);
// attempt to retrieve a repository which does not exist
$this->setExpectedException('Elastica\Exception\NotFoundException');
- $this->_snapshot->getRepository("foobar");
+ $this->_snapshot->getRepository('foobar');
}
+ /**
+ * @group functional
+ */
public function testSnapshotAndRestore()
{
- $repositoryName = "test_repository";
+ $repositoryName = 'test_repository';
$location = "/tmp/{$repositoryName}";
// register the repository
- $response = $this->_snapshot->registerRepository($repositoryName, "fs", array("location" => $location));
+ $response = $this->_snapshot->registerRepository($repositoryName, 'fs', array('location' => $location));
$this->assertTrue($response->isOk());
// create a snapshot of our test index
- $snapshotName = "test_snapshot_1";
- $response = $this->_snapshot->createSnapshot($repositoryName, $snapshotName, array("indices" => $this->_index->getName()), true);
+ $snapshotName = 'test_snapshot_1';
+ $response = $this->_snapshot->createSnapshot($repositoryName, $snapshotName, array('indices' => $this->_index->getName()), true);
// ensure that the snapshot was created properly
$this->assertTrue($response->isOk());
- $this->assertArrayHasKey("snapshot", $response->getData());
+ $this->assertArrayHasKey('snapshot', $response->getData());
$data = $response->getData();
- $this->assertContains($this->_index->getName(), $data["snapshot"]["indices"]);
- $this->assertEquals(1, sizeof($data["snapshot"]["indices"])); // only the specified index should be present
- $this->assertEquals($snapshotName, $data["snapshot"]["snapshot"]);
+ $this->assertContains($this->_index->getName(), $data['snapshot']['indices']);
+ $this->assertEquals(1, sizeof($data['snapshot']['indices'])); // only the specified index should be present
+ $this->assertEquals($snapshotName, $data['snapshot']['snapshot']);
// retrieve data regarding the snapshot
$response = $this->_snapshot->getSnapshot($repositoryName, $snapshotName);
- $this->assertContains($this->_index->getName(), $response["indices"]);
+ $this->assertContains($this->_index->getName(), $response['indices']);
// delete our test index
$this->_index->delete();
@@ -97,7 +95,7 @@ class SnapshotTest extends Base
$this->_index->optimize();
// ensure that the index has been restored
- $count = $this->_index->getType("test")->count();
+ $count = $this->_index->getType('test')->count();
$this->assertEquals(sizeof($this->_docs), $count);
// delete the snapshot
@@ -109,4 +107,3 @@ class SnapshotTest extends Base
$this->_snapshot->getSnapshot($repositoryName, $snapshotName);
}
}
- \ No newline at end of file