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
$receivedRequests = $plugin->getReceivedRequests();
$this->assertSame(1, count($receivedRequests));
$this->assertCount(1, $receivedRequests);
$this->assertSame('GET', $receivedRequests[0]->getMethod());
$this->assertSame(
......@@ -149,10 +149,10 @@ final class Guzzle3Test extends \PHPUnit_Framework_TestCase
$receivedRequests = $plugin->getReceivedRequests();
$this->assertSame(1, count($receivedRequests));
$this->assertCount(1, $receivedRequests);
$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(
'request value',
(string)$receivedRequests[0]->getHeader('X-PHPUnit')
......@@ -198,7 +198,7 @@ final class Guzzle3Test extends \PHPUnit_Framework_TestCase
$receivedRequests = $plugin->getReceivedRequests();
$this->assertSame(1, count($receivedRequests));
$this->assertCount(1, $receivedRequests);
$this->assertSame('POST', $receivedRequests[0]->getMethod());
$this->assertSame($xml, (string)$receivedRequests[0]->getBody());
......@@ -250,7 +250,7 @@ final class Guzzle3Test extends \PHPUnit_Framework_TestCase
$receivedRequests = $plugin->getReceivedRequests();
$this->assertSame(1, count($receivedRequests));
$this->assertCount(1, $receivedRequests);
$this->assertSame('GET', $receivedRequests[0]->getMethod());
$this->assertSame(
......
......@@ -155,7 +155,7 @@ final class GuzzleAdapterTest extends \PHPUnit_Framework_TestCase
$this->assertCount(1, $container);
$this->assertSame('POST', $container[0]['request']->getMethod());
$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
$key = $randomizer->getRandom($excludes);
$this->assertTrue($key !== 'key3');
$this->assertNotSame($key, 'key3');
}
public function testAllEntriesExcluded()
......
......@@ -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);
$docs = $result->getDocuments();
$this->assertEquals(3, count($docs));
$this->assertCount(3, $docs);
$this->assertEquals($docs[0]->title, $this->docs[0]->title);
$this->assertEquals($docs[1]->title, $this->docs[1]->title);
$this->assertEquals($docs[2]->title, $this->docs[2]->title);
......
......@@ -86,7 +86,7 @@ class PrefetchIteratorTest extends \PHPUnit_Framework_TestCase
$this->plugin->initPlugin($mockClient, array());
$this->plugin->setQuery($this->query);
$this->assertEquals(5, count($this->plugin));
$this->assertCount(5, $this->plugin);
}
public function testIteratorAndRewind()
......@@ -200,7 +200,7 @@ class PrefetchIteratorTest extends \PHPUnit_Framework_TestCase
$this->plugin->initPlugin($mockClient, array());
$this->plugin->setQuery($this->query)->setEndpoint('s2');
$this->assertEquals(5, count($this->plugin));
$this->assertCount(5, $this->plugin);
}
public function testWithSpecificEndpointOption()
......@@ -214,7 +214,7 @@ class PrefetchIteratorTest extends \PHPUnit_Framework_TestCase
$this->plugin->initPlugin($mockClient, array('endpoint' => 's3'));
$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
);
$components = $query->getComponents();
$this->assertEquals(1, count($components));
$this->assertCount(1, $components);
$this->assertThat(
array_pop($components),
$this->isInstanceOf('Solarium\QueryType\Select\Query\Component\FacetSet')
......
......@@ -470,7 +470,7 @@ abstract class AbstractQueryTest extends \PHPUnit_Framework_TestCase
);
$components = $query->getComponents();
$this->assertEquals(1, count($components));
$this->assertCount(1, $components);
$this->assertThat(
array_pop($components),
$this->isInstanceOf('Solarium\QueryType\Select\Query\Component\FacetSet')
......
......@@ -138,7 +138,7 @@ class DistributedSearchTest extends \PHPUnit_Framework_TestCase
$this->distributedSearch->clearShards();
$shards = $this->distributedSearch->getShards();
$this->assertTrue(is_array($shards));
$this->assertEquals(0, count($shards));
$this->assertCount(0, $shards);
}
public function testAddShards()
......@@ -167,7 +167,7 @@ class DistributedSearchTest extends \PHPUnit_Framework_TestCase
)
);
$shards = $this->distributedSearch->getShards();
$this->assertEquals(3, count($shards));
$this->assertCount(3, $shards);
$this->assertEquals(
array(
'shard3' => 'localhost:8983/solr/shard3',
......@@ -216,7 +216,7 @@ class DistributedSearchTest extends \PHPUnit_Framework_TestCase
$this->distributedSearch->clearCollections();
$collections = $this->distributedSearch->getCollections();
$this->assertTrue(is_array($collections));
$this->assertEquals(0, count($collections));
$this->assertCount(0, $collections);
}
public function testAddCollections()
......@@ -245,7 +245,7 @@ class DistributedSearchTest extends \PHPUnit_Framework_TestCase
)
);
$collections = $this->distributedSearch->getCollections();
$this->assertEquals(3, count($collections));
$this->assertCount(3, $collections);
$this->assertEquals(
array(
'collection3' => 'localhost:8983/solr/collection3',
......@@ -285,7 +285,7 @@ class DistributedSearchTest extends \PHPUnit_Framework_TestCase
$this->distributedSearch->clearReplicas();
$replicas = $this->distributedSearch->getReplicas();
$this->assertTrue(is_array($replicas));
$this->assertEquals(0, count($replicas));
$this->assertCount(0, $replicas);
}
public function testAddReplicas()
......@@ -314,7 +314,7 @@ class DistributedSearchTest extends \PHPUnit_Framework_TestCase
)
);
$replicas = $this->distributedSearch->getReplicas();
$this->assertEquals(3, count($replicas));
$this->assertCount(3, $replicas);
$this->assertEquals(
array(
'replica3' => 'localhost:8983/solr/replica3',
......
......@@ -124,7 +124,7 @@ class DebugTest extends \PHPUnit_Framework_TestCase
$this->assertEquals('dummy-qp', $result->getQueryParser());
$this->assertEquals('dummy-oq', $result->getOtherQuery());
$this->assertEquals(1, count($result->getExplain()));
$this->assertCount(1, $result->getExplain());
$doc = $result->getExplain()->getDocument('MA147LL/A');
$this->assertEquals(0.5, $doc->getValue());
$this->assertEquals(true, $doc->getMatch());
......@@ -146,7 +146,7 @@ class DebugTest extends \PHPUnit_Framework_TestCase
)
);
$this->assertEquals(array($expectedDetail), $doc->getDetails());
$this->assertEquals(1, count($result->getExplainOther()));
$this->assertCount(1, $result->getExplainOther());
$doc = $result->getExplainOther()->getDocument('IW-02');
$this->assertEquals(0.6, $doc->getValue());
$this->assertEquals(true, $doc->getMatch());
......@@ -158,10 +158,10 @@ class DebugTest extends \PHPUnit_Framework_TestCase
$timing = $result->getTiming();
$this->assertEquals(36, $timing->getTime());
$this->assertEquals(2, count($timing->getPhases()));
$this->assertCount(2, $timing->getPhases());
$phase = $timing->getPhase('process');
$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(3, $phase->getTiming('org.apache.solr.handler.component.MoreLikeThisComponent'));
}
......@@ -183,8 +183,8 @@ class DebugTest extends \PHPUnit_Framework_TestCase
$this->assertEquals('dummy-qp', $result->getQueryParser());
$this->assertEquals('dummy-oq', $result->getOtherQuery());
$this->assertEquals(0, count($result->getExplain()));
$this->assertEquals(0, count($result->getExplainOther()));
$this->assertCount(0, $result->getExplain());
$this->assertCount(0, $result->getExplainOther());
}
public function testParseNoData()
......
......@@ -76,6 +76,6 @@ class StatsTest extends \PHPUnit_Framework_TestCase
public function testParseNoData()
{
$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
public function testPropertyEmpty()
{
$this->assertTrue(
empty($this->doc->empty_field)
);
$this->assertFalse(
empty($this->doc->categories)
);
$this->assertEmpty($this->doc->empty_field);
$this->assertNotEmpty($this->doc->categories);
}
public function testSetField()
......@@ -124,13 +119,8 @@ abstract class AbstractDocumentTest extends \PHPUnit_Framework_TestCase
public function testArrayEmpty()
{
$this->assertTrue(
empty($this->doc['empty_field'])
);
$this->assertFalse(
empty($this->doc['categories'])
);
$this->assertEmpty($this->doc['empty_field']);
$this->assertNotEmpty($this->doc['categories']);
}
public function testArraySet()
......
......@@ -85,7 +85,7 @@ class ResponseParserTest extends \PHPUnit_Framework_TestCase
);
$this->assertEquals($expected, $result['results']);
$this->assertEquals(2, count($result['results']));
$this->assertCount(2, $result['results']);
}
public function testParseSolr14Format()
......@@ -139,6 +139,6 @@ class ResponseParserTest extends \PHPUnit_Framework_TestCase
);
$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