Skip to content

Commit

Permalink
PHPOffice#634 : Add support PHP 7.4 to 8.0 & Remove support PHP < 7.1
Browse files Browse the repository at this point in the history
  • Loading branch information
Progi1984 committed Jun 6, 2021
1 parent 8bf50ec commit 49312ba
Show file tree
Hide file tree
Showing 53 changed files with 257 additions and 382 deletions.
50 changes: 3 additions & 47 deletions .github/workflows/php.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,6 @@ jobs:
extensions: mbstring, intl, gd, xml, dom, json, fileinfo, curl, zip, iconv
- uses: actions/checkout@v2

- name: Get Composer Cache Directory
id: composer-cache
run: |
echo "::set-output name=dir::$(composer config cache-files-dir)"
- name: Cache Composer Directory
uses: actions/cache@v2
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-composer-
- name: Validate composer config
run: composer validate --strict

Expand All @@ -44,17 +33,6 @@ jobs:
extensions: gd, xml, zip
- uses: actions/checkout@v2

- name: Get Composer Cache Directory
id: composer-cache
run: |
echo "::set-output name=dir::$(composer config cache-files-dir)"
- name: Cache Composer Directory
uses: actions/cache@v2
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-composer-
- name: Composer Install
run: composer install --ansi --prefer-dist --no-interaction --no-progress

Expand All @@ -73,17 +51,6 @@ jobs:
extensions: gd, xml, zip
- uses: actions/checkout@v2

- name: Get Composer Cache Directory
id: composer-cache
run: |
echo "::set-output name=dir::$(composer config cache-files-dir)"
- name: Cache Composer Directory
uses: actions/cache@v2
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-composer-
- name: Composer Install
run: composer install --ansi --prefer-dist --no-interaction --no-progress

Expand All @@ -94,9 +61,9 @@ jobs:
name: PHPUnit
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
php: ['5.6', '7.0', '7.1', '7.2', '7.3']
## , '7.4', '8.0', '8.1'
php: ['7.1', '7.2', '7.3', '7.4', '8.0'] #, '8.1'
steps:
- name: Setup PHP
uses: shivammathur/setup-php@v2
Expand All @@ -107,25 +74,14 @@ jobs:

- uses: actions/checkout@v2

- name: Get Composer Cache Directory
id: composer-cache
run: |
echo "::set-output name=dir::$(composer config cache-files-dir)"
- name: Cache Composer Directory
uses: actions/cache@v2
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-composer-
- name: Composer Install
run: composer install --ansi --prefer-dist --no-interaction --no-progress

- name: Run phpunit
run: ./vendor/bin/phpunit -c phpunit.xml.dist --coverage-clover build/clover.xml

- name: Upload coverage results to Coveralls
if: matrix.php-versions == '7.3'
if: matrix.php == '7.3'
env:
COVERALLS_REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
Expand Down
8 changes: 1 addition & 7 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,10 @@
Thumbs.db
Desktop.ini

### IDE Jetbrains PhpStorm
.idea
### IDE Eclipse
*.settings
*.project
*.buildpath

### Continuous Integration
build/
phpunit.xml
.phpunit.result.cache
composer.phar
vendor
/batch_CI.bat
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ Read more about PHPPresentation:

PHPPresentation requires the following:

