Skip to content

Commit bd9682c

Browse files
committed
use assertCount
1 parent 18abb37 commit bd9682c

17 files changed

+47
-47
lines changed

tests/05_Reading/NodeReadMethodsTest.php

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ public function testGetNodesNameGlobs()
231231
/** @var $n \PHPCR\NodeInterface */
232232
array_push($nodes, $n->getName());
233233
}
234-
$this->assertEquals(2, count($nodes));
234+
$this->assertCount(2, $nodes);
235235
$this->assertContains('idExample', $nodes);
236236
$this->assertContains('test:namespacedNode', $nodes);
237237
$this->assertNotContains('jcr:content', $nodes); //jrc:content is not immediate child
@@ -390,7 +390,7 @@ public function testGetPropertiesValuesGlob()
390390
} elseif (count($props) == 2) {
391391
$this->assertArrayHasKey('jcr:primaryType', $props);
392392
$this->assertArrayHasKey('jcr:mixinTypes', $props);
393-
$this->assertEquals(0, count($props['jcr:mixinTypes']));
393+
$this->assertCount(0, $props['jcr:mixinTypes']);
394394
} else {
395395
$this->fail('wrong number of properties starting with jcr:');
396396
}
@@ -462,7 +462,7 @@ public function testGetReferencesAll()
462462
$this->assertInstanceOf('Iterator', $iterator);
463463

464464
//there are two nodes with reference to idExample.
465-
$this->assertEquals(2, count($iterator), "Wrong number of references to idExample");
465+
$this->assertCount(2, $iterator, "Wrong number of references to idExample");
466466
foreach ($iterator as $prop) {
467467
$this->assertInstanceOf('\PHPCR\PropertyInterface', $prop);
468468
$this->assertTrue(in_array($prop, $source));
@@ -481,7 +481,7 @@ public function testGetReferencesOnNonReferencedNode()
481481
$this->assertInstanceOf('Iterator', $iterator);
482482

483483
//there is no node with reference to numberPropertyNode.
484-
$this->assertEquals(0, count($iterator), "Wrong number of references to numberPropertyNode");
484+
$this->assertCount(0, $iterator, "Wrong number of references to numberPropertyNode");
485485
}
486486

