Skip to content

Commit 19fb23f

Browse files
authored
Merge pull request #16 from luyadev/xlsx-test
add test
2 parents c709157 + 24f5bea commit 19fb23f

File tree

4 files changed

+34
-4
lines changed

4 files changed

+34
-4
lines changed

.github/workflows/tests.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ jobs:
8181
fail-fast: false
8282
matrix:
8383
os: [ubuntu-latest]
84-
php: ['7.2', '7.3', '7.4', '8.0', '8.1']
84+
php: ['7.2', '7.3', '7.4', '8.0', '8.1', '8.2']
8585

8686
steps:
8787
## checkout the repoistory
@@ -104,7 +104,7 @@ jobs:
104104
## run unit tests
105105
- name: PHP Unit tests for PHP
106106
run: vendor/bin/phpunit --verbose --configuration actions.phpunit.xml
107-
if: matrix.php == '7.2' || matrix.php == '7.3' || matrix.php == '8.1' || matrix.php == '8.0'
107+
if: matrix.php == '7.2' || matrix.php == '7.3' || matrix.php == '8.0' || matrix.php == '8.1' || matrix.php == '8.2'
108108

109109
## unit test with coverage
110110
- name: PHP Unit tests for PHP 7.4 Coverage

CHANGELOG.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,13 @@
22

33
All notable changes to this project will be documented in this file. This project adheres to [Semantic Versioning](http://semver.org/).
44

5+
## 1.4.2 (25. January 2022)
6+
7+
+ [#16](https://github.com/luyadev/yii-helpers/pull/16) Fix PHP 8.1 compatibility bug in `ExportHelper::xlsx()`.
8+
59
## 1.4.1 (18. January 2022)
610

7-
+ [#15](https://github.com/luyadev/yii-helpers/pull/15) Fix PHP 8.1 compatibility bug in `ArrayHelper::searchColumns()`
11+
+ [#15](https://github.com/luyadev/yii-helpers/pull/15) Fix PHP 8.1 compatibility bug in `ArrayHelper::searchColumns()`.
812

913
## 1.4.0 (20. October 2022)
1014

src/helpers/XLSXWriter.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -899,7 +899,7 @@ public static function xmlspecialchars($val)
899899
static $badchars = "\x00\x01\x02\x03\x04\x05\x06\x07\x08\x0b\x0c\x0e\x0f\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f\x7f";
900900
static $goodchars = " ";
901901
return strtr(
902-
htmlspecialchars($val, ENT_QUOTES | ENT_XML1),
902+
htmlspecialchars((string) $val, ENT_QUOTES | ENT_XML1),
903903
$badchars,
904904
$goodchars
905905
);//strtr appears to be faster than str_replace

tests/helpers/ExportHelperTest.php

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,4 +142,30 @@ public function testSpecialCharsEncoding()
142142

143143
$this->assertSameTrimmed('"&","\'","a""b""c" "nix","nix","\'=1+2"";=1+2"', $content);
144144
}
145+
146+
public function testXlsPhp81()
147+
{
148+
$data = [
149+
[
150+
'Datum' => '20.01.2023, 10:52:52',
151+
'Sprache' => 'de',
152+
'name' => 'TEST',
153+
'visit' => 'Sehr gut',
154+
'happiness' => 'Ja',
155+
'fragen' => '',
156+
'datenschutz' => 'Ja',
157+
],
158+
[
159+
'Datum' => '13.11.2022, 13:36:56',
160+
'Sprache' => 'de',
161+
'name' => 'TEST',
162+
'visit' => 'Sehr gut',
163+
'happiness' => 'Ja',
164+
'fragen' => '',
165+
'datenschutz' => 'Ja',
166+
],
167+
];
168+
169+
$this->assertNotEmpty(ExportHelper::xlsx($data, [], true, ['sort' => false]));
170+
}
145171
}

0 commit comments

Comments
 (0)