Skip to content

Commit

Permalink
Update unit tests to be 1.0 compatible
Browse files Browse the repository at this point in the history
  • Loading branch information
polyfractal committed Jan 24, 2014
1 parent 08cabbe commit c386538
Show file tree
Hide file tree
Showing 29 changed files with 221 additions and 405 deletions.
4 changes: 2 additions & 2 deletions tests/Elasticsearch/Tests/ClientTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public function testBadHost()
'127.0.0.1:8200',
));
$client = new Elasticsearch\Client($params);
$client->exists(array("index" => 'test', 'id' => 'test'));
$client->exists(array("index" => 'test', 'type' => 'test', 'id' => 'test'));

}

Expand All @@ -91,7 +91,7 @@ public function testZeroRetries()
'hosts' => array('localhost:8000')
);
$client = new Elasticsearch\Client($params);
$client->exists(array("index" => 'test', 'id' => 'test'));
$client->exists(array("index" => 'test', 'type' => 'test', 'id' => 'test'));

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
* Time: 1:02 PM
*/

namespace Elasticsearch\Tests\Endpoints\Cluster\Node;
namespace Elasticsearch\Tests\Endpoints\Cluster\Nodes;

use Elasticsearch\Common\Exceptions\InvalidArgumentException;
use Elasticsearch\Endpoints\Cluster\Node\HotThreads;
use Elasticsearch\Endpoints\Cluster\Nodes\HotThreads;
use Mockery as m;

