Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
- Restricted `XMLReader::getElement` return type to `DOMElement|null` using `instanceof` check - @slayerfx GH-35
- Fixed date setters (`Task`, `DocumentInformations`, `DocumentProperties`) storing `strtotime()` `false` for unparseable date strings; now stored as `null` to match the typed `?int` getters (revealed by the samples job) - @slayerfx GH-45
- Fixed flaky date tests (`Task`, `DocumentInformations`, `DocumentProperties`) comparing two separate `time()` calls, which failed whenever the second changed between them; the argument-less setters are now asserted against a time range - @slayerfx GH-60
- Fixed `Reader/GnomePlanner` storing `percent-complete` as a raw 0-100 value, while `Task::setProgress()` expects a 0..1 fraction and clamps anything above 1; progress is now divided by 100, as in `Reader/MSPDI` - @slayerfx GH-61

### Miscellaneous
- Added ProjectLibre writer for `.pod` files (writes an embedded MSPDI part) - @slayerfx GH-58
Expand Down
2 changes: 1 addition & 1 deletion src/PhpProject/Reader/GnomePlanner.php
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ protected function readNodeTask(XMLReader $xml, \DOMElement $domNode, Task $task
$task->setDuration($domNode->getAttribute('work'));
}
if ($domNode->hasAttribute('percent-complete')) {
$task->setProgress($domNode->getAttribute('percent-complete'));
$task->setProgress((float) $domNode->getAttribute('percent-complete') / 100);
}

// SubNodes
Expand Down
23 changes: 23 additions & 0 deletions tests/PhpProject/Tests/Reader/GnomePlannerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@

namespace PhpOffice\PhpProject\Tests\Reader;

use PhpOffice\PhpProject\IOFactory;
use PhpOffice\PhpProject\PhpProject;
use PhpOffice\PhpProject\Reader\GnomePlanner;

/**
Expand Down Expand Up @@ -100,6 +102,27 @@ public function testLoad(): void
$this->assertEquals('Kurt Maute', $taskResources[1]->getTitle());
}

public function testLoadProgressRoundTrip(): void
{
$fileOutput = tempnam(sys_get_temp_dir(), 'PHPPROJECT');

$phpProject = new PhpProject();
$task = $phpProject->createTask();
$task->setName('ProgressTest');
$task->setProgress(0.5);

IOFactory::createWriter($phpProject, 'GnomePlanner')->save($fileOutput);

$object = new GnomePlanner();
$return = $object->load($fileOutput);

$tasks = $return->getAllTasks();
$this->assertCount(1, $tasks);
$this->assertEquals(0.5, $tasks[0]->getProgress());

unlink($fileOutput);
}

public function testLoadException(): void
{
$this->expectException(\Exception::class);
Expand Down