- PHP 5.3+
- PHP 7.1+
- [Zip extension](http://php.net/manual/en/book.zip.php)
- [XML Parser extension](http://www.php.net/manual/en/xml.installation.php)
- [XMLWriter extension](http://php.net/manual/en/book.xmlwriter.php) (optional, used to write DOCX and ODT)
Expand Down
12 changes: 4 additions & 8 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,15 @@
}
],
"require": {
"php": ">=5.3.0",
"php": "^7.1|^8.0",
"ext-xml": "*",
"ext-zip": "*",
"phpoffice/common": "0.2.*"
},
"require-dev": {
"phpunit/phpunit": "4.*|5.*|6.*|7.*",
"phpdocumentor/phpdocumentor":"2.*",
"phpmd/phpmd": "2.*",
"sebastian/phpcpd": "2.*",
"phploc/phploc": "2.*",
"squizlabs/php_codesniffer": "2.*",
"codeclimate/php-test-reporter": "dev-master"
"phpunit/phpunit": ">=7.0",
"phpdocumentor/phpdocumentor":"^2.0|^3.0",
"phpmd/phpmd": "2.*"
},
"suggest": {
"ext-gd": "Required to add images"
Expand Down
4 changes: 2 additions & 2 deletions samples/Sample_Header.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@
require_once __DIR__ . '/../src/PhpPresentation/Autoloader.php';
Autoloader::register();

if (is_file(__DIR__. '/../../../../vendor/autoload.php')) {
require_once __DIR__ . '/../../../../vendor/autoload.php';
if (is_file(dirname(__DIR__). '/vendor/autoload.php')) {
require_once dirname(__DIR__) . '/vendor/autoload.php';
} else {
throw new Exception ('Can not find the vendor folder!');
}
Expand Down
3 changes: 3 additions & 0 deletions src/PhpPresentation/Writer/Serialized.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@ public function save($pFilename)
if (empty($pFilename)) {
throw new \Exception("Filename is empty.");
}
if (!is_dir(dirname($pFilename))) {
throw new \Exception(sprintf("Could not open %s for writing.", $pFilename));
}
$oPresentation = $this->getPhpPresentation();

// Create new ZIP file and open it for writing
Expand Down
10 changes: 4 additions & 6 deletions tests/PhpPresentation/Tests/AbstractShapeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -192,18 +192,16 @@ public function testContainer()
$this->assertNull($object->getContainer());
}

/**
* @expectedException \Exception
* @expectedExceptionMessage A \PhpOffice\PhpPresentation\ShapeContainerInterface has already been assigned. Shapes can only exist on one \PhpOffice\PhpPresentation\ShapeContainerInterface.
*/
public function testContainerException()
public function testContainerException(): void
{
$object = new RichText();
$oSlide = new Slide();

$this->assertNull($object->getContainer());
$this->assertInstanceOf('PhpOffice\\PhpPresentation\\AbstractShape', $object->setContainer($oSlide));
$this->assertInstanceOf('PhpOffice\\PhpPresentation\\Slide', $object->getContainer());
$this->assertInstanceOf('PhpOffice\\PhpPresentation\\AbstractShape', $object->setContainer(null));
$this->expectException(\Exception::class);
$this->expectExceptionMessage('A \PhpOffice\PhpPresentation\ShapeContainerInterface has already been assigned. Shapes can only exist on one \PhpOffice\PhpPresentation\ShapeContainerInterface.');
$object->setContainer(null);
}
}
14 changes: 6 additions & 8 deletions tests/PhpPresentation/Tests/HashTableTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public function testConstructNull()
$this->assertEquals(0, $object->count());
$this->assertNull($object->getByIndex());
$this->assertNull($object->getByHashCode());
$this->assertInternalType('array', $object->toArray());
$this->assertIsArray($object->toArray());
$this->assertEmpty($object->toArray());
}

Expand All @@ -51,7 +51,7 @@ public function testConstructSource()
));

$this->assertEquals(2, $object->count());
$this->assertInternalType('array', $object->toArray());
$this->assertIsArray($object->toArray());
$this->assertCount(2, $object->toArray());
}

Expand All @@ -66,7 +66,7 @@ public function testAdd()
$this->assertNull($object->addFromSource());
// Add From Source : Array
$this->assertNull($object->addFromSource(array($oSlide)));
$this->assertInternalType('array', $object->toArray());
$this->assertIsArray($object->toArray());
$this->assertCount(1, $object->toArray());
// Clear
$this->assertNull($object->clear());
Expand Down Expand Up @@ -122,14 +122,12 @@ public function testRemove()
$this->assertCount(1, $object->toArray());
}

/**
* @expectedException \Exception
* @expectedExceptionMessage Invalid array parameter passed.
*/
public function testAddException()
public function testAddException(): void
{
$object = new HashTable();
$oSlide = new Slide();
$this->expectException(\Exception::class);
$this->expectExceptionMessage('Invalid array parameter passed.');
$object->addFromSource($oSlide);
}
}
10 changes: 4 additions & 6 deletions tests/PhpPresentation/Tests/IOFactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,11 @@ public function testCreateReader()

/**
* Test load class exception
*
* @expectedException \Exception
* @expectedExceptionMessage is not a valid reader
*/
public function testLoadClassException()
{
$this->expectException(\Exception::class);
$this->expectExceptionMessage('"" is not a valid reader');
IOFactory::createReader();
}

Expand All @@ -66,12 +65,11 @@ public function testLoad()

/**
* Test load class exception
*
* @expectedException \Exception
* @expectedExceptionMessage Could not automatically determine \PhpOffice\PhpPresentation\Reader\ReaderInterface for file.
*/
public function testLoadException()
{
$this->expectException(\Exception::class);
$this->expectExceptionMessage('Could not automatically determine \PhpOffice\PhpPresentation\Reader\ReaderInterface for file.');
IOFactory::load(PHPPRESENTATION_TESTS_BASE_DIR.DIRECTORY_SEPARATOR.'resources'.DIRECTORY_SEPARATOR.'images'.DIRECTORY_SEPARATOR.'PhpPresentationLogo.png');
}
}
18 changes: 9 additions & 9 deletions tests/PhpPresentation/Tests/PhpPresentationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,36 +93,36 @@ public function testCopy()

