From b33a0383fa8c4782d947b440f86b91ebb8a49387 Mon Sep 17 00:00:00 2001 From: Will Rossiter Date: Wed, 19 Jul 2023 15:35:23 +1200 Subject: [PATCH] feat: update to silverstripe version --- .editorconfig | 39 ++++++++++++ .github/workflows/ci.yml | 13 ++++ .gitignore | 6 +- .php_cs | 12 ---- .travis.yml | 11 ---- composer.json | 66 ++++++++++---------- phpunit.xml | 24 ------- phpunit.xml.dist | 9 +++ src/Generator.php | 6 +- tests/EchoValue.php | 15 +++-- tests/GeneratorTest.php | 2 +- tests/ImageHelperTest.php | 59 ------------------ tests/Input/RequestTest.php | 4 +- tests/Input/StringTest.php | 7 ++- tests/Input/TemplateTest.php | 107 -------------------------------- tests/Input/UrlTest.php | 58 ----------------- tests/Output/BrowserTest.php | 46 -------------- tests/Output/RandomFileTest.php | 46 -------------- tests/Output/StringTest.php | 46 -------------- tests/TemplateHelperTest.php | 58 ----------------- 20 files changed, 114 insertions(+), 520 deletions(-) create mode 100644 .editorconfig create mode 100644 .github/workflows/ci.yml delete mode 100644 .php_cs delete mode 100644 .travis.yml delete mode 100644 phpunit.xml create mode 100644 phpunit.xml.dist delete mode 100644 tests/ImageHelperTest.php delete mode 100644 tests/Input/TemplateTest.php delete mode 100644 tests/Input/UrlTest.php delete mode 100644 tests/Output/BrowserTest.php delete mode 100644 tests/Output/RandomFileTest.php delete mode 100644 tests/Output/StringTest.php delete mode 100644 tests/TemplateHelperTest.php diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..170c83b --- /dev/null +++ b/.editorconfig @@ -0,0 +1,39 @@ +# For more information about the properties used in +# this file, please see the EditorConfig documentation: +# http://editorconfig.org/ + +root = true + +[*] +charset = utf-8 +end_of_line = lf +indent_size = 4 +indent_style = space +insert_final_newline = true +trim_trailing_whitespace = true + +[*.md] +trim_trailing_whitespace = false + +[*.{yml,json,tf}] +# The indent size used in the `package.json` file cannot be changed +# https://github.com/npm/npm/pull/3180#issuecomment-16336516 +indent_size = 2 + +[Makefile] +indent_style = tab + +[*.go] +indent_style = tab + +[*.sh] +indent_style = tab + +[composer.json] +indent_size = 4 + +[*.{js,vue,scss}] +indent_size = 2 + +[*.js] +quote_type = single diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..6ac187d --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,13 @@ +name: CI + +on: + push: + pull_request: + workflow_dispatch: + +jobs: + ci: + name: CI + uses: silverstripe/gha-ci/.github/workflows/ci.yml@v1 + with: + simple_matrix: true diff --git a/.gitignore b/.gitignore index 5a0e444..049e185 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,5 @@ /.idea -/framework -/vendor \ No newline at end of file +/vendor +.phpunit.result.cache +composer.lock +/public diff --git a/.php_cs b/.php_cs deleted file mode 100644 index 3557594..0000000 --- a/.php_cs +++ /dev/null @@ -1,12 +0,0 @@ -name('*.php') - ->exclude(array( - 'sapphire', - 'vendor' - )) - ->in(__DIR__); - -return Symfony\CS\Config\Config::create() - ->finder($finder); \ No newline at end of file diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index e093076..0000000 --- a/.travis.yml +++ /dev/null @@ -1,11 +0,0 @@ -language: php - -php: - - 5.6 - - 7.0 - - 7.1 - - 7.2 - -before_script: - - composer self-update - - composer install --prefer-dist diff --git a/composer.json b/composer.json index b4f5630..ded77df 100644 --- a/composer.json +++ b/composer.json @@ -1,35 +1,35 @@ { - "name": "heyday/silverstripe-wkhtml", - "description": "Provides Wkhtml functionality in SilverStripe", - "type": "silverstripe-vendormodule", - "license": "MIT", - "autoload": { - "psr-4": { - "Heyday\\SilverStripe\\WkHtml\\": "src/" - } - }, - "autoload-dev": { - "psr-4": { - "Heyday\\SilverStripe\\WkHtml\\": "tests/" - } - }, - "require": { - "php": ">=5.6", - "knplabs/knp-snappy": "^1", - "silverstripe/framework": "^4" - }, - "require-dev": { - "phpunit/phpunit": "^5.7", - "mikey179/vfsstream": "^1" - }, - "extra": { - "branch-alias": { - "dev-master": "1.1.x-dev" - } - }, - "config": { - "preferred-install": { - "silverstripe/framework": "source" - } - } + "name": "heyday/silverstripe-wkhtml", + "description": "Provides Wkhtml functionality in SilverStripe", + "type": "silverstripe-vendormodule", + "license": "MIT", + "autoload": { + "psr-4": { + "Heyday\\SilverStripe\\WkHtml\\": "src/" + } + }, + "autoload-dev": { + "psr-4": { + "Heyday\\SilverStripe\\WkHtml\\": "tests/" + } + }, + "require": { + "knplabs/knp-snappy": "^1", + "silverstripe/framework": "^5" + }, + "require-dev": { + "phpunit/phpunit": "^9.5", + "mikey179/vfsstream": "^1" + }, + "extra": { + "branch-alias": { + "dev-master": "1.1.x-dev" + } + }, + "config": { + "allow-plugins": { + "composer/installers": true, + "silverstripe/vendor-plugin": true + } + } } diff --git a/phpunit.xml b/phpunit.xml deleted file mode 100644 index 460a95c..0000000 --- a/phpunit.xml +++ /dev/null @@ -1,24 +0,0 @@ - - - - - - ./tests - - - - - src - - - diff --git a/phpunit.xml.dist b/phpunit.xml.dist new file mode 100644 index 0000000..6aaf78b --- /dev/null +++ b/phpunit.xml.dist @@ -0,0 +1,9 @@ + + + + + + ./tests + + + diff --git a/src/Generator.php b/src/Generator.php index fa4ac9b..d7cede5 100644 --- a/src/Generator.php +++ b/src/Generator.php @@ -82,8 +82,7 @@ public function __construct( InputInterface $input, OutputInterface $output, $cache = true - ) - { + ) { $this->generator = $generator; $this->input = $input; $this->output = $output; @@ -97,7 +96,7 @@ public function process() { if ($this->cacheOutput && $this->cache) { $contents = $this->input->process(); - $key = md5($contents); + $key = md5($contents ?? ''); if (!($output = $this->cache->get($key))) { $output = $this->output->process($contents, $this->generator); @@ -177,4 +176,3 @@ public function setCache(CacheInterface $cache) $this->cache = $cache; } } - diff --git a/tests/EchoValue.php b/tests/EchoValue.php index 1870be2..cb852f9 100644 --- a/tests/EchoValue.php +++ b/tests/EchoValue.php @@ -2,11 +2,10 @@ namespace Heyday\SilverStripe\WkHtml; -use PHPUnit_Framework_MockObject_Stub; -use PHPUnit_Framework_MockObject_Invocation; -use PHPUnit_Util_Type; +use PHPUnit\Framework\MockObject\Stub\Stub; +use PHPUnit\Framework\MockObject\Invocation; -class EchoValue implements PHPUnit_Framework_MockObject_Stub +class EchoValue implements Stub { protected $value; @@ -15,16 +14,16 @@ public function __construct($value) $this->value = $value; } - public function invoke(PHPUnit_Framework_MockObject_Invocation $invocation) + public function invoke(Invocation $invocation) { echo $this->value; } - public function toString() + public function toString(): string { return sprintf( 'echo user-specified value %s', - PHPUnit_Util_Type::toString($this->value) + $this->value ); } -} \ No newline at end of file +} diff --git a/tests/GeneratorTest.php b/tests/GeneratorTest.php index 5a73d86..bcfedea 100644 --- a/tests/GeneratorTest.php +++ b/tests/GeneratorTest.php @@ -33,7 +33,7 @@ class GeneratorTest extends SapphireTest * Sets up the fixture, for example, opens a network connection. * This method is called before a test is executed. */ - protected function setUp() + protected function setUp(): void { parent::setUp(); diff --git a/tests/ImageHelperTest.php b/tests/ImageHelperTest.php deleted file mode 100644 index f85ef2c..0000000 --- a/tests/ImageHelperTest.php +++ /dev/null @@ -1,59 +0,0 @@ -object = Injector::inst()->get(ImageHelper::class); - } - - /** - * Tears down the fixture, for example, closes a network connection. - * This method is called after a test is executed. - */ - protected function tearDown() - { - parent::tearDown(); - } - - /** - * @covers Heyday\SilverStripe\WkHtml\ImageHelper::extraStatics - * @todo Implement testExtraStatics(). - */ - public function testExtraStatics() - { - // Remove the following lines when you implement this test. - $this->markTestIncomplete( - 'This test has not been implemented yet.' - ); - } - - /** - * @covers Heyday\SilverStripe\WkHtml\ImageHelper::Base64 - * @todo Implement testBase64(). - */ - public function testBase64() - { - // Remove the following lines when you implement this test. - $this->markTestIncomplete( - 'This test has not been implemented yet.' - ); - } -} diff --git a/tests/Input/RequestTest.php b/tests/Input/RequestTest.php index f52002b..fedf125 100644 --- a/tests/Input/RequestTest.php +++ b/tests/Input/RequestTest.php @@ -111,7 +111,7 @@ public function testProcessBadReturn() * Sets up the fixture, for example, opens a network connection. * This method is called before a test is executed. */ - protected function setUp() + protected function setUp(): void { parent::setUp(); @@ -126,5 +126,3 @@ protected function setUp() $this->object = Request::create($this->request); } } - - diff --git a/tests/Input/StringTest.php b/tests/Input/StringTest.php index 76fe715..387ff7d 100644 --- a/tests/Input/StringTest.php +++ b/tests/Input/StringTest.php @@ -17,7 +17,7 @@ class StringTest extends SapphireTest /** * */ - protected function setUp() + protected function setUp(): void { parent::setUp(); @@ -28,6 +28,9 @@ protected function setUp() */ public function testProcess() { - $this->assertEquals('test', $this->object->process()); + $this->assertStringContainsString( + 'test', + $this->object->process() + ); } } diff --git a/tests/Input/TemplateTest.php b/tests/Input/TemplateTest.php deleted file mode 100644 index 3c39664..0000000 --- a/tests/Input/TemplateTest.php +++ /dev/null @@ -1,107 +0,0 @@ -object = new Template; - } - - /** - * Tears down the fixture, for example, closes a network connection. - * This method is called after a test is executed. - */ - protected function tearDown() - { - parent::tearDown(); - } - - /** - * @covers \Heyday\SilverStripe\WkHtml\Input\Template::setTemplate - * @todo Implement testSetTemplate(). - */ - public function testSetTemplate() - { - // Remove the following lines when you implement this test. - $this->markTestIncomplete( - 'This test has not been implemented yet.' - ); - } - - /** - * @covers \Heyday\SilverStripe\WkHtml\Input\Template::getTemplate - * @todo Implement testGetTemplate(). - */ - public function testGetTemplate() - { - // Remove the following lines when you implement this test. - $this->markTestIncomplete( - 'This test has not been implemented yet.' - ); - } - - /** - * @covers \Heyday\SilverStripe\WkHtml\Input\Template::setTemplateFromString - * @todo Implement testSetTemplateFromString(). - */ - public function testSetTemplateFromString() - { - // Remove the following lines when you implement this test. - $this->markTestIncomplete( - 'This test has not been implemented yet.' - ); - } - - /** - * @covers \Heyday\SilverStripe\WkHtml\Input\Template::setData - * @todo Implement testSetData(). - */ - public function testSetData() - { - // Remove the following lines when you implement this test. - $this->markTestIncomplete( - 'This test has not been implemented yet.' - ); - } - - /** - * @covers \Heyday\SilverStripe\WkHtml\Input\Template::getData - * @todo Implement testGetData(). - */ - public function testGetData() - { - // Remove the following lines when you implement this test. - $this->markTestIncomplete( - 'This test has not been implemented yet.' - ); - } - - /** - * @covers \Heyday\SilverStripe\WkHtml\Input\Template::process - * @todo Implement testProcess(). - */ - public function testProcess() - { - // Remove the following lines when you implement this test. - $this->markTestIncomplete( - 'This test has not been implemented yet.' - ); - } -} diff --git a/tests/Input/UrlTest.php b/tests/Input/UrlTest.php deleted file mode 100644 index db7840c..0000000 --- a/tests/Input/UrlTest.php +++ /dev/null @@ -1,58 +0,0 @@ -object = new Url; - } - - /** - * Tears down the fixture, for example, closes a network connection. - * This method is called after a test is executed. - */ - protected function tearDown() - { - parent::tearDown(); - } - - /** - * @covers \Heyday\SilverStripe\WkHtml\Input\Url::setUrl - * @todo Implement testSetUrl(). - */ - public function testSetUrl() - { - // Remove the following lines when you implement this test. - $this->markTestIncomplete( - 'This test has not been implemented yet.' - ); - } - - /** - * @covers \Heyday\SilverStripe\WkHtml\Input\Url::process - * @todo Implement testProcess(). - */ - public function testProcess() - { - // Remove the following lines when you implement this test. - $this->markTestIncomplete( - 'This test has not been implemented yet.' - ); - } -} diff --git a/tests/Output/BrowserTest.php b/tests/Output/BrowserTest.php deleted file mode 100644 index b623128..0000000 --- a/tests/Output/BrowserTest.php +++ /dev/null @@ -1,46 +0,0 @@ -object = new Browser; - } - - /** - * Tears down the fixture, for example, closes a network connection. - * This method is called after a test is executed. - */ - protected function tearDown() - { - parent::tearDown(); - } - - /** - * @covers \Heyday\SilverStripe\WkHtml\Output\Browser::process - * @todo Implement testProcess(). - */ - public function testProcess() - { - // Remove the following lines when you implement this test. - $this->markTestIncomplete( - 'This test has not been implemented yet.' - ); - } -} diff --git a/tests/Output/RandomFileTest.php b/tests/Output/RandomFileTest.php deleted file mode 100644 index bc6ba9e..0000000 --- a/tests/Output/RandomFileTest.php +++ /dev/null @@ -1,46 +0,0 @@ -object = new RandomFile; - } - - /** - * Tears down the fixture, for example, closes a network connection. - * This method is called after a test is executed. - */ - protected function tearDown() - { - parent::tearDown(); - } - - /** - * @covers \Heyday\SilverStripe\WkHtml\Output\RandomFile::process - * @todo Implement testProcess(). - */ - public function testProcess() - { - // Remove the following lines when you implement this test. - $this->markTestIncomplete( - 'This test has not been implemented yet.' - ); - } -} diff --git a/tests/Output/StringTest.php b/tests/Output/StringTest.php deleted file mode 100644 index afeabd2..0000000 --- a/tests/Output/StringTest.php +++ /dev/null @@ -1,46 +0,0 @@ -object = new TextString; - } - - /** - * Tears down the fixture, for example, closes a network connection. - * This method is called after a test is executed. - */ - protected function tearDown() - { - parent::tearDown(); - } - - /** - * @covers \Heyday\SilverStripe\WkHtml\Output\TextString::process - * @todo Implement testProcess(). - */ - public function testProcess() - { - // Remove the following lines when you implement this test. - $this->markTestIncomplete( - 'This test has not been implemented yet.' - ); - } -} diff --git a/tests/TemplateHelperTest.php b/tests/TemplateHelperTest.php deleted file mode 100644 index abf842c..0000000 --- a/tests/TemplateHelperTest.php +++ /dev/null @@ -1,58 +0,0 @@ -object = TemplateHelper::create(); - } - - /** - * Tears down the fixture, for example, closes a network connection. - * This method is called after a test is executed. - */ - protected function tearDown() - { - parent::tearDown(); - } - - /** - * @covers \Heyday\SilverStripe\WkHtml\TemplateHelper::EmbedCss - * @todo Implement testEmbedCss(). - */ - public function testEmbedCss() - { - // Remove the following lines when you implement this test. - $this->markTestIncomplete( - 'This test has not been implemented yet.' - ); - } - - /** - * @covers \Heyday\SilverStripe\WkHtml\TemplateHelper::EmbedBase64Image - * @todo Implement testEmbedBase64Image(). - */ - public function testEmbedBase64Image() - { - // Remove the following lines when you implement this test. - $this->markTestIncomplete( - 'This test has not been implemented yet.' - ); - } -}