Skip to content

Commit eb58563

Browse files
committed
Written DataValidation was corrupted
Fixes #290
1 parent 04a8ddf commit eb58563

File tree

3 files changed

+22
-2
lines changed

3 files changed

+22
-2
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
1616
### Fixed
1717

1818
- Can read very small HTML files - [#194](https://github.com/PHPOffice/PhpSpreadsheet/issues/194)
19+
- Written DataValidation was corrupted - [#290](https://github.com/PHPOffice/PhpSpreadsheet/issues/290)
1920

2021
### BREAKING CHANGE
2122

src/PhpSpreadsheet/Cell/DataValidation.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -449,8 +449,8 @@ public function getHashCode()
449449
return md5(
450450
$this->formula1 .
451451
$this->formula2 .
452-
$this->type = self::TYPE_NONE .
453-
$this->errorStyle = self::STYLE_STOP .
452+
$this->type .
453+
$this->errorStyle .
454454
$this->operator .
455455
($this->allowBlank ? 't' : 'f') .
456456
($this->showDropDown ? 't' : 'f') .
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?php
2+
3+
namespace PhpOffice\PhpSpreadsheetTests\Cell;
4+
5+
use PhpOffice\PhpSpreadsheet\Cell\DataValidation;
6+
use PHPUnit\Framework\TestCase;
7+
8+
class DataValidationTest extends TestCase
9+
{
10+
public function testNoValidation()
11+
{
12+
$dataValidation = new DataValidation();
13+
self::assertSame('090624f04837265d79323c4a1b7e89d1', $dataValidation->getHashCode());
14+
$dataValidation->setType(DataValidation::TYPE_CUSTOM);
15+
16+
self::assertSame('778f6c9e0ffcd5eaa7d8e1432d67f919', $dataValidation->getHashCode());
17+
self::assertSame('778f6c9e0ffcd5eaa7d8e1432d67f919', $dataValidation->getHashCode(), 'getHashCode() should not have side effect');
18+
}
19+
}

0 commit comments

Comments
 (0)