/**
* Test remove slide by index exception
*
* @expectedException Exception
* @expectedExceptionMessage Slide index is out of bounds.
*/
public function testRemoveSlideByIndexException()
{
$this->expectException(\Exception::class);
$this->expectExceptionMessage('Slide index is out of bounds.');

$object = new PhpPresentation();
$object->removeSlideByIndex(1);
}

/**
* Test get slide exception
*
* @expectedException Exception
* @expectedExceptionMessage Slide index is out of bounds.
*/
public function testGetSlideException()
{
$this->expectException(\Exception::class);
$this->expectExceptionMessage('Slide index is out of bounds.');

$object = new PhpPresentation();
$object->getSlide(1);
}

/**
* Test set active slide index exception
*
* @expectedException Exception
* @expectedExceptionMessage Active slide index is out of bounds.
*/
public function testSetActiveSlideIndexException()
{
$this->expectException(\Exception::class);
$this->expectExceptionMessage('Active slide index is out of bounds.');

$object = new PhpPresentation();
$object->setActiveSlideIndex(1);
}
Expand Down
31 changes: 14 additions & 17 deletions tests/PhpPresentation/Tests/Reader/ODPresentationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,33 +49,30 @@ public function testCanRead()
$this->assertTrue($object->canRead($file));
}

/**
* @expectedException \Exception
* @expectedExceptionMessage Could not open for reading! File does not exist.
*/
public function testLoadFileNotExists()
{
$this->expectException(\Exception::class);
$this->expectExceptionMessage('Could not open for reading! File does not exist.');

$object = new ODPresentation();
$object->load('');
}

/**
* @expectedException \Exception
* @expectedExceptionMessage Invalid file format for PhpOffice\PhpPresentation\Reader\ODPresentation:
*/
public function testLoadFileBadFormat()
{
$this->expectException(\Exception::class);
$this->expectExceptionMessage('Invalid file format for PhpOffice\PhpPresentation\Reader\ODPresentation:');

$file = PHPPRESENTATION_TESTS_BASE_DIR . '/resources/files/Sample_00_01.ppt';
$object = new ODPresentation();
$object->load($file);
}

/**
* @expectedException \Exception
* @expectedExceptionMessage Could not open for reading! File does not exist.
*/
public function testFileSupportsNotExists()
{
$this->expectException(\Exception::class);
$this->expectExceptionMessage('Could not open for reading! File does not exist.');

$object = new ODPresentation();
$object->fileSupportsUnserializePhpPresentation('');
}
Expand All @@ -98,7 +95,7 @@ public function testLoadFile01()

// Slide 1
$oSlide1 = $oPhpPresentation->getSlide(0);
$arrayShape = $oSlide1->getShapeCollection();
$arrayShape = (array) $oSlide1->getShapeCollection();
$this->assertCount(2, $arrayShape);
// Slide 1 : Shape 1
$oShape = $arrayShape[0];
Expand Down Expand Up @@ -144,7 +141,7 @@ public function testLoadFile01()

// Slide 2
$oSlide2 = $oPhpPresentation->getSlide(1);
$arrayShape = $oSlide2->getShapeCollection();
$arrayShape = (array) $oSlide2->getShapeCollection();
$this->assertCount(3, $arrayShape);
// Slide 2 : Shape 1
$oShape = $arrayShape[0];
Expand Down Expand Up @@ -241,7 +238,7 @@ public function testLoadFile01()

// Slide 3
$oSlide2 = $oPhpPresentation->getSlide(2);
$arrayShape = $oSlide2->getShapeCollection();
$arrayShape = (array) $oSlide2->getShapeCollection();
$this->assertCount(3, $arrayShape);
// Slide 3 : Shape 1
$oShape = $arrayShape[0];
Expand Down Expand Up @@ -398,7 +395,7 @@ public function testLoadFile01()

// Slide 4
$oSlide3 = $oPhpPresentation->getSlide(3);
$arrayShape = $oSlide3->getShapeCollection();
$arrayShape = (array) $oSlide3->getShapeCollection();
$this->assertCount(3, $arrayShape);
// Slide 4 : Shape 1
$oShape = $arrayShape[0];
Expand Down Expand Up @@ -487,7 +484,7 @@ public function testIssue00141()

// Slide 1
$oSlide = $oPhpPresentation->getSlide(1);
$arrayShape = $oSlide->getShapeCollection();
$arrayShape = (array) $oSlide->getShapeCollection();
$this->assertCount(2, $arrayShape);
// Slide 1 : Shape 1
$oShape = reset($arrayShape);
Expand Down
Loading

0 comments on commit 49312ba

Please sign in to comment.