Skip to content

Commit 0ea2193

Browse files
author
Roman Syroeshko
committed
[CHANGED] Replaced "assertEquals" with "assertCount" where it was necessary.
1 parent d35db83 commit 0ea2193

File tree

6 files changed

+14
-18
lines changed

6 files changed

+14
-18
lines changed

tests/PhpWord/Tests/AutoloaderTest.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,11 @@ public function testRegister()
4343
*/
4444
public function testAutoload()
4545
{
46-
$declared = get_declared_classes();
47-
$declaredCount = count($declared);
46+
$declaredCount = count(get_declared_classes());
4847
Autoloader::autoload('Foo');
49-
$this->assertEquals(
48+
$this->assertCount(
5049
$declaredCount,
51-
count(get_declared_classes()),
50+
get_declared_classes(),
5251
'PhpOffice\\PhpWord\\Autoloader::autoload() is trying to load ' .
5352
'classes outside of the PhpOffice\\PhpWord namespace'
5453
);

tests/PhpWord/Tests/Collection/CollectionTest.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,7 @@ public function testCollection()
2828
$object->addItem(new Footnote()); // addItem #1
2929

3030
$this->assertEquals(2, $object->addItem(new Footnote())); // addItem #2. Should returns new item index
31-
$this->assertEquals(2, $object->countItems()); // There are two items now
32-
$this->assertEquals(2, count($object->getItems())); // getItems returns array
31+
$this->assertCount(2, $object->getItems()); // getItems returns array
3332
$this->assertInstanceOf('PhpOffice\\PhpWord\\Element\\Footnote', $object->getItem(1)); // getItem returns object
3433
$this->assertNull($object->getItem(3)); // getItem returns null when invalid index is referenced
3534

tests/PhpWord/Tests/MediaTest.php

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public function testGetSectionMediaElementsWithNull()
4040
*/
4141
public function testCountSectionMediaElementsWithNull()
4242
{
43-
$this->assertEquals(Media::countElements('section'), 0);
43+
$this->assertEquals(0, Media::countElements('section'));
4444
}
4545

4646
/**
@@ -57,7 +57,7 @@ public function testAddSectionMediaElement()
5757
Media::addElement('section', 'object', $object);
5858
Media::addElement('section', 'object', $object);
5959

60-
$this->assertEquals(3, Media::countElements('section'));
60+
$this->assertCount(3, Media::getElements('section'));
6161
}
6262

6363
/**
@@ -69,8 +69,7 @@ public function testAddSectionLinkElement()
6969
$actual = Media::addElement('section', 'link', 'http://test.com');
7070

7171
$this->assertEquals($expected, $actual);
72-
$this->assertEquals(1, Media::countElements('section', 'link'));
73-
$this->assertEquals(1, count(Media::getElements('section', 'link')));
72+
$this->assertCount(1, Media::getElements('section', 'link'));
7473
}
7574

7675
/**
@@ -84,8 +83,7 @@ public function testAddHeaderMediaElement()
8483
Media::addElement('header1', 'image', $local, new Image($local));
8584
Media::addElement('header1', 'image', $remote, new Image($remote));
8685

87-
$this->assertEquals(2, Media::countElements('header1'));
88-
$this->assertEquals(2, count(Media::getElements('header1')));
86+
$this->assertCount(2, Media::getElements('header1'));
8987
$this->assertEmpty(Media::getElements('header2'));
9088
}
9189

@@ -100,10 +98,10 @@ public function testAddFooterMediaElement()
10098
Media::addElement('footer1', 'image', $local, new Image($local));
10199
Media::addElement('footer1', 'image', $remote, new Image($remote));
102100

103-
$this->assertEquals(2, Media::countElements('footer1'));
101+
$this->assertCount(2, Media::getElements('footer1'));
104102

105103
Media::resetElements();
106-
$this->assertEquals(0, Media::countElements('footer1'));
104+
$this->assertCount(0, Media::getElements('footer1'));
107105
}
108106

109107
/**

tests/PhpWord/Tests/PhpWordTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public function testCreateGetSections()
4747
{
4848
$phpWord = new PhpWord();
4949
$phpWord->addSection();
50-
$this->assertEquals(1, count($phpWord->getSections()));
50+
$this->assertCount(1, $phpWord->getSections());
5151
}
5252

5353
/**

tests/PhpWord/Tests/Shared/HtmlTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public function testAddHtml()
3434

3535
// Default
3636
$section = new Section(1);
37-
$this->assertEquals(0, $section->countElements());
37+
$this->assertCount(0, $section->getElements());
3838

3939
// Heading
4040
$styles = array('strong', 'em', 'sup', 'sub');
@@ -52,7 +52,7 @@ public function testAddHtml()
5252

5353
// Add HTML
5454
Html::addHtml($section, $content);
55-
$this->assertEquals(7, $section->countElements());
55+
$this->assertCount(7, $section->getElements());
5656

5757
// Other parts
5858
$section = new Section(1);

tests/PhpWord/Tests/Style/ParagraphTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ public function testTabs()
119119
{
120120
$object = new Paragraph();
121121
$object->setTabs(array(new Tab('left', 1550), new Tab('right', 5300)));
122-
$this->assertEquals(2, count($object->getTabs()));
122+
$this->assertCount(2, $object->getTabs());
123123
}
124124

125125
/**

0 commit comments

Comments
 (0)