/**
Expand All @@ -18,7 +18,7 @@
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache2
* @link http://elasticsearch.org
*/
class SettingsTest extends \PHPUnit_Framework_TestCase
class HotThreadsTest extends \PHPUnit_Framework_TestCase
{
public function tearDown() {
m::close();
Expand All @@ -31,7 +31,7 @@ public function testValidSettingsWithNodeID()
->shouldReceive('performRequest')->once()->once()
->with(
'GET',
'/_cluster/nodes/abc/hot_threads',
'/_cluster/nodes/abc/hotthreads',
array(),
null
)
Expand All @@ -53,10 +53,9 @@ public function testValidSettingsWithInvalidNodeID()

$action = new HotThreads($mockTransport);

$nodeID = array('field' => 'value');
$nodeID = new \stdClass();

$action->setNodeID($nodeID)
->performRequest();
$action->setNodeID($nodeID);;

}

Expand All @@ -66,7 +65,7 @@ public function testValidSettingsWithoutNodeID()
->shouldReceive('performRequest')->once()
->with(
'GET',
'/_cluster/nodes/hot_threads',
'/_cluster/nodes/hotthreads',
array(),
null
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
* Time: 1:02 PM
*/

namespace Elasticsearch\Tests\Endpoints\Cluster\Node;
namespace Elasticsearch\Tests\Endpoints\Cluster\Nodes;

use Elasticsearch\Common\Exceptions\InvalidArgumentException;
use Elasticsearch\Endpoints\Cluster\Node\Info;
use Elasticsearch\Endpoints\Cluster\Nodes\Info;
use Mockery as m;

/**
Expand All @@ -31,7 +31,7 @@ public function testValidSettingsWithNodeID()
->shouldReceive('performRequest')->once()->once()
->with(
'GET',
'/_cluster/nodes/abc',
'/_nodes/abc',
array(),
null
)
Expand All @@ -53,7 +53,7 @@ public function testValidSettingsWithInvalidNodeID()

$action = new Info($mockTransport);

$nodeID = array('field' => 'value');
$nodeID = new \stdClass();

$action->setNodeID($nodeID)
->performRequest();
Expand All @@ -66,7 +66,7 @@ public function testValidSettingsWithoutNodeID()
->shouldReceive('performRequest')->once()
->with(
'GET',
'/_cluster/nodes',
'/_nodes',
array(),
null
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
namespace Elasticsearch\Tests\Endpoints\Cluster\Node;

use Elasticsearch\Common\Exceptions\InvalidArgumentException;
use Elasticsearch\Endpoints\Cluster\Node\Shutdown;
use Elasticsearch\Endpoints\Cluster\Nodes\Shutdown;
use Mockery as m;

/**
Expand Down Expand Up @@ -53,7 +53,7 @@ public function testValidSettingsWithInvalidNodeID()

$action = new Shutdown($mockTransport);

$nodeID = array('field' => 'value');
$nodeID = new \stdClass();

$action->setNodeID($nodeID)
->performRequest();
Expand All @@ -66,7 +66,7 @@ public function testValidSettingsWithoutNodeID()
->shouldReceive('performRequest')->once()
->with(
'POST',
'/_cluster/nodes/_shutdown',
'/_shutdown',
array(),
null
)
Expand Down
16 changes: 0 additions & 16 deletions tests/Elasticsearch/Tests/Endpoints/Cluster/RerouteTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,22 +45,6 @@ public function testSetBody()

}


/**
* @expectedException InvalidArgumentException
*/
public function testSetIllegalBody()
{
$query = 5;

$mockTransport = m::mock('\Elasticsearch\Transport');

$action = new Reroute($mockTransport);
$action->setBody($query)
->performRequest();

}

public function testValidReroute()
{
$mockTransport = m::mock('\Elasticsearch\Transport')
Expand Down
18 changes: 1 addition & 17 deletions tests/Elasticsearch/Tests/Endpoints/Cluster/Settings/PutTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* Time: 1:02 PM
*/

namespace Elasticsearch\Tests\Endpoints\Cluster\Puttings;
namespace Elasticsearch\Tests\Endpoints\Cluster\Settings;

use Elasticsearch\Common\Exceptions\InvalidArgumentException;
use Elasticsearch\Endpoints\Cluster\Settings\Put;
Expand Down Expand Up @@ -45,22 +45,6 @@ public function testPutBody()

}


/**
* @expectedException InvalidArgumentException
*/
public function testPutIllegalBody()
{
$query = 5;

$mockTransport = m::mock('\Elasticsearch\Transport');

$action = new Put($mockTransport);
$action->setBody($query)
->performRequest();

}

public function testValidPutWithBody()
{
$Puttings = array('field' => 'value');
Expand Down
2 changes: 1 addition & 1 deletion tests/Elasticsearch/Tests/Endpoints/CountTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public function tearDown() {
public function testGetURIWithNoIndexOrType()
{

$uri = '/_all/_count';
$uri = '/_count';

$mockTransport = m::mock('\Elasticsearch\Transport')
->shouldReceive('performRequest')->once()
Expand Down
21 changes: 5 additions & 16 deletions tests/Elasticsearch/Tests/Endpoints/Indices/Alias/AliasesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
namespace Elasticsearch\Tests\Endpoints\Indices\Alias;

use Elasticsearch\Common\Exceptions\InvalidArgumentException;
use Elasticsearch\Common\Exceptions\RuntimeException;
use Elasticsearch\Endpoints\Indices\Alias\Aliases;
use Elasticsearch\Endpoints\Indices\Aliases\Get;
use Elasticsearch\Endpoints\Indices\Aliases\Update;
use Mockery as m;

/**
Expand All @@ -26,17 +26,6 @@ public function tearDown() {
m::close();
}

/**
* @expectedException InvalidArgumentException
*/
public function testSetStringBody()
{
$body = 'value';
$mockTransport = m::mock('\Elasticsearch\Transport');
$action = new Aliases($mockTransport);
$action->setBody($body)->performRequest();
}

public function testSetArrayBody()
{
$body = array('field' => 'value');
Expand All @@ -50,7 +39,7 @@ public function testSetArrayBody()
)
->getMock();

$action = new Aliases($mockTransport);
$action = new Update($mockTransport);
$action->setBody($body)->performRequest();

}
Expand All @@ -68,7 +57,7 @@ public function testValidAliasesWithoutIndex()
)
->getMock();

$action = new Aliases($mockTransport);
$action = new Get($mockTransport);
$action->performRequest();

}
Expand All @@ -86,7 +75,7 @@ public function testValidAliasesWithIndex()
)
->getMock();

$action = new Aliases($mockTransport);
$action = new Get($mockTransport);
$action->setIndex('testIndex')->performRequest();

}
Expand Down
29 changes: 19 additions & 10 deletions tests/Elasticsearch/Tests/Endpoints/Indices/Alias/GetTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

