diff --git a/.github/workflows/php.yml b/.github/workflows/php.yml index 9b259c42c4..f6211e31cd 100644 --- a/.github/workflows/php.yml +++ b/.github/workflows/php.yml @@ -93,3 +93,26 @@ jobs: wget https://github.com/php-coveralls/php-coveralls/releases/download/v2.4.3/php-coveralls.phar chmod +x php-coveralls.phar php php-coveralls.phar --coverage_clover=build/clover.xml --json_path=build/coveralls-upload.json -vvv + + samples: + name: Check samples + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + php: ['7.1', '7.2', '7.3', '7.4', '8.0', '8.1'] + steps: + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php }} + extensions: gd, xml, zip + coverage: xdebug + + - uses: actions/checkout@v2 + + - name: Composer Install + run: composer install --ansi --prefer-dist --no-interaction --no-progress + + - name: Generate samples files + run: composer run samples diff --git a/composer.json b/composer.json index ab4a5dd19f..6052836d6e 100644 --- a/composer.json +++ b/composer.json @@ -37,5 +37,31 @@ "psr-4": { "PhpOffice\\PhpPresentation\\": "src/PhpPresentation/" } + }, + "scripts": { + "samples": [ + "php samples/Sample_01_Complex.php", + "php samples/Sample_01_Simple.php", + "php samples/Sample_03_Image.php", + "php samples/Sample_03_Video.php", + "php samples/Sample_04_Table.php", + "php samples/Sample_05_Chart_Line.php", + "php samples/Sample_05_Chart.php", + "php samples/Sample_05_Chart_with_PhpSpreadsheet.php", + "php samples/Sample_06_Fill.php", + "php samples/Sample_07_Border.php", + "php samples/Sample_08_Group.php", + "php samples/Sample_09_SlideNote.php", + "php samples/Sample_10_Transition.php", + "php samples/Sample_11_Shape.php", + "php samples/Sample_13_MarkAsFinal.php", + "php samples/Sample_14_Zoom.php", + "php samples/Sample_15_Background.php", + "php samples/Sample_16_Thumbnail.php", + "php samples/Sample_17_Comment.php", + "php samples/Sample_18_Animation.php", + "php samples/Sample_19_SlideMaster.php", + "php samples/Sample_20_ExternalSlide.php" + ] } } diff --git a/samples/Sample_03_Video.php b/samples/Sample_03_Video.php index 3998f750ce..c28892c0f7 100644 --- a/samples/Sample_03_Video.php +++ b/samples/Sample_03_Video.php @@ -17,7 +17,10 @@ $shape = new Media(); $shape->setName('Video') ->setDescription('Video') - ->setPath('WIN' === strtoupper(substr(PHP_OS, 0, 3)) ? './resources/sintel_trailer-480p.wmv' : './resources/sintel_trailer-480p.ogv') + ->setPath( + __DIR__ . '/resources/sintel_trailer-480p' . + ('WIN' === strtoupper(substr(PHP_OS, 0, 3)) ? '.wmv' : '.ogv') + ) ->setResizeProportional(false) ->setHeight(90) ->setWidth(90) diff --git a/samples/Sample_08_Group.php b/samples/Sample_08_Group.php index b87b50b7b5..f22196696f 100644 --- a/samples/Sample_08_Group.php +++ b/samples/Sample_08_Group.php @@ -29,7 +29,7 @@ $shape = $currentGroup->createDrawingShape(); $shape->setName('PHPPresentation logo') ->setDescription('PHPPresentation logo') - ->setPath('./resources/phppowerpoint_logo.gif') + ->setPath(__DIR__ . '/resources/phppowerpoint_logo.gif') ->setHeight(36) ->setOffsetX(10) ->setOffsetY(10); diff --git a/samples/Sample_09_SlideNote.php b/samples/Sample_09_SlideNote.php index 8a597dfa08..641c778636 100644 --- a/samples/Sample_09_SlideNote.php +++ b/samples/Sample_09_SlideNote.php @@ -24,7 +24,7 @@ $shape = $currentSlide->createDrawingShape(); $shape->setName('PHPPresentation logo') ->setDescription('PHPPresentation logo') - ->setPath('./resources/phppowerpoint_logo.gif') + ->setPath(__DIR__ . '/resources/phppowerpoint_logo.gif') ->setHeight(36) ->setOffsetX(10) ->setOffsetY(10); diff --git a/samples/Sample_10_Transition.php b/samples/Sample_10_Transition.php index 58dcbab34b..7cb732ecb9 100644 --- a/samples/Sample_10_Transition.php +++ b/samples/Sample_10_Transition.php @@ -30,7 +30,7 @@ $shapeDrawing = $slide0->createDrawingShape(); $shapeDrawing->setName('PHPPresentation logo') ->setDescription('PHPPresentation logo') - ->setPath('./resources/phppowerpoint_logo.gif') + ->setPath(__DIR__ . '/resources/phppowerpoint_logo.gif') ->setHeight(36) ->setOffsetX(10) ->setOffsetY(10); diff --git a/samples/Sample_15_Background.php b/samples/Sample_15_Background.php index 8c78d2d501..74135eeceb 100644 --- a/samples/Sample_15_Background.php +++ b/samples/Sample_15_Background.php @@ -33,7 +33,7 @@ * @link : http://publicdomainarchive.com/public-domain-images-cave-red-rocks-light-beam-cavern/ */ $oBkgImage = new Image(); -$oBkgImage->setPath('./resources/background.jpg'); +$oBkgImage->setPath(__DIR__ . '/resources/background.jpg'); $oSlide2->setBackground($oBkgImage); // Save file diff --git a/samples/Sample_19_SlideMaster.php b/samples/Sample_19_SlideMaster.php index ef1ac4b52b..d72b2488b4 100644 --- a/samples/Sample_19_SlideMaster.php +++ b/samples/Sample_19_SlideMaster.php @@ -80,7 +80,7 @@ $shape = $currentSlide->createDrawingShape(); $shape->setName('PHPPresentation logo') ->setDescription('PHPPresentation logo') - ->setPath('./resources/phppowerpoint_logo.gif') + ->setPath(__DIR__ . '/resources/phppowerpoint_logo.gif') ->setHeight(36) ->setOffsetX(10) ->setOffsetY(10); diff --git a/samples/Sample_Header.php b/samples/Sample_Header.php index 308451e193..eb16a62a3c 100644 --- a/samples/Sample_Header.php +++ b/samples/Sample_Header.php @@ -45,11 +45,6 @@ // Set writers $writers = ['PowerPoint2007' => 'pptx', 'ODPresentation' => 'odp']; -// Return to the caller script when runs by CLI -if (CLI) { - return; -} - // Set titles and names $pageHeading = str_replace('_', ' ', SCRIPT_FILENAME); $pageTitle = IS_INDEX ? 'Welcome to ' : "{$pageHeading} - "; @@ -59,7 +54,7 @@ $oShapeDrawing = new Drawing\File(); $oShapeDrawing->setName('PHPPresentation logo') ->setDescription('PHPPresentation logo') - ->setPath('./resources/phppowerpoint_logo.gif') + ->setPath(__DIR__ . '/resources/phppowerpoint_logo.gif') ->setHeight(36) ->setOffsetX(10) ->setOffsetY(10); @@ -80,6 +75,11 @@ ->setSize(60) ->setColor(new Color('FFE06B20')); +// Return to the caller script when runs by CLI +if (CLI) { + return; +} + // Populate samples $files = []; if ($handle = opendir('.')) { diff --git a/samples/results/.gitkeep b/samples/results/.gitkeep new file mode 100644 index 0000000000..e69de29bb2 diff --git a/src/PhpPresentation/Writer/ODPresentation/ObjectsChart.php b/src/PhpPresentation/Writer/ODPresentation/ObjectsChart.php index 38c8057ae3..12ded07239 100644 --- a/src/PhpPresentation/Writer/ODPresentation/ObjectsChart.php +++ b/src/PhpPresentation/Writer/ODPresentation/ObjectsChart.php @@ -886,7 +886,7 @@ protected function writeTable(): void $this->xmlContent->writeAttributeIf($cellValueTypeFloat, 'office:value', is_null($cell) ? 'NaN' : $cell); // text:p $this->xmlContent->startElement('text:p'); - $this->xmlContent->text(is_null($cell) ? 'NaN' : $cell); + $this->xmlContent->text(is_null($cell) ? 'NaN' : (string) $cell); $this->xmlContent->endElement(); // > table:table-cell $this->xmlContent->endElement();