Commit a2ea6900 authored by Bas de Nooijer's avatar Bas de Nooijer Committed by GitHub

Merge pull request #507 from localheinz/fix/assertion

Fix: Use more appropriate assertion
parents 312b4da4 787ba075
...@@ -102,7 +102,7 @@ final class Guzzle3Test extends \PHPUnit_Framework_TestCase ...@@ -102,7 +102,7 @@ final class Guzzle3Test extends \PHPUnit_Framework_TestCase
$receivedRequests = $plugin->getReceivedRequests(); $receivedRequests = $plugin->getReceivedRequests();
$this->assertSame(1, count($receivedRequests)); $this->assertCount(1, $receivedRequests);
$this->assertSame('GET', $receivedRequests[0]->getMethod()); $this->assertSame('GET', $receivedRequests[0]->getMethod());
$this->assertSame( $this->assertSame(
...@@ -149,10 +149,10 @@ final class Guzzle3Test extends \PHPUnit_Framework_TestCase ...@@ -149,10 +149,10 @@ final class Guzzle3Test extends \PHPUnit_Framework_TestCase
$receivedRequests = $plugin->getReceivedRequests(); $receivedRequests = $plugin->getReceivedRequests();
$this->assertSame(1, count($receivedRequests)); $this->assertCount(1, $receivedRequests);
$this->assertSame('POST', $receivedRequests[0]->getMethod()); $this->assertSame('POST', $receivedRequests[0]->getMethod());
$this->assertSame(file_get_contents(__FILE__), (string)$receivedRequests[0]->getBody()); $this->assertStringEqualsFile(__FILE__, (string)$receivedRequests[0]->getBody());
$this->assertSame( $this->assertSame(
'request value', 'request value',
(string)$receivedRequests[0]->getHeader('X-PHPUnit') (string)$receivedRequests[0]->getHeader('X-PHPUnit')
...@@ -198,7 +198,7 @@ final class Guzzle3Test extends \PHPUnit_Framework_TestCase ...@@ -198,7 +198,7 @@ final class Guzzle3Test extends \PHPUnit_Framework_TestCase
$receivedRequests = $plugin->getReceivedRequests(); $receivedRequests = $plugin->getReceivedRequests();
$this->assertSame(1, count($receivedRequests)); $this->assertCount(1, $receivedRequests);
$this->assertSame('POST', $receivedRequests[0]->getMethod()); $this->assertSame('POST', $receivedRequests[0]->getMethod());
$this->assertSame($xml, (string)$receivedRequests[0]->getBody()); $this->assertSame($xml, (string)$receivedRequests[0]->getBody());
...@@ -250,7 +250,7 @@ final class Guzzle3Test extends \PHPUnit_Framework_TestCase ...@@ -250,7 +250,7 @@ final class Guzzle3Test extends \PHPUnit_Framework_TestCase
$receivedRequests = $plugin->getReceivedRequests(); $receivedRequests = $plugin->getReceivedRequests();
$this->assertSame(1, count($receivedRequests)); $this->assertCount(1, $receivedRequests);
$this->assertSame('GET', $receivedRequests[0]->getMethod()); $this->assertSame('GET', $receivedRequests[0]->getMethod());
$this->assertSame( $this->assertSame(
......
...@@ -155,7 +155,7 @@ final class GuzzleAdapterTest extends \PHPUnit_Framework_TestCase ...@@ -155,7 +155,7 @@ final class GuzzleAdapterTest extends \PHPUnit_Framework_TestCase
$this->assertCount(1, $container); $this->assertCount(1, $container);
$this->assertSame('POST', $container[0]['request']->getMethod()); $this->assertSame('POST', $container[0]['request']->getMethod());
$this->assertSame('request value', $container[0]['request']->getHeaderline('X-PHPUnit')); $this->assertSame('request value', $container[0]['request']->getHeaderline('X-PHPUnit'));
$this->assertSame(file_get_contents(__FILE__), (string)$container[0]['request']->getBody()); $this->assertStringEqualsFile(__FILE__, (string)$container[0]['request']->getBody());
} }
/** /**
......
...@@ -65,7 +65,7 @@ class WeightedRandomChoiceTest extends \PHPUnit_Framework_TestCase ...@@ -65,7 +65,7 @@ class WeightedRandomChoiceTest extends \PHPUnit_Framework_TestCase
$key = $randomizer->getRandom($excludes); $key = $randomizer->getRandom($excludes);
$this->assertTrue($key !== 'key3'); $this->assertNotSame($key, 'key3');
} }
public function testAllEntriesExcluded() public function testAllEntriesExcluded()
......
...@@ -85,7 +85,7 @@ class ResultTest extends AbstractResultTest ...@@ -85,7 +85,7 @@ class ResultTest extends AbstractResultTest
$result = new FilterResultDummy(1, 12, $this->numFound, $this->maxScore, $this->docs, $this->components, Query::FILTER_MODE_REMOVE); $result = new FilterResultDummy(1, 12, $this->numFound, $this->maxScore, $this->docs, $this->components, Query::FILTER_MODE_REMOVE);
$docs = $result->getDocuments(); $docs = $result->getDocuments();
$this->assertEquals(3, count($docs)); $this->assertCount(3, $docs);
$this->assertEquals($docs[0]->title, $this->docs[0]->title); $this->assertEquals($docs[0]->title, $this->docs[0]->title);
$this->assertEquals($docs[1]->title, $this->docs[1]->title); $this->assertEquals($docs[1]->title, $this->docs[1]->title);
$this->assertEquals($docs[2]->title, $this->docs[2]->title); $this->assertEquals($docs[2]->title, $this->docs[2]->title);
......
...@@ -86,7 +86,7 @@ class PrefetchIteratorTest extends \PHPUnit_Framework_TestCase ...@@ -86,7 +86,7 @@ class PrefetchIteratorTest extends \PHPUnit_Framework_TestCase
$this->plugin->initPlugin($mockClient, array()); $this->plugin->initPlugin($mockClient, array());
$this->plugin->setQuery($this->query); $this->plugin->setQuery($this->query);
$this->assertEquals(5, count($this->plugin)); $this->assertCount(5, $this->plugin);
} }
public function testIteratorAndRewind() public function testIteratorAndRewind()
...@@ -200,7 +200,7 @@ class PrefetchIteratorTest extends \PHPUnit_Framework_TestCase ...@@ -200,7 +200,7 @@ class PrefetchIteratorTest extends \PHPUnit_Framework_TestCase
$this->plugin->initPlugin($mockClient, array()); $this->plugin->initPlugin($mockClient, array());
$this->plugin->setQuery($this->query)->setEndpoint('s2'); $this->plugin->setQuery($this->query)->setEndpoint('s2');
$this->assertEquals(5, count($this->plugin)); $this->assertCount(5, $this->plugin);
} }
public function testWithSpecificEndpointOption() public function testWithSpecificEndpointOption()
...@@ -214,7 +214,7 @@ class PrefetchIteratorTest extends \PHPUnit_Framework_TestCase ...@@ -214,7 +214,7 @@ class PrefetchIteratorTest extends \PHPUnit_Framework_TestCase
$this->plugin->initPlugin($mockClient, array('endpoint' => 's3')); $this->plugin->initPlugin($mockClient, array('endpoint' => 's3'));
$this->plugin->setQuery($this->query); $this->plugin->setQuery($this->query);
$this->assertEquals(5, count($this->plugin)); $this->assertCount(5, $this->plugin);
} }
} }
......
...@@ -467,7 +467,7 @@ class QueryTest extends \PHPUnit_Framework_TestCase ...@@ -467,7 +467,7 @@ class QueryTest extends \PHPUnit_Framework_TestCase
); );
$components = $query->getComponents(); $components = $query->getComponents();
$this->assertEquals(1, count($components)); $this->assertCount(1, $components);
$this->assertThat( $this->assertThat(
array_pop($components), array_pop($components),
$this->isInstanceOf('Solarium\QueryType\Select\Query\Component\FacetSet') $this->isInstanceOf('Solarium\QueryType\Select\Query\Component\FacetSet')
......
...@@ -470,7 +470,7 @@ abstract class AbstractQueryTest extends \PHPUnit_Framework_TestCase ...@@ -470,7 +470,7 @@ abstract class AbstractQueryTest extends \PHPUnit_Framework_TestCase
); );
$components = $query->getComponents(); $components = $query->getComponents();
$this->assertEquals(1, count($components)); $this->assertCount(1, $components);
$this->assertThat( $this->assertThat(
array_pop($components), array_pop($components),
$this->isInstanceOf('Solarium\QueryType\Select\Query\Component\FacetSet') $this->isInstanceOf('Solarium\QueryType\Select\Query\Component\FacetSet')
......
...@@ -138,7 +138,7 @@ class DistributedSearchTest extends \PHPUnit_Framework_TestCase ...@@ -138,7 +138,7 @@ class DistributedSearchTest extends \PHPUnit_Framework_TestCase
$this->distributedSearch->clearShards(); $this->distributedSearch->clearShards();
$shards = $this->distributedSearch->getShards(); $shards = $this->distributedSearch->getShards();
$this->assertTrue(is_array($shards)); $this->assertTrue(is_array($shards));
$this->assertEquals(0, count($shards)); $this->assertCount(0, $shards);
} }
public function testAddShards() public function testAddShards()
...@@ -167,7 +167,7 @@ class DistributedSearchTest extends \PHPUnit_Framework_TestCase ...@@ -167,7 +167,7 @@ class DistributedSearchTest extends \PHPUnit_Framework_TestCase
) )
); );
$shards = $this->distributedSearch->getShards(); $shards = $this->distributedSearch->getShards();
$this->assertEquals(3, count($shards)); $this->assertCount(3, $shards);
$this->assertEquals( $this->assertEquals(
array( array(
'shard3' => 'localhost:8983/solr/shard3', 'shard3' => 'localhost:8983/solr/shard3',
...@@ -216,7 +216,7 @@ class DistributedSearchTest extends \PHPUnit_Framework_TestCase ...@@ -216,7 +216,7 @@ class DistributedSearchTest extends \PHPUnit_Framework_TestCase
$this->distributedSearch->clearCollections(); $this->distributedSearch->clearCollections();
$collections = $this->distributedSearch->getCollections(); $collections = $this->distributedSearch->getCollections();
$this->assertTrue(is_array($collections)); $this->assertTrue(is_array($collections));
$this->assertEquals(0, count($collections)); $this->assertCount(0, $collections);
} }
public function testAddCollections() public function testAddCollections()
...@@ -245,7 +245,7 @@ class DistributedSearchTest extends \PHPUnit_Framework_TestCase ...@@ -245,7 +245,7 @@ class DistributedSearchTest extends \PHPUnit_Framework_TestCase
) )
); );
$collections = $this->distributedSearch->getCollections(); $collections = $this->distributedSearch->getCollections();
$this->assertEquals(3, count($collections)); $this->assertCount(3, $collections);
$this->assertEquals( $this->assertEquals(
array( array(
'collection3' => 'localhost:8983/solr/collection3', 'collection3' => 'localhost:8983/solr/collection3',
...@@ -285,7 +285,7 @@ class DistributedSearchTest extends \PHPUnit_Framework_TestCase ...@@ -285,7 +285,7 @@ class DistributedSearchTest extends \PHPUnit_Framework_TestCase
$this->distributedSearch->clearReplicas(); $this->distributedSearch->clearReplicas();
$replicas = $this->distributedSearch->getReplicas(); $replicas = $this->distributedSearch->getReplicas();
$this->assertTrue(is_array($replicas)); $this->assertTrue(is_array($replicas));
$this->assertEquals(0, count($replicas)); $this->assertCount(0, $replicas);
} }
public function testAddReplicas() public function testAddReplicas()
...@@ -314,7 +314,7 @@ class DistributedSearchTest extends \PHPUnit_Framework_TestCase ...@@ -314,7 +314,7 @@ class DistributedSearchTest extends \PHPUnit_Framework_TestCase
) )
); );
$replicas = $this->distributedSearch->getReplicas(); $replicas = $this->distributedSearch->getReplicas();
$this->assertEquals(3, count($replicas)); $this->assertCount(3, $replicas);
$this->assertEquals( $this->assertEquals(
array( array(
'replica3' => 'localhost:8983/solr/replica3', 'replica3' => 'localhost:8983/solr/replica3',
......
...@@ -124,7 +124,7 @@ class DebugTest extends \PHPUnit_Framework_TestCase ...@@ -124,7 +124,7 @@ class DebugTest extends \PHPUnit_Framework_TestCase
$this->assertEquals('dummy-qp', $result->getQueryParser()); $this->assertEquals('dummy-qp', $result->getQueryParser());
$this->assertEquals('dummy-oq', $result->getOtherQuery()); $this->assertEquals('dummy-oq', $result->getOtherQuery());
$this->assertEquals(1, count($result->getExplain())); $this->assertCount(1, $result->getExplain());
$doc = $result->getExplain()->getDocument('MA147LL/A'); $doc = $result->getExplain()->getDocument('MA147LL/A');
$this->assertEquals(0.5, $doc->getValue()); $this->assertEquals(0.5, $doc->getValue());
$this->assertEquals(true, $doc->getMatch()); $this->assertEquals(true, $doc->getMatch());
...@@ -146,7 +146,7 @@ class DebugTest extends \PHPUnit_Framework_TestCase ...@@ -146,7 +146,7 @@ class DebugTest extends \PHPUnit_Framework_TestCase
) )
); );
$this->assertEquals(array($expectedDetail), $doc->getDetails()); $this->assertEquals(array($expectedDetail), $doc->getDetails());
$this->assertEquals(1, count($result->getExplainOther())); $this->assertCount(1, $result->getExplainOther());
$doc = $result->getExplainOther()->getDocument('IW-02'); $doc = $result->getExplainOther()->getDocument('IW-02');
$this->assertEquals(0.6, $doc->getValue()); $this->assertEquals(0.6, $doc->getValue());
$this->assertEquals(true, $doc->getMatch()); $this->assertEquals(true, $doc->getMatch());
...@@ -158,10 +158,10 @@ class DebugTest extends \PHPUnit_Framework_TestCase ...@@ -158,10 +158,10 @@ class DebugTest extends \PHPUnit_Framework_TestCase
$timing = $result->getTiming(); $timing = $result->getTiming();
$this->assertEquals(36, $timing->getTime()); $this->assertEquals(36, $timing->getTime());
$this->assertEquals(2, count($timing->getPhases())); $this->assertCount(2, $timing->getPhases());
$phase = $timing->getPhase('process'); $phase = $timing->getPhase('process');
$this->assertEquals(8, $phase->getTime()); $this->assertEquals(8, $phase->getTime());
$this->assertEquals(2, count($phase->getTimings())); $this->assertCount(2, $phase->getTimings());
$this->assertEquals(5, $phase->getTiming('org.apache.solr.handler.component.QueryComponent')); $this->assertEquals(5, $phase->getTiming('org.apache.solr.handler.component.QueryComponent'));
$this->assertEquals(3, $phase->getTiming('org.apache.solr.handler.component.MoreLikeThisComponent')); $this->assertEquals(3, $phase->getTiming('org.apache.solr.handler.component.MoreLikeThisComponent'));
} }
...@@ -183,8 +183,8 @@ class DebugTest extends \PHPUnit_Framework_TestCase ...@@ -183,8 +183,8 @@ class DebugTest extends \PHPUnit_Framework_TestCase
$this->assertEquals('dummy-qp', $result->getQueryParser()); $this->assertEquals('dummy-qp', $result->getQueryParser());
$this->assertEquals('dummy-oq', $result->getOtherQuery()); $this->assertEquals('dummy-oq', $result->getOtherQuery());
$this->assertEquals(0, count($result->getExplain())); $this->assertCount(0, $result->getExplain());
$this->assertEquals(0, count($result->getExplainOther())); $this->assertCount(0, $result->getExplainOther());
} }
public function testParseNoData() public function testParseNoData()
......
...@@ -76,6 +76,6 @@ class StatsTest extends \PHPUnit_Framework_TestCase ...@@ -76,6 +76,6 @@ class StatsTest extends \PHPUnit_Framework_TestCase
public function testParseNoData() public function testParseNoData()
{ {
$result = $this->parser->parse(null, null, array()); $result = $this->parser->parse(null, null, array());
$this->assertEquals(0, count($result)); $this->assertCount(0, $result);
} }
} }
...@@ -73,13 +73,8 @@ abstract class AbstractDocumentTest extends \PHPUnit_Framework_TestCase ...@@ -73,13 +73,8 @@ abstract class AbstractDocumentTest extends \PHPUnit_Framework_TestCase
public function testPropertyEmpty() public function testPropertyEmpty()
{ {
$this->assertTrue( $this->assertEmpty($this->doc->empty_field);
empty($this->doc->empty_field) $this->assertNotEmpty($this->doc->categories);
);
$this->assertFalse(
empty($this->doc->categories)
);
} }
public function testSetField() public function testSetField()
...@@ -124,13 +119,8 @@ abstract class AbstractDocumentTest extends \PHPUnit_Framework_TestCase ...@@ -124,13 +119,8 @@ abstract class AbstractDocumentTest extends \PHPUnit_Framework_TestCase
public function testArrayEmpty() public function testArrayEmpty()
{ {
$this->assertTrue( $this->assertEmpty($this->doc['empty_field']);
empty($this->doc['empty_field']) $this->assertNotEmpty($this->doc['categories']);
);
$this->assertFalse(
empty($this->doc['categories'])
);
} }
public function testArraySet() public function testArraySet()
......
...@@ -85,7 +85,7 @@ class ResponseParserTest extends \PHPUnit_Framework_TestCase ...@@ -85,7 +85,7 @@ class ResponseParserTest extends \PHPUnit_Framework_TestCase
); );
$this->assertEquals($expected, $result['results']); $this->assertEquals($expected, $result['results']);
$this->assertEquals(2, count($result['results'])); $this->assertCount(2, $result['results']);
} }
public function testParseSolr14Format() public function testParseSolr14Format()
...@@ -139,6 +139,6 @@ class ResponseParserTest extends \PHPUnit_Framework_TestCase ...@@ -139,6 +139,6 @@ class ResponseParserTest extends \PHPUnit_Framework_TestCase
); );
$this->assertEquals($expected, $result['results']); $this->assertEquals($expected, $result['results']);
$this->assertEquals(2, count($result['results'])); $this->assertCount(2, $result['results']);
} }
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment