Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Open sidebar
project
migrate_spreadsheet
Commits
cffc6aa7
Commit
cffc6aa7
authored
Oct 07, 2020
by
claudiu.cristea
Committed by
claudiu.cristea
Oct 07, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Issue
#3175258
by claudiu.cristea: Fix tests for branch 2.0.x
parent
c826ca6f
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
23 deletions
+20
-23
tests/src/Unit/SpreadsheetIteratorTest.php
tests/src/Unit/SpreadsheetIteratorTest.php
+20
-23
No files found.
tests/src/Unit/SpreadsheetIteratorTest.php
View file @
cffc6aa7
<?php
declare
(
strict_types
=
1
);
namespace
Drupal\Tests\migrate_spreadsheet\Unit
;
use
Drupal\migrate_spreadsheet
\
SpreadsheetIterator
;
use
Drupal\Tests\UnitTestCase
;
use
PhpOffice\PhpSpreadsheet\Spreadsheet
;
use
PhpOffice\PhpSpreadsheet\Worksheet\Worksheet
;
use
PHPUnit\Framework\TestCase
;
/**
* Tests the spreadsheet iterator.
...
...
@@ -13,7 +16,7 @@ use PhpOffice\PhpSpreadsheet\Spreadsheet;
*
* @group migrate_spreadsheet
*/
class
SpreadsheetIteratorTest
extends
Unit
TestCase
{
class
SpreadsheetIteratorTest
extends
TestCase
{
/**
* A worksheet.
...
...
@@ -32,7 +35,7 @@ class SpreadsheetIteratorTest extends UnitTestCase {
/**
* {@inheritdoc}
*/
protected
function
setUp
()
{
protected
function
setUp
()
:
void
{
parent
::
setUp
();
$this
->
iterator
=
(
new
SpreadsheetIterator
())
...
...
@@ -48,7 +51,7 @@ class SpreadsheetIteratorTest extends UnitTestCase {
* @covers ::getRowsCount
* @covers ::getColumnsCount
*/
public
function
testRowsAndColumnsCount
()
{
public
function
testRowsAndColumnsCount
()
:
void
{
$this
->
assertEquals
(
5
,
$this
->
iterator
->
getRowsCount
());
$this
->
assertEquals
(
7
,
$this
->
iterator
->
getColumnsCount
());
}
...
...
@@ -62,11 +65,11 @@ class SpreadsheetIteratorTest extends UnitTestCase {
* @param bool $expect_exception
* If a exception is expected.
*/
public
function
testGetOrigin
(
$origin
,
$expect_exception
)
{
public
function
testGetOrigin
(
string
$origin
,
bool
$expect_exception
)
:
void
{
$config
=
[
'origin'
=>
$origin
]
+
$this
->
iterator
->
getConfiguration
();
$this
->
iterator
->
setConfiguration
(
$config
);
if
(
$expect_exception
)
{
$this
->
setE
xpect
ed
Exception
(
'
InvalidArgumentException
'
);
$this
->
e
xpectException
(
\
InvalidArgumentException
::
class
);
}
$this
->
assertEquals
(
$origin
,
$this
->
iterator
->
getOrigin
());
}
...
...
@@ -77,27 +80,21 @@ class SpreadsheetIteratorTest extends UnitTestCase {
* @return array[]
* A list of test parameters to be passed to ::testGetOrigin().
*/
public
function
providerTestGetException
()
{
public
function
providerTestGetException
()
:
array
{
return
[
// The minimum valid origin.
[
'A1'
,
FALSE
],
// A valid origin.
[
'B3'
,
FALSE
],
// Column out of bounds.
[
'H3'
,
TRUE
],
// Row out of bounds.
[
'E6'
,
TRUE
],
// Both, row and column, out of bounds.
[
'H6'
,
TRUE
],
// The maximum valid value.
[
'G5'
,
FALSE
],
'The minimum valid origin'
=>
[
'A1'
,
FALSE
],
'A valid origin'
=>
[
'B3'
,
FALSE
],
'Column out of bounds'
=>
[
'H3'
,
TRUE
],
'Row out of bounds'
=>
[
'E6'
,
TRUE
],
'Both, row and column, out of bounds'
=>
[
'H6'
,
TRUE
],
'The maximum valid value'
=>
[
'G5'
,
FALSE
],
];
}
/**
* @covers ::getHeaders
*/
public
function
testGetHeaders
()
{
public
function
testGetHeaders
()
:
void
{
$cols
=
[
'column b'
=>
'B'
,
'column c'
=>
'C'
,
...
...
@@ -124,14 +121,14 @@ class SpreadsheetIteratorTest extends UnitTestCase {
$this
->
getWorksheet
()
->
setCellValue
(
'C2'
,
'column b'
);
$config
[
'header_row'
]
=
2
;
$this
->
iterator
->
setConfiguration
(
$config
);
$this
->
setE
xpect
ed
Exception
(
'RuntimeException'
);
$this
->
e
xpectException
(
'RuntimeException'
);
$this
->
iterator
->
getHeaders
();
}
/**
* @covers ::current
*/
public
function
testIteration
()
{
public
function
testIteration
()
:
void
{
$config
=
$this
->
iterator
->
getConfiguration
();
$config
[
'row_index_column'
]
=
'row'
;
$this
->
iterator
->
setConfiguration
(
$config
);
...
...
@@ -232,7 +229,7 @@ class SpreadsheetIteratorTest extends UnitTestCase {
* @return \PhpOffice\PhpSpreadsheet\Worksheet\Worksheet
* A PhpSpreadsheet worksheet object.
*/
protected
function
getWorksheet
()
{
protected
function
getWorksheet
()
:
Worksheet
{
if
(
!
isset
(
$this
->
worksheet
))
{
// Test case:
// - origin: B3;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment