Refactoring tests

This commit is contained in:
Gabriel Caruso authored and Adrien Loison committed 2017-12-15 10:09:18 +01:00
1 parent 9f4e28b3fd
commit 4c7adbb33f
16 files changed
+52 -52

No files matched your search

@@ -39,7 +39,7 @@ class StyleRegistryTest extends TestCase
$styleRegistry->registerStyle($styleOrangeBold);
$styleRegistry->registerStyle($styleNoBackgroundColor);
$this->assertEquals(2, count($styleRegistry->getRegisteredFills()), 'There should be 2 registered fills');
$this->assertCount(2, $styleRegistry->getRegisteredFills(), 'There should be 2 registered fills');
$this->assertEquals(2, $styleRegistry->getFillIdForStyleId($styleBlack->getId()), 'First style with background color set should have index 2 (0 and 1 being reserved)');
$this->assertEquals(3, $styleRegistry->getFillIdForStyleId($styleOrange->getId()), 'Second style with background color set - different from first style - should have index 3');
@@ -67,7 +67,7 @@ class StyleRegistryTest extends TestCase
$styleRegistry->registerStyle($styleBoderRightBold);
$styleRegistry->registerStyle($styleNoBorder);
$this->assertEquals(2, count($styleRegistry->getRegisteredBorders()), 'There should be 2 registered borders');
$this->assertCount(2, $styleRegistry->getRegisteredBorders(), 'There should be 2 registered borders');
$this->assertEquals(1, $styleRegistry->getBorderIdForStyleId($styleBorderLeft->getId()), 'First style with border set should have index 1 (0 is for the default style)');
$this->assertEquals(2, $styleRegistry->getBorderIdForStyleId($styleBoderRight->getId()), 'Second style with border set - different from first style - should have index 2');
+2 -2
View File
@@ -25,7 +25,7 @@ class SheetTest extends TestCase
{
$sheets = $this->writeDataToMultipleSheetsAndReturnSheets('test_get_sheet_index.xlsx');
$this->assertEquals(2, count($sheets), '2 sheets should have been created');
$this->assertCount(2, $sheets, '2 sheets should have been created');
$this->assertEquals(0, $sheets[0]->getIndex(), 'The first sheet should be index 0');
$this->assertEquals(1, $sheets[1]->getIndex(), 'The second sheet should be index 1');
}
@@ -37,7 +37,7 @@ class SheetTest extends TestCase
{
$sheets = $this->writeDataToMultipleSheetsAndReturnSheets('test_get_sheet_name.xlsx');
$this->assertEquals(2, count($sheets), '2 sheets should have been created');
$this->assertCount(2, $sheets, '2 sheets should have been created');
$this->assertEquals('Sheet1', $sheets[0]->getName(), 'Invalid name for the first sheet');
$this->assertEquals('Sheet2', $sheets[1]->getName(), 'Invalid name for the second sheet');
}
+3 -3
View File
@@ -190,7 +190,7 @@ class WriterTest extends TestCase
$writer->close();
$sheets = $writer->getSheets();
$this->assertEquals(2, count($sheets), 'There should be 2 sheets');
$this->assertCount(2, $sheets, 'There should be 2 sheets');
$this->assertEquals($sheets[1], $writer->getCurrentSheet(), 'The current sheet should be the second one.');
}
@@ -454,7 +454,7 @@ class WriterTest extends TestCase
\ReflectionHelper::setStaticValue('\Box\Spout\Writer\XLSX\Manager\WorkbookManager', 'maxRowsPerWorksheet', 2);
$writer = $this->writeToXLSXFile($dataRows, $fileName, true, $shouldCreateSheetsAutomatically = true);
$this->assertEquals(2, count($writer->getSheets()), '2 sheets should have been created.');
$this->assertCount(2, $writer->getSheets(), '2 sheets should have been created.');
$this->assertInlineDataWasNotWrittenToSheet($fileName, 1, 'xlsx--sheet2--11');
$this->assertInlineDataWasWrittenToSheet($fileName, 2, 'xlsx--sheet2--11');
@@ -478,7 +478,7 @@ class WriterTest extends TestCase
\ReflectionHelper::setStaticValue('\Box\Spout\Writer\XLSX\Manager\WorkbookManager', 'maxRowsPerWorksheet', 2);
$writer = $this->writeToXLSXFile($dataRows, $fileName, true, $shouldCreateSheetsAutomatically = false);
$this->assertEquals(1, count($writer->getSheets()), 'Only 1 sheet should have been created.');
$this->assertCount(1, $writer->getSheets(), 'Only 1 sheet should have been created.');
$this->assertInlineDataWasNotWrittenToSheet($fileName, 1, 'xlsx--sheet1--31');
@@ -137,7 +137,7 @@ class WriterWithStyleTest extends TestCase
$this->writeToXLSXFile($dataRows, $fileName);
$cellDomElements = $this->getCellElementsFromSheetXmlFile($fileName);
$this->assertEquals(3, count($cellDomElements), 'There should be 3 cells.');
$this->assertCount(3, $cellDomElements, 'There should be 3 cells.');
$this->assertEquals('1', $cellDomElements[0]->getAttribute('s'));
$this->assertEquals('2', $cellDomElements[1]->getAttribute('s'));
@@ -171,7 +171,7 @@ class WriterWithStyleTest extends TestCase
// The first and second rows should not have a reference to the empty cell
// The other rows should have the reference because style should be applied to them
// So that's: 2 + 2 + 3 + 3 = 10 cells
$this->assertEquals(10, count($cellDomElements));
$this->assertCount(10, $cellDomElements);
// First row has 2 styled cells
$this->assertEquals('0', $cellDomElements[0]->getAttribute('s'));
@@ -499,9 +499,9 @@ class WriterWithStyleTest extends TestCase
$shouldApplyBorder = ((int) $node->getAttribute('applyBorder') === 1);
if ($shouldApplyBorder) {
$bordersApplied++;
$this->assertTrue((int) $node->getAttribute('borderId') > 0, 'BorderId is greater than 0');
$this->assertGreaterThan(0, (int) $node->getAttribute('borderId'), 'BorderId is greater than 0');
} else {
$this->assertTrue((int) $node->getAttribute('borderId') === 0, 'BorderId is 0');
$this->assertSame(0, (int) $node->getAttribute('borderId'), 'BorderId is 0');
}
}