mirror of
https://github.com/silverstripe/silverstripe-iframe
synced 2024-10-22 11:05:51 +02:00
Update CI tool configurations to fit SS4 conventions
Also update test class to use non-deprecated methods from core (such as Config::update). Fix a few code sniffer errors.
This commit is contained in:
parent
4fb947d0c7
commit
352bc67aa8
1
.gitattributes
vendored
1
.gitattributes
vendored
@ -4,3 +4,4 @@
|
|||||||
/.gitignore export-ignore
|
/.gitignore export-ignore
|
||||||
/.travis.yml export-ignore
|
/.travis.yml export-ignore
|
||||||
/.scrutinizer.yml export-ignore
|
/.scrutinizer.yml export-ignore
|
||||||
|
/codecov.yml
|
||||||
|
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
.DS_Store
|
@ -1,5 +1,11 @@
|
|||||||
inherit: true
|
inherit: true
|
||||||
|
|
||||||
|
build:
|
||||||
|
nodes:
|
||||||
|
analysis:
|
||||||
|
tests:
|
||||||
|
override: [php-scrutinizer-run]
|
||||||
|
|
||||||
checks:
|
checks:
|
||||||
php:
|
php:
|
||||||
code_rating: true
|
code_rating: true
|
||||||
|
35
.travis.yml
35
.travis.yml
@ -1,34 +1,35 @@
|
|||||||
# See https://github.com/silverstripe/silverstripe-travis-support for setup details
|
|
||||||
language: php
|
language: php
|
||||||
|
|
||||||
sudo: false
|
|
||||||
|
|
||||||
env:
|
env:
|
||||||
global:
|
global:
|
||||||
- COMPOSER_ROOT_VERSION=1.0.x-dev
|
- COMPOSER_ROOT_VERSION=2.0.x-dev
|
||||||
- CORE_RELEASE=4
|
|
||||||
# The path of the module when installed by composer
|
|
||||||
- MODULE_PATH=iframe
|
|
||||||
|
|
||||||
matrix:
|
matrix:
|
||||||
fast_finish: true
|
|
||||||
include:
|
include:
|
||||||
- php: 5.6
|
- php: 5.6
|
||||||
env: DB=MYSQL
|
env: DB=MYSQL PHPCS_TEST=1 PHPUNIT_TEST=1
|
||||||
- php: 7.0
|
- php: 7.0
|
||||||
env: DB=MYSQL
|
env: DB=MYSQL PHPUNIT_TEST=1
|
||||||
- php: 7.1
|
- php: 7.1
|
||||||
env: DB=MYSQL
|
env: DB=MYSQL PHPUNIT_COVERAGE_TEST=1
|
||||||
|
- php: 7.2
|
||||||
|
env: DB=MYSQL PHPUNIT_TEST=1
|
||||||
|
|
||||||
before_script:
|
before_script:
|
||||||
- composer self-update || true
|
# Init PHP
|
||||||
- phpenv rehash
|
- phpenv rehash
|
||||||
- phpenv config-rm xdebug.ini
|
- phpenv config-rm xdebug.ini
|
||||||
|
- echo 'memory_limit = 2048M' >> ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/travis.ini
|
||||||
|
|
||||||
|
# Install composer dependencies
|
||||||
- composer validate
|
- composer validate
|
||||||
- git clone git://github.com/silverstripe/silverstripe-travis-support.git ~/travis-support
|
- composer require --no-update silverstripe/recipe-cms:1.0.x-dev
|
||||||
- php ~/travis-support/travis_setup.php --source `pwd` --target ~/builds/ss
|
- composer install --prefer-dist --no-interaction --no-progress --no-suggest --optimize-autoloader --verbose --profile
|
||||||
- cd ~/builds/ss
|
|
||||||
- composer install --prefer-dist
|
|
||||||
|
|
||||||
script:
|
script:
|
||||||
- vendor/bin/phpunit $MODULE_PATH/tests
|
- if [[ $PHPUNIT_TEST ]]; then vendor/bin/phpunit; fi
|
||||||
|
- if [[ $PHPUNIT_COVERAGE_TEST ]]; then phpdbg -qrr vendor/bin/phpunit --coverage-clover=coverage.xml; fi
|
||||||
|
- if [[ $PHPCS_TEST ]]; then vendor/bin/phpcs code/ tests/ *.php; fi
|
||||||
|
|
||||||
|
after_success:
|
||||||
|
- if [[ $PHPUNIT_COVERAGE_TEST ]]; then bash <(curl -s https://codecov.io/bash) -f coverage.xml; fi
|
||||||
|
@ -1,2 +1 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
@ -7,6 +7,7 @@ use SilverStripe\Forms\DropdownField;
|
|||||||
use SilverStripe\Forms\CheckboxField;
|
use SilverStripe\Forms\CheckboxField;
|
||||||
use SilverStripe\Forms\NumericField;
|
use SilverStripe\Forms\NumericField;
|
||||||
use SilverStripe\Forms\HTMLEditor\HtmlEditorField;
|
use SilverStripe\Forms\HTMLEditor\HtmlEditorField;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Iframe page type embeds an iframe of URL of choice into the page.
|
* Iframe page type embeds an iframe of URL of choice into the page.
|
||||||
* CMS editor can choose width, height, or set it to attempt automatic size configuration.
|
* CMS editor can choose width, height, or set it to attempt automatic size configuration.
|
||||||
@ -40,22 +41,28 @@ class IFramePage extends Page
|
|||||||
|
|
||||||
$fields->removeFieldFromTab('Root.Main', 'Content');
|
$fields->removeFieldFromTab('Root.Main', 'Content');
|
||||||
$fields->addFieldToTab('Root.Main', $url = new TextField('IFrameURL', 'Iframe URL'));
|
$fields->addFieldToTab('Root.Main', $url = new TextField('IFrameURL', 'Iframe URL'));
|
||||||
$url->setRightTitle('Can be absolute (<em>http://silverstripe.com</em>) or relative to this site (<em>about-us</em>).');
|
$url->setRightTitle(
|
||||||
|
'Can be absolute (<em>http://silverstripe.com</em>) or relative to this site (<em>about-us</em>).'
|
||||||
|
);
|
||||||
$fields->addFieldToTab(
|
$fields->addFieldToTab(
|
||||||
'Root.Main',
|
'Root.Main',
|
||||||
DropdownField::create('ForceProtocol', 'Force protocol?')
|
DropdownField::create('ForceProtocol', 'Force protocol?')
|
||||||
->setSource(array('http://' => 'http://', 'https://' => 'https://'))
|
->setSource(array('http://' => 'http://', 'https://' => 'https://'))
|
||||||
->setEmptyString('')
|
->setEmptyString('')
|
||||||
->setDescription('Avoids mixed content warnings when iframe content is just available under a specific protocol'),
|
->setDescription(
|
||||||
|
'Avoids mixed content warnings when iframe content is just available under a specific protocol'
|
||||||
|
),
|
||||||
'Metadata'
|
'Metadata'
|
||||||
);
|
);
|
||||||
$fields->addFieldToTab('Root.Main', new CheckboxField('AutoHeight', 'Auto height (only works with same domain URLs)'));
|
$fields->addFieldsToTab('Root.Main', [
|
||||||
$fields->addFieldToTab('Root.Main', new CheckboxField('AutoWidth', 'Auto width (100% of the available space)'));
|
CheckboxField::create('AutoHeight', 'Auto height (only works with same domain URLs)'),
|
||||||
$fields->addFieldToTab('Root.Main', new NumericField('FixedHeight', 'Fixed height (in pixels)'));
|
CheckboxField::create('AutoWidth', 'Auto width (100% of the available space)'),
|
||||||
$fields->addFieldToTab('Root.Main', new NumericField('FixedWidth', 'Fixed width (in pixels)'));
|
NumericField::create('FixedHeight', 'Fixed height (in pixels)'),
|
||||||
$fields->addFieldToTab('Root.Main', new HtmlEditorField('Content', 'Content (appears above iframe)'));
|
NumericField::create('FixedWidth', 'Fixed width (in pixels)'),
|
||||||
$fields->addFieldToTab('Root.Main', new HtmlEditorField('BottomContent', 'Content (appears below iframe)'));
|
HtmlEditorField::create('Content', 'Content (appears above iframe)'),
|
||||||
$fields->addFieldToTab('Root.Main', new HtmlEditorField('AlternateContent', 'Alternate Content (appears when user has iframes disabled)'));
|
HtmlEditorField::create('BottomContent', 'Content (appears below iframe)'),
|
||||||
|
HtmlEditorField::create('AlternateContent', 'Alternate Content (appears when user has iframes disabled)')
|
||||||
|
]);
|
||||||
|
|
||||||
// Move the Metadata field to last position, but make a check for it's
|
// Move the Metadata field to last position, but make a check for it's
|
||||||
// existence first.
|
// existence first.
|
||||||
|
1
codecov.yml
Normal file
1
codecov.yml
Normal file
@ -0,0 +1 @@
|
|||||||
|
comment: false
|
@ -11,10 +11,11 @@
|
|||||||
}
|
}
|
||||||
],
|
],
|
||||||
"require": {
|
"require": {
|
||||||
"silverstripe/recipe-cms": "^1"
|
"silverstripe/cms": "^4.0"
|
||||||
},
|
},
|
||||||
"require-dev": {
|
"require-dev": {
|
||||||
"phpunit/PHPUnit": "^5.7"
|
"phpunit/phpunit": "^5.7",
|
||||||
|
"squizlabs/php_codesniffer": "^3.0"
|
||||||
},
|
},
|
||||||
"autoload": {
|
"autoload": {
|
||||||
"psr-4": {
|
"psr-4": {
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
Copyright (c) 2016, SilverStripe Limited
|
Copyright (c) 2017, SilverStripe Limited
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
||||||
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
|
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
|
||||||
|
9
phpcs.xml.dist
Normal file
9
phpcs.xml.dist
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<ruleset name="SilverStripe">
|
||||||
|
<description>CodeSniffer ruleset for SilverStripe coding conventions.</description>
|
||||||
|
|
||||||
|
<rule ref="PSR2" >
|
||||||
|
<!-- Current exclusions -->
|
||||||
|
<exclude name="PSR1.Methods.CamelCapsMethodName" />
|
||||||
|
</rule>
|
||||||
|
</ruleset>
|
13
phpunit.xml.dist
Normal file
13
phpunit.xml.dist
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
<phpunit bootstrap="vendor/silverstripe/cms/tests/bootstrap.php" colors="true">
|
||||||
|
<testsuite name="Default">
|
||||||
|
<directory>tests/</directory>
|
||||||
|
</testsuite>
|
||||||
|
<filter>
|
||||||
|
<whitelist addUncoveredFilesFromWhitelist="true">
|
||||||
|
<directory suffix=".php">code/</directory>
|
||||||
|
<exclude>
|
||||||
|
<directory suffix=".php">tests/</directory>
|
||||||
|
</exclude>
|
||||||
|
</whitelist>
|
||||||
|
</filter>
|
||||||
|
</phpunit>
|
@ -12,18 +12,6 @@ class IFramePageTest extends SapphireTest
|
|||||||
{
|
{
|
||||||
protected $usesDatabase = true;
|
protected $usesDatabase = true;
|
||||||
|
|
||||||
public function setUp()
|
|
||||||
{
|
|
||||||
parent::setUp();
|
|
||||||
Config::nest();
|
|
||||||
}
|
|
||||||
|
|
||||||
public function tearDown()
|
|
||||||
{
|
|
||||||
Config::unnest();
|
|
||||||
parent::tearDown();
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testGetClass()
|
public function testGetClass()
|
||||||
{
|
{
|
||||||
$iframe = new IFramePage();
|
$iframe = new IFramePage();
|
||||||
@ -109,40 +97,40 @@ class IFramePageTest extends SapphireTest
|
|||||||
$page->URLSegment = 'iframe';
|
$page->URLSegment = 'iframe';
|
||||||
$page->IFrameURL = 'http://target.com';
|
$page->IFrameURL = 'http://target.com';
|
||||||
|
|
||||||
Config::inst()->update(Director::class, 'alternate_protocol', 'http');
|
Config::modify()->set(Director::class, 'alternate_protocol', 'http');
|
||||||
Config::inst()->update(Director::class, 'alternate_base_url', 'http://host.com');
|
Config::modify()->set(Director::class, 'alternate_base_url', 'http://host.com');
|
||||||
$page->ForceProtocol = '';
|
$page->ForceProtocol = '';
|
||||||
$controller = new IFramePageController($page);
|
$controller = new IFramePageController($page);
|
||||||
$controller->doInit();
|
$controller->doInit();
|
||||||
$response = $controller->getResponse();
|
$response = $controller->getResponse();
|
||||||
$this->assertNull($response->getHeader('Location'));
|
$this->assertNull($response->getHeader('Location'));
|
||||||
|
|
||||||
Config::inst()->update(Director::class, 'alternate_protocol', 'https');
|
Config::modify()->set(Director::class, 'alternate_protocol', 'https');
|
||||||
Config::inst()->update(Director::class, 'alternate_base_url', 'https://host.com');
|
Config::modify()->set(Director::class, 'alternate_base_url', 'https://host.com');
|
||||||
$page->ForceProtocol = '';
|
$page->ForceProtocol = '';
|
||||||
$controller = new IFramePageController($page);
|
$controller = new IFramePageController($page);
|
||||||
$controller->doInit();
|
$controller->doInit();
|
||||||
$response = $controller->getResponse();
|
$response = $controller->getResponse();
|
||||||
$this->assertNull($response->getHeader('Location'));
|
$this->assertNull($response->getHeader('Location'));
|
||||||
|
|
||||||
Config::inst()->update(Director::class, 'alternate_protocol', 'http');
|
Config::modify()->set(Director::class, 'alternate_protocol', 'http');
|
||||||
Config::inst()->update(Director::class, 'alternate_base_url', 'http://host.com');
|
Config::modify()->set(Director::class, 'alternate_base_url', 'http://host.com');
|
||||||
$page->ForceProtocol = 'http://';
|
$page->ForceProtocol = 'http://';
|
||||||
$controller = new IFramePageController($page);
|
$controller = new IFramePageController($page);
|
||||||
$controller->doInit();
|
$controller->doInit();
|
||||||
$response = $controller->getResponse();
|
$response = $controller->getResponse();
|
||||||
$this->assertNull($response->getHeader('Location'));
|
$this->assertNull($response->getHeader('Location'));
|
||||||
|
|
||||||
Config::inst()->update(Director::class, 'alternate_protocol', 'http');
|
Config::modify()->set(Director::class, 'alternate_protocol', 'http');
|
||||||
Config::inst()->update(Director::class, 'alternate_base_url', 'http://host.com');
|
Config::modify()->set(Director::class, 'alternate_base_url', 'http://host.com');
|
||||||
$page->ForceProtocol = 'https://';
|
$page->ForceProtocol = 'https://';
|
||||||
$controller = new IFramePageController($page);
|
$controller = new IFramePageController($page);
|
||||||
$controller->doInit();
|
$controller->doInit();
|
||||||
$response = $controller->getResponse();
|
$response = $controller->getResponse();
|
||||||
$this->assertEquals($response->getHeader('Location'), 'https://host.com/iframe/');
|
$this->assertEquals($response->getHeader('Location'), 'https://host.com/iframe/');
|
||||||
|
|
||||||
Config::inst()->update(Director::class, 'alternate_protocol', 'https');
|
Config::modify()->set(Director::class, 'alternate_protocol', 'https');
|
||||||
Config::inst()->update(Director::class, 'alternate_base_url', 'https://host.com');
|
Config::modify()->set(Director::class, 'alternate_base_url', 'https://host.com');
|
||||||
$page->ForceProtocol = 'http://';
|
$page->ForceProtocol = 'http://';
|
||||||
$controller = new IFramePageController($page);
|
$controller = new IFramePageController($page);
|
||||||
$controller->doInit();
|
$controller->doInit();
|
||||||
|
Loading…
Reference in New Issue
Block a user