Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
X
xls_serialization
Manage
Activity
Members
Labels
Plan
Wiki
Custom issue tracker
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
project
xls_serialization
Commits
5bfd013e
Commit
5bfd013e
authored
1 year ago
by
Jonathan Hedstrom
Browse files
Options
Downloads
Patches
Plain Diff
Issue
#3395395
by jhedstrom: Tests are failing on 10.1
parent
bbd22909
No related branches found
No related tags found
1 merge request
!13
Issue #3395395: Tests are failing on 10.1
Pipeline
#37610
passed with warnings
1 year ago
Stage: build
Stage: validate
Stage: test
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/Encoder/Xls.php
+2
-2
2 additions, 2 deletions
src/Encoder/Xls.php
tests/src/Unit/Encoder/XlsTest.php
+19
-0
19 additions, 0 deletions
tests/src/Unit/Encoder/XlsTest.php
with
21 additions
and
2 deletions
src/Encoder/Xls.php
+
2
−
2
View file @
5bfd013e
...
...
@@ -176,7 +176,7 @@ class Xls implements EncoderInterface {
// Extract headers from the data.
$headers
=
$this
->
extractHeaders
(
$data
,
$context
);
foreach
(
$headers
as
$column
=>
$header
)
{
$sheet
->
setCellValue
(
++
$column
,
1
,
$this
->
formatValue
(
$header
));
$sheet
->
setCellValue
(
[
++
$column
,
1
]
,
$this
->
formatValue
(
$header
));
}
}
...
...
@@ -268,7 +268,7 @@ class Xls implements EncoderInterface {
$column
=
1
;
foreach
(
$row
as
$value
)
{
// Since headers have been added, rows are offset here by 2.
$sheet
->
setCellValue
(
$column
,
$i
+
2
,
$this
->
formatValue
(
$value
));
$sheet
->
setCellValue
(
[
$column
,
$i
+
2
]
,
$this
->
formatValue
(
$value
));
$column
++
;
}
}
...
...
This diff is collapsed.
Click to expand it.
tests/src/Unit/Encoder/XlsTest.php
+
19
−
0
View file @
5bfd013e
...
...
@@ -2,10 +2,13 @@
namespace
Drupal\Tests\xls_serialization\Unit\Encoder
;
use
Drupal\Core\Config\ConfigFactoryInterface
;
use
Drupal\Core\Config\ImmutableConfig
;
use
Drupal\Tests\UnitTestCase
;
use
Drupal\xls_serialization
\Encoder\Xls
;
use
PhpOffice\PhpSpreadsheet\IOFactory
;
use
PhpOffice\PhpSpreadsheet\Shared\File
;
use
Symfony\Component\DependencyInjection\ContainerInterface
;
/**
* Tests the XLS encoder.
...
...
@@ -16,6 +19,22 @@ use PhpOffice\PhpSpreadsheet\Shared\File;
*/
class
XlsTest
extends
UnitTestCase
{
/**
* {@inheritdoc}
*/
protected
function
setUp
():
void
{
parent
::
setUp
();
// The global \Drupal::config method is used within the encoder.
// @todo The config service should be injected instead.
$config
=
$this
->
prophesize
(
ImmutableConfig
::
class
);
$config_factory
=
$this
->
prophesize
(
ConfigFactoryInterface
::
class
);
$config_factory
->
get
(
'xls_serialization.configuration'
)
->
willReturn
(
$config
->
reveal
());
$container
=
$this
->
prophesize
(
ContainerInterface
::
class
);
$container
->
get
(
'config.factory'
)
->
willReturn
(
$config_factory
->
reveal
());
\Drupal
::
setContainer
(
$container
->
reveal
());
}
/**
* @covers ::supportsEncoding
*/
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment