Skip to content

Commit b198d20

Browse files
author
Dylan Wagstaff
committed
API Updated classes and CI to support SilverStripe 4.0
Now that SilverStripe Framework makes use of namespaces and the vendor folder with composer's autoloader, we need up update numerious sections of the code base in non backwards compatible ways.
1 parent ddb638b commit b198d20

12 files changed

+89
-63
lines changed

.gitattributes

+1
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@
44
/.gitignore export-ignore
55
/.travis.yml export-ignore
66
/.scrutinizer.yml export-ignore
7+
/codecov.yml export-ignore

.scrutinizer.yml

+6
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
inherit: true
22

3+
build:
4+
nodes:
5+
analysis:
6+
tests:
7+
override: [php-scrutinizer-run]
8+
39
checks:
410
php:
511
code_rating: true

.travis.yml

+21-21
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,33 @@
1-
# See https://github.com/silverstripe/silverstripe-travis-support for setup details
2-
3-
sudo: false
4-
51
language: php
62

7-
php:
8-
- 5.4
9-
- 5.5
10-
113
env:
12-
- DB=MYSQL CORE_RELEASE=3.5
4+
global:
5+
- COMPOSER_ROOT_VERSION=2.0.x-dev
136

147
matrix:
158
include:
169
- php: 5.6
17-
env: DB=MYSQL CORE_RELEASE=3
18-
- php: 5.6
19-
env: DB=MYSQL CORE_RELEASE=3.1
20-
- php: 5.6
21-
env: DB=PGSQL CORE_RELEASE=3.2
10+
env: DB=MYSQL PHPCS_TEST=1 PHPUNIT_TEST=1
11+
- php: 7.0
12+
env: DB=MYSQL PHPUNIT_TEST=1
2213
- php: 7.1
23-
env: DB=MYSQL CORE_RELEASE=3.6
14+
env: DB=PGSQL PHPUNIT_COVERAGE_TEST=1
2415

2516
before_script:
26-
- composer self-update || true
27-
- git clone git://github.com/silverstripe/silverstripe-travis-support.git ~/travis-support
28-
- php ~/travis-support/travis_setup.php --source `pwd` --target ~/builds/ss
29-
- cd ~/builds/ss
30-
- composer install
17+
# Init PHP
18+
- phpenv rehash
19+
- phpenv config-rm xdebug.ini
20+
21+
# Install composer dependencies
22+
- composer validate
23+
- composer require --no-update silverstripe/recipe-core:1.0.x-dev
24+
- if [[ $DB == PGSQL ]]; then composer require --no-update silverstripe/postgresql 2.0.x-dev; fi
25+
- composer install --prefer-dist --no-interaction --no-progress --no-suggest --optimize-autoloader --verbose --profile
3126

3227
script:
33-
- vendor/bin/phpunit html5/tests
28+
- if [[ $PHPUNIT_TEST ]]; then vendor/bin/phpunit; fi
29+
- if [[ $PHPUNIT_COVERAGE_TEST ]]; then phpdbg -qrr vendor/bin/phpunit --coverage-clover=coverage.xml; fi
30+
- if [[ $PHPCS_TEST ]]; then vendor/bin/phpcs code/ tests/; fi
31+
32+
after_success:
33+
- if [[ $PHPUNIT_COVERAGE_TEST ]]; then bash <(curl -s https://codecov.io/bash) -f coverage.xml; fi

README.md

+4-5
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,13 @@
22

33
[![Build Status](https://travis-ci.org/silverstripe/silverstripe-html5.svg?branch=master)](https://travis-ci.org/silverstripe/silverstripe-html5)
44
[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/silverstripe/silverstripe-html5/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/silverstripe/silverstripe-html5/?branch=master)
5-
6-
## Maintainer Contact
7-
8-
* Hamish Friedlander <[email protected]>
5+
[![codecov](https://codecov.io/gh/silverstripe/silverstripe-html5/branch/master/graph/badge.svg)](https://codecov.io/gh/silverstripe/silverstripe-html5)
96

107
## Requirements
118

12-
* SilverStripe 3.1 or higher
9+
* SilverStripe 4.0 or higher
10+
11+
For a SilverStripe 3.x compatible version of this module, please see the [1.0 branch, or 1.x release line](https://github.com/silverstripe/silverstripe-html5/tree/1.0#readme).
1312

1413
## Summary
1514

_config/html.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
After: 'framework/html'
33
---
4-
Injector:
5-
HTMLValue:
6-
class: SS_HTML5Value
4+
SilverStripe\Core\Injector\Injector:
5+
SilverStripe\View\Parsers\HTMLValue:
6+
class: SilverStripe\HTML5\HTML5Value

changelog.md

-12
This file was deleted.

code/HTML5Value.php

+7-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
<?php
22

3-
class SS_HTML5Value extends SS_HTMLValue
3+
namespace SilverStripe\HTML5;
4+
5+
use Exception;
6+
use SilverStripe\View\Parsers\HTMLValue;
7+
8+
class HTML5Value extends HTMLValue
49
{
510
public function setContent($content)
611
{
@@ -16,7 +21,7 @@ function ($no, $str) {
1621

1722
// Use HTML5lib to parse the HTML fragment
1823
try {
19-
$document = HTML5_Parser::parse(
24+
$document = \HTML5_Parser::parse(
2025
'<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></head>'.
2126
"<body>$content</body></html>"
2227
);

codecov.yml

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
comment: false
2+

composer.json

+10-4
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,21 @@
77
"require": {
88
"silverstripe/framework": "^4"
99
},
10+
"require-dev": {
11+
"phpunit/phpunit": "^5.7",
12+
"squizlabs/php_codesniffer": "^3.0"
13+
},
1014
"autoload": {
1115
"psr-4": {
12-
"SilverStripe\\Html5\\": "code",
13-
"SilverStripe\\Html5\\Tests\\": "tests"
16+
"SilverStripe\\HTML5\\": "code",
17+
"SilverStripe\\HTML5\\Tests\\": "tests"
1418
}
1519
},
1620
"extra": {
1721
"branch-alias": {
18-
"dev-pulls/2.0/make-a-2.0": "2.0.x-dev"
22+
"dev-master": "2.x-dev"
1923
}
20-
}
24+
},
25+
"prefer-stable": true,
26+
"minimum-stability": "dev"
2127
}

license.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Copyright (c) 2016, SilverStripe Limited
1+
Copyright (c) 2017, SilverStripe Limited
22
All rights reserved.
33

44
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

phpunit.xml.dist

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<phpunit bootstrap="vendor/silverstripe/framework/tests/bootstrap.php" colors="true">
2+
<testsuite name="Default">
3+
<directory>tests/</directory>
4+
</testsuite>
5+
<filter>
6+
<whitelist addUncoveredFilesFromWhitelist="true">
7+
<directory suffix=".php">code/</directory>
8+
<exclude>
9+
<directory suffix=".php">tests/</directory>
10+
</exclude>
11+
</whitelist>
12+
</filter>
13+
</phpunit>

tests/HTML5ValueTest.php

+21-15
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,26 @@
11
<?php
2+
3+
namespace SilverStripe\HTML5\Tests;
4+
5+
use SilverStripe\HTML5\HTML5Value;
6+
use SilverStripe\Dev\SapphireTest;
7+
28
/**
39
* @package framework
410
* @subpackage tests
511
*/
6-
class SS_HTML5ValueTest extends SapphireTest
12+
class HTML5ValueTest extends SapphireTest
713
{
814
public function testInvalidHTMLParsing()
915
{
10-
$value = new SS_HTML5Value();
16+
$value = new HTML5Value();
17+
18+
$invalid = [
19+
'<p>Enclosed Value</p></p>' => '<p>Enclosed Value</p><p></p>',
20+
'<meta content="text/html"></meta>' => '<meta content="text/html">',
21+
'<p><div class="example"></div></p>' => '<p></p><div class="example"></div><p></p>'
22+
];
1123

12-
$invalid = array(
13-
'<p>Enclosed Value</p></p>' => '<p>Enclosed Value</p><p></p>',
14-
'<meta content="text/html"></meta>' => '<meta content="text/html">',
15-
'<p><div class="example"></div></p>' => '<p></p><div class="example"></div><p></p>'
16-
);
17-
1824
foreach ($invalid as $input => $expected) {
1925
$value->setContent($input);
2026
$this->assertEquals($expected, $value->getContent(), 'Invalid HTML can be parsed');
@@ -23,29 +29,29 @@ public function testInvalidHTMLParsing()
2329

2430
public function testUtf8Saving()
2531
{
26-
$value = new SS_HTML5Value();
32+
$value = new HTML5Value();
2733

2834
$value->setContent('<p>ö ß ā い 家</p>');
2935
$this->assertEquals('<p>ö ß ā い 家</p>', $value->getContent());
3036
}
3137

3238
public function testWhitespaceHandling()
3339
{
34-
$value = new SS_HTML5Value();
40+
$value = new HTML5Value();
3541

3642
$value->setContent('<p></p> <p></p>');
3743
$this->assertEquals('<p></p> <p></p>', $value->getContent());
3844
}
3945

4046
public function testInvalidHTMLTagNames()
4147
{
42-
$value = new SS_HTML5Value();
48+
$value = new HTML5Value();
4349

44-
$invalid = array(
50+
$invalid = [
4551
'<p><div><a href="test-link"></p></div>',
4652
'<html><div><a href="test-link"></a></a></html_>'
47-
);
48-
53+
];
54+
4955
foreach ($invalid as $input) {
5056
$value->setContent($input);
5157

@@ -59,7 +65,7 @@ public function testInvalidHTMLTagNames()
5965

6066
public function testMixedNewlines()
6167
{
62-
$value = new SS_HTML5Value();
68+
$value = new HTML5Value();
6369

6470
$value->setContent("<p>paragraph</p>\n<ul><li>1</li>\r\n</ul>");
6571
$this->assertEquals(

0 commit comments

Comments
 (0)