Skip to content

Commit

Permalink
Written DataValidation was corrupted
Browse files Browse the repository at this point in the history
Fixes #290
  • Loading branch information
PowerKiKi committed Dec 16, 2017
1 parent 04a8ddf commit eb58563
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
### Fixed

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

### BREAKING CHANGE

Expand Down
4 changes: 2 additions & 2 deletions src/PhpSpreadsheet/Cell/DataValidation.php
Original file line number Diff line number Diff line change
Expand Up @@ -449,8 +449,8 @@ public function getHashCode()
return md5(
$this->formula1 .
$this->formula2 .
$this->type = self::TYPE_NONE .
$this->errorStyle = self::STYLE_STOP .
$this->type .
$this->errorStyle .
$this->operator .
($this->allowBlank ? 't' : 'f') .
($this->showDropDown ? 't' : 'f') .
Expand Down
19 changes: 19 additions & 0 deletions tests/PhpSpreadsheetTests/Cell/DataValidationTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php

namespace PhpOffice\PhpSpreadsheetTests\Cell;

use PhpOffice\PhpSpreadsheet\Cell\DataValidation;
use PHPUnit\Framework\TestCase;

class DataValidationTest extends TestCase
{
public function testNoValidation()
{
$dataValidation = new DataValidation();
self::assertSame('090624f04837265d79323c4a1b7e89d1', $dataValidation->getHashCode());
$dataValidation->setType(DataValidation::TYPE_CUSTOM);

self::assertSame('778f6c9e0ffcd5eaa7d8e1432d67f919', $dataValidation->getHashCode());
self::assertSame('778f6c9e0ffcd5eaa7d8e1432d67f919', $dataValidation->getHashCode(), 'getHashCode() should not have side effect');
}
}

0 comments on commit eb58563

Please sign in to comment.