487487
/**
@@ -496,7 +496,7 @@ public function testGetReferencesName()
496496
$this->assertInstanceOf('Iterator', $iterator);
497497

498498
//there is exactly one node with reference to idExample.
499-
$this->assertEquals(1, count($iterator), "Wrong number of references with name ref to idExample");
499+
$this->assertCount(1, $iterator, "Wrong number of references with name ref to idExample");
500500
foreach ($iterator as $prop) {
501501
$this->assertInstanceOf('\PHPCR\PropertyInterface', $prop);
502502
$this->assertEquals($source, $prop);
@@ -515,7 +515,7 @@ public function testGetReferencesNonexistingName()
515515
$target = $this->rootNode->getNode('tests_general_base/idExample');
516516
$iterator = $target->getReferences('notexisting');
517517
$this->assertInstanceOf('Iterator', $iterator);
518-
$this->assertEquals(0, count($iterator), "Wrong number of references with name notexisting to idExample");
518+
$this->assertCount(0, $iterator, "Wrong number of references with name notexisting to idExample");
519519
}
520520

521521
/**
@@ -530,7 +530,7 @@ public function testGetWeakReferencesAll()
530530
$iterator = $target->getWeakReferences();
531531
$this->assertInstanceOf('Iterator', $iterator);
532532

533-
$this->assertEquals(2, count($iterator), "Wrong number of weak references to weakreference_target");
533+
$this->assertCount(2, $iterator, "Wrong number of weak references to weakreference_target");
534534
foreach ($iterator as $prop) {
535535
$this->assertInstanceOf('\PHPCR\PropertyInterface', $prop);
536536
$this->assertTrue(in_array($prop, $source, true));
@@ -548,7 +548,7 @@ public function testGetWeakReferencesName()
548548
$iterator = $target->getWeakReferences('ref1');
549549
$this->assertInstanceOf('Iterator', $iterator);
550550

551-
$this->assertEquals(1, count($iterator), "Wrong number of weak references to weakreference_target");
551+
$this->assertCount(1, $iterator, "Wrong number of weak references to weakreference_target");
552552
foreach ($iterator as $prop) {
553553
$this->assertInstanceOf('\PHPCR\PropertyInterface', $prop);
554554
$this->assertEquals($prop, $source);
@@ -565,7 +565,7 @@ public function testGetWeakReferencesNonExistingName()
565565
$iterator = $target->getWeakReferences('unexisting_name');
566566
$this->assertInstanceOf('Iterator', $iterator);
567567

568-
$this->assertEquals(0, count($iterator), "Wrong number of weak references to weakreference_target");
568+
$this->assertCount(0, $iterator, "Wrong number of weak references to weakreference_target");
569569
}
570570

571571
/**
@@ -579,7 +579,7 @@ public function testGetWeakReferencesOnNonReferencedNode()
579579
$this->assertInstanceOf('Iterator', $iterator);
580580

581581
//there is no node with reference to numberPropertyNode.
582-
$this->assertEquals(0, count($iterator), "Wrong number of references to numberPropertyNode");
582+
$this->assertCount(0, $iterator, "Wrong number of references to numberPropertyNode");
583583
}
584584

585585
public function testGetSharedSetUnreferenced()

tests/05_Reading/PropertyReadMethodsTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -337,7 +337,7 @@ public function testGetBooleanMulti()
337337
foreach ($arr as $v) {
338338
$this->assertInternalType('boolean', $v);
339339
}
340-
$this->assertEquals(2, count($arr));
340+
$this->assertCount(2, $arr);
341341
$this->assertFalse($arr[0]);
342342
$this->assertTrue($arr[1]);
343343
}
@@ -426,7 +426,7 @@ public function testGetPropertyMulti()
426426
{
427427
$propertyPath = $this->node->getNode('numberPropertyNode/jcr:content')->getProperty('multiPropertyPath');
428428
$properties = $propertyPath->getProperty();
429-
$this->assertEquals(2, count($properties));
429+
$this->assertCount(2, $properties);
430430
foreach ($properties as $prop) {
431431
$this->assertInstanceOf('PHPCR\PropertyInterface', $prop);
432432
}

tests/06_Query/QOM/Sql2ToQomConverterTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public function testColumnsAndSelector()
4444

4545
$cols = $query->getColumns();
4646
$this->assertTrue(is_array($cols));
47-
$this->assertEquals(2, count($cols));
47+
$this->assertCount(2, $cols);
4848

4949
$this->assertEquals('u', $cols[0]->getselectorName());
5050
$this->assertEquals('prop1', $cols[0]->getPropertyName());

tests/06_Query/QueryObjectQOMTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public function testExecute()
5151
{
5252
$qr = $this->query->execute();
5353
$this->assertInstanceOf('PHPCR\Query\QueryResultInterface', $qr);
54-
$this->assertEquals(5, count($qr->getRows()));
54+
$this->assertCount(5, $qr->getRows());
5555
// we assume content is the same as for sql2
5656
}
5757

tests/06_Query/QueryResultsTest.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ public function testGetNodesAtOnce()
9898

9999
$keys[] = $path;
100100
}
101-
$this->assertEquals(8, count($keys));
101+
$this->assertCount(8, $keys);
102102

103103
$this->assertContains('/tests_general_base/idExample/jcr:content/Test escaping_x0020bla <>\'" node', $keys);
104104
}
@@ -159,7 +159,7 @@ public function testCompareNumberFields()
159159
$rows[] = $row;
160160
}
161161

162-
$this->assertEquals(1, count($rows));
162+
$this->assertCount(1, $rows);
163163
$this->assertEquals(10, $rows[0]->getValue('data.longNumberToCompare'));
164164
}
165165

@@ -176,7 +176,7 @@ public function testCompareStringFields()
176176
$rows[] = $row;
177177
}
178178

179-
$this->assertEquals(1, count($rows));
179+
$this->assertCount(1, $rows);
180180
$this->assertEquals(2, $rows[0]->getValue('data.stringToCompare'));
181181
}
182182

@@ -193,7 +193,7 @@ public function testBooleanField()
193193
$rows[] = $row;
194194
}
195195

196-
$this->assertEquals(1, count($rows));
196+
$this->assertCount(1, $rows);
197197
$this->assertEquals(false, $rows[0]->getValue('data.thisIsNo'));
198198

199199
$query = $this->sharedFixture['qm']->createQuery(
@@ -207,7 +207,7 @@ public function testBooleanField()
207207
$rows[] = $row;
208208
}
209209

210-
$this->assertEquals(1, count($rows));
210+
$this->assertCount(1, $rows);
211211
$this->assertEquals(true, $rows[0]->getValue('data.thisIsYes'));
212212
}
213213
}

tests/06_Query/QuerySql2OperationsTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,14 +57,14 @@ public function testQueryFieldSomeNull()
5757
$vals[] = ($node->hasProperty('foo') ? $node->getPropertyValue('foo') : null);
5858
}
5959
$this->assertContains('bar', $vals);
60-
$this->assertEquals(9, count($vals));
60+
$this->assertCount(9, $vals);
6161

6262
$vals = array();
6363
foreach ($result->getRows() as $row) {
6464
$vals[] = $row->getValue('foo');
6565
}
6666
$this->assertContains('bar', $vals);
67-
$this->assertEquals(9, count($vals));
67+
$this->assertCount(9, $vals);
6868
}
6969

7070
public function testQueryFieldSelector()

tests/06_Query/RowIteratorTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ public function setUp()
1515
parent::setUp();
1616

1717
$this->rowIterator = $this->query->execute()->getRows();
18-
$this->assertEquals(5, count($this->rowIterator));
18+
$this->assertCount(5, $this->rowIterator);
1919
}
2020

2121
public function testIterator()
@@ -25,7 +25,7 @@ public function testIterator()
2525
foreach ($this->rowIterator as $key => $row) {
2626
$this->assertInstanceOf('PHPCR\Query\RowInterface', $row); // Test if the return element is an istance of row
2727
$this->assertInstanceOf('PHPCR\NodeInterface', $row->getNode()); //Test if we can get the node of a certain row
28-
$this->assertEquals(3, count($row->getValues())); // test if we can get all the values of a row
28+
$this->assertCount(3, $row->getValues()); // test if we can get all the values of a row
2929

3030
foreach ($row as $key => $value) { // Test if we can iterate over the columns inside a row
3131
$count++;

tests/06_Query/Sql1/QueryOperationsTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,14 +53,14 @@ public function testQueryFieldSomenull()
5353
$vals[] = ($node->hasProperty('foo') ? $node->getPropertyValue('foo') : null);
5454
}
5555
$this->assertContains('bar', $vals);
56-
$this->assertEquals(9, count($vals));
56+
$this->assertCount(9, $vals);
5757

5858
$vals = array();
5959
foreach ($result->getRows() as $row) {
6060
$vals[] = $row->getValue('foo');
6161
}
6262
$this->assertContains('bar', $vals);
63-
$this->assertEquals(9, count($vals));
63+
$this->assertCount(9, $vals);
6464
}
6565

6666
public function testQueryOrder()

tests/06_Query/XPath/QueryOperationsTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,14 +50,14 @@ public function testQueryFieldSomenull()
5050
$vals[] = ($node->hasProperty('foo') ? $node->getPropertyValue('foo') : null);
5151
}
5252
$this->assertContains('bar', $vals);
53-
$this->assertEquals(9, count($vals));
53+
$this->assertCount(9, $vals);
5454

5555
$vals = array();
5656
foreach ($result->getRows() as $row) {
5757
$vals[] = $row->getValue('foo');
5858
}
5959
$this->assertContains('bar', $vals);
60-
$this->assertEquals(9, count($vals));
60+
$this->assertCount(9, $vals);
6161
}
6262

6363
public function testQueryOrder()

tests/08_NodeTypeDiscovery/NodeDefinitionTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,14 @@ public function setUp()
3232
try {
3333
$defs = self::$file->getChildNodeDefinitions();
3434
$this->assertInternalType('array', $defs);
35-
$this->assertEquals(1, count($defs));
35+
$this->assertCount(1, $defs);
3636
list($key, $this->content) = each($defs);
3737
$this->assertInstanceOf('\PHPCR\NodeType\NodeDefinitionInterface', $this->content);
3838
$this->assertEquals('jcr:content', $this->content->getName());
3939

4040
$defs = self::$folder->getChildNodeDefinitions();
4141
$this->assertInternalType('array', $defs);
42-
$this->assertEquals(1, count($defs));
42+
$this->assertCount(1, $defs);
4343
list($key, $this->hierarchyNodeDef) = each($defs);
4444
$this->assertInstanceOf('\PHPCR\NodeType\NodeDefinitionInterface', $this->hierarchyNodeDef);
4545
$this->assertEquals('*', $this->hierarchyNodeDef->getName());

0 commit comments

Comments
 (0)