Skip to content
Snippets Groups Projects
Commit 5bfd013e authored by Jonathan Hedstrom's avatar Jonathan Hedstrom
Browse files

Issue #3395395 by jhedstrom: Tests are failing on 10.1

parent bbd22909
No related branches found
No related tags found
1 merge request!13Issue #3395395: Tests are failing on 10.1
Pipeline #37610 passed with warnings
......@@ -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++;
}
}
......
......@@ -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
*/
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment