Skip to content

Commit

Permalink
Merge pull request #151 from dhensby/pulls/phpunit-8
Browse files Browse the repository at this point in the history
Upgrade phpunit
  • Loading branch information
kinglozzer authored Mar 31, 2020
2 parents d92c6a6 + a2631ca commit a19db19
Show file tree
Hide file tree
Showing 21 changed files with 106 additions and 84 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ coverage/
/**/*.js.map
/**/*.css.map
artifacts/
coverage/
/vendor/
/silverstripe-cache/
31 changes: 21 additions & 10 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,17 +1,23 @@
language: php

dist: trusty
dist: xenial

before_install:
- sudo apt-get update
- sudo apt-get install chromium-chromedriver
services:
- mysql
- postgresql
- xvfb

addons:
apt:
packages:
- tidy
- chromium-chromedriver
- chromium-browser

env:
global:
- COMPOSER_ROOT_VERSION=2.x-dev
- TRAVIS_NODE_VERSION="10"
- DISPLAY=":99"
- XVFBARGS=":99 -ac -screen 0 1024x768x16"
- SS_BASE_URL="http://localhost:8080/"
- SS_ENVIRONMENT_TYPE="dev"

Expand All @@ -23,7 +29,7 @@ matrix:
env: DB=MYSQL PHPUNIT_TEST=1
- php: 7.3
env: DB=MYSQL PDO=1 PHPUNIT_COVERAGE_TEST=1
- php: 7.3
- php: 7.4
env: DB=MYSQL PHPUNIT_TEST=1
- php: 7.3
env: DB=PGSQL PHPUNIT_TEST=1 PHPCS_TEST=1 NPM_TEST=1
Expand All @@ -44,9 +50,14 @@ before_script:

# Install composer
- composer validate
- if [[ $DB == PGSQL ]]; then composer require --prefer-dist --no-update silverstripe/postgresql 3.x-dev; fi
- composer require --no-update silverstripe/recipe-testing:^2 silverstripe/recipe-cms 5.x-dev
- composer install --prefer-source
- if [[ $DB == PGSQL ]]; then composer require --no-update silverstripe/postgresql:3.x-dev; fi
- composer require --no-update silverstripe/recipe-testing:^2 silverstripe/recipe-cms:5.x-dev
- composer install --prefer-dist --no-interaction --no-progress --no-suggest --optimize-autoloader --verbose --profile

# Remove preinstalled Chrome (google-chrome)
# this would conflict with our chromium-browser installation
# and its version is incompatible with chromium-chromedriver
- sudo apt-get remove -y --purge google-chrome-stable || true

# Behat bootstrapping
- if [[ $BEHAT_TEST ]]; then mkdir artifacts; fi
Expand Down
2 changes: 1 addition & 1 deletion client/dist/js/bundle.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion client/dist/styles/bundle.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 7 additions & 2 deletions client/src/components/HistoryViewer/HistoryViewer.scss
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
$diff-removed-color: #ffd2da;
$diff-added-color: #b9f1c8;