namespace Elasticsearch\Tests\Endpoints\Indices\Alias;

use Elasticsearch\Common\Exceptions\RuntimeException;
use Elasticsearch\Endpoints\Indices\Alias\Get;
use Mockery as m;

Expand All @@ -25,25 +24,35 @@ public function tearDown() {
m::close();
}


/**
* @expectedException RuntimeException
*/
public function testNoIndexOrName()
{
$mockTransport = m::mock('\Elasticsearch\Transport');
$mockTransport = m::mock('\Elasticsearch\Transport')
->shouldReceive('performRequest')->once()
->with(
'GET',
'/_alias',
array(),
null
)
->getMock();

$action = new Get($mockTransport);
$action->performRequest();

}

/**
* @expectedException RuntimeException
*/

public function testNoName()
{
$mockTransport = m::mock('\Elasticsearch\Transport');
$mockTransport = m::mock('\Elasticsearch\Transport')
->shouldReceive('performRequest')->once()
->with(
'GET',
'/testIndex/_alias',
array(),
null
)
->getMock();

$action = new Get($mockTransport);
$action->setIndex('testIndex')->performRequest();
Expand Down
24 changes: 9 additions & 15 deletions tests/Elasticsearch/Tests/Endpoints/Indices/Alias/PutTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,6 @@ public function tearDown() {
}


/**
* @expectedException InvalidArgumentException
*/
public function testSetStringBody()
{
$body = 'value';
$mockTransport = m::mock('\Elasticsearch\Transport');
$action = new Put($mockTransport);
$action->setBody($body)->performRequest();
}

public function testSetArrayBody()
{
$body = array('field' => 'value');
Expand Down Expand Up @@ -68,13 +57,18 @@ public function testNoBody()
}


/**
* @expectedException RuntimeException
*/
public function testNoIndex()
{
$body = array('field' => 'value');
$mockTransport = m::mock('\Elasticsearch\Transport');
$mockTransport = m::mock('\Elasticsearch\Transport')
->shouldReceive('performRequest')->once()
->with(
'PUT',
'/_alias/testName',
array(),
$body
)
->getMock();

$action = new Put($mockTransport);
$action->setBody($body)->setName('testName')->performRequest();
Expand Down
16 changes: 0 additions & 16 deletions tests/Elasticsearch/Tests/Endpoints/Indices/AnalyzeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,22 +45,6 @@ public function testSetBody()

}


/**
* @expectedException InvalidArgumentException
*/
public function testSetIllegalQuery()
{
$body = array('field' => 'value');

$mockTransport = m::mock('\Elasticsearch\Transport');

$action = new Analyze($mockTransport);
$action->setBody($body)
->performRequest();

}

public function testGetURIWithNoIndex()
{

Expand Down
16 changes: 0 additions & 16 deletions tests/Elasticsearch/Tests/Endpoints/Indices/CreateTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,22 +36,6 @@ public function testSetBody()

}


/**
* @expectedException InvalidArgumentException
*/
public function testSetIllegalQuery()
{
$body = 'abc';

$mockTransport = m::mock('\Elasticsearch\Transport');

$action = new Create($mockTransport);
$action->setBody($body);

}


/**
* @expectedException RuntimeException
*/
Expand Down
Loading

0 comments on commit c386538

Please sign in to comment.