.history-viewer {
> .panel--padded {
padding-top: 0;
Expand Down Expand Up @@ -68,11 +71,13 @@

.history-viewer__version-detail-diff {
del {
color: $red;
background-color: $diff-removed-color;
border-radius: 1px;
}

ins {
background-color: lighten($green, 70%);
background-color: $diff-added-color;
border-radius: 1px;
text-decoration: none;
}
}
Expand Down
9 changes: 6 additions & 3 deletions client/src/components/HistoryViewer/HistoryViewerToolbar.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,12 @@ class HistoryViewerToolbar extends Component {
const { FormActionComponent, ViewModeComponent, isLatestVersion, isPreviewable } = this.props;
const { isReverting } = this.state;

const revertButtonTitle = isReverting
? i18n._t('HistoryViewerToolbar.REVERT_IN_PROGRESS', 'Revert in progress...')
: i18n._t('HistoryViewerToolbar.REVERT_UNAVAILABLE', 'Unavailable for the current version');
let revertButtonTitle = '';
if (isReverting) {
revertButtonTitle = i18n._t('HistoryViewerToolbar.REVERT_IN_PROGRESS', 'Revert in progress...');
} else if (isLatestVersion) {
revertButtonTitle = i18n._t('HistoryViewerToolbar.REVERT_UNAVAILABLE', 'Unavailable for the current version');
}

return (
<div className="toolbar toolbar--south">
Expand Down
20 changes: 14 additions & 6 deletions client/src/components/HistoryViewer/HistoryViewerVersionDetail.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import FormBuilderLoader from 'containers/FormBuilderLoader/FormBuilderLoader';
import { inject } from 'lib/Injector';
import { versionType } from 'types/versionType';
import PropTypes from 'prop-types';
import url from 'url';
import qs from 'qs';

class HistoryViewerVersionDetail extends PureComponent {
componentWillMount() {
Expand Down Expand Up @@ -89,25 +91,31 @@ class HistoryViewerVersionDetail extends PureComponent {
* @returns {Preview|null}
*/
renderPreview() {
const { version, PreviewComponent, previewState } = this.props;
const {
version: { AbsoluteLink, LastEdited, Version },
PreviewComponent,
previewState
} = this.props;

// Don't render the preview if the view mode is "edit"
if (!this.isPreviewable() || previewState === 'edit') {
return null;
}

// Build HREF for the preview
const parsedURL = url.parse(AbsoluteLink);
const parsedQs = qs.parse(parsedURL.query);
parsedQs.archiveDate = LastEdited;
const href = url.format({ ...parsedURL, search: qs.stringify(parsedQs) });
return (
<PreviewComponent
className="history-viewer__preview flexbox-area-grow" // removes default: fill-height
itemLinks={{
preview: {
Stage: {
href: `${version.AbsoluteLink}&archiveDate=${version.LastEdited}`,
type: 'text/html',
},
Stage: { href, type: 'text/html' },
},
}}
itemId={version.Version}
itemId={Version}
/>
);
}
Expand Down
14 changes: 7 additions & 7 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,16 @@
}
],
"require": {
"silverstripe/admin": "^2@dev",
"silverstripe/framework": "^5@dev",
"silverstripe/versioned": "^2@dev",
"silverstripe/graphql": "^4@dev",
"silverstripe/admin": "^2",
"silverstripe/framework": "^5",
"silverstripe/versioned": "^2",
"silverstripe/graphql": "^4",
"silverstripe/vendor-plugin": "^1"
},
"require-dev": {
"phpunit/phpunit": "^7",
"phpunit/phpunit": "^8 || ^9",
"squizlabs/php_codesniffer": "^3",
"silverstripe/cms": "^5@dev"
"silverstripe/cms": "^5"
},
"scripts": {
"lint": "phpcs src/ tests/",
Expand All @@ -51,4 +51,4 @@
},
"minimum-stability": "dev",
"prefer-stable": true
}
}
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
},
"devDependencies": {
"@silverstripe/eslint-config": "0.0.5",
"@silverstripe/webpack-config": "^1.3.0",
"@silverstripe/webpack-config": "^1.4.0",
"@storybook/addon-actions": "^3.4.11",
"@storybook/addons": "^3.4.11",
"@storybook/react": "^3.4.11",
Expand All @@ -72,6 +72,7 @@
"moment": "^2.21.0",
"popper.js": "^1.14.4",
"prop-types": "^15.6.2",
"qs": "^6.1.0",
"react": "^16.6.1",
"react-apollo": "^2.1.11",
"react-dom": "^16.6.1",
Expand All @@ -80,6 +81,7 @@
"react-router-redux": "^4.0.5",
"reactstrap": "^6.4.0",
"redux": "^3.3.1",
"url": "^0.11.0",
"uuid": "^3.2.1"
},
"babel": {
Expand Down
3 changes: 2 additions & 1 deletion src/ArchiveAdmin.php
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,8 @@ public function getManagedModelTabs()

foreach ($mainModels as $class => $title) {
$classInst = Injector::inst()->get($class);
if (ClassInfo::hasMethod($classInst, 'isArchiveFieldEnabled')
if (
ClassInfo::hasMethod($classInst, 'isArchiveFieldEnabled')
&& $classInst->isArchiveFieldEnabled()
) {
$forms->push(ArrayData::create([
Expand Down
2 changes: 1 addition & 1 deletion src/Controllers/HistoryControllerFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public function create($service, array $params = array())

if ($page && !$this->isEnabled($page)) {
// Injector is not used to prevent an infinite loop
return new CMSPageHistoryController();
return new CMSPageHistoryViewerController();
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/Controllers/HistoryViewerController.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,12 @@ class HistoryViewerController extends LeftAndMain
/**
* @var string
*/
const FORM_NAME_VERSION = 'versionForm';
public const FORM_NAME_VERSION = 'versionForm';

/**
* @var string
*/
const FORM_NAME_COMPARE = 'compareForm';
public const FORM_NAME_COMPARE = 'compareForm';

private static $url_segment = 'historyviewer';

Expand Down
2 changes: 1 addition & 1 deletion src/Forms/DataObjectVersionFormFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class DataObjectVersionFormFactory implements FormFactory
*
* @var string
*/
const TYPE_HISTORY = 'history';
public const TYPE_HISTORY = 'history';

/**
* Define context types that will automatically be converted to readonly forms
Expand Down
Loading

0 comments on commit a19db19

Please sign in to comment.