Skip to content

Commit 515aa3c

Browse files
committed
Test travis-ci support
1 parent 5e0c41b commit 515aa3c

File tree

4 files changed

+100
-0
lines changed

4 files changed

+100
-0
lines changed

.travis.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
language: php
2+
3+
php:
4+
- 7.0
5+
- 7.1
6+
7+
before_install:
8+
- composer self-update
9+
- composer clear-cache
10+
11+
install:
12+
- travis_retry composer update --no-interaction --no-suggest --prefer-source --optimize-autoloader
13+
14+
script:
15+
- phpunit
16+
17+
after_success:
18+
- bash <(curl -s https://codecov.io/bash)
19+
20+
notifications:
21+
- email: false

composer.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,16 @@
1818
"Html5Gen\\": "src/Html5Gen"
1919
}
2020
},
21+
"autoload-dev": {
22+
"psr-4": {
23+
"Html5Gen\\Tests\\": "tests"
24+
}
25+
},
2126
"require": {
2227
"php": ">=5.5"
28+
},
29+
"require-dev": {
30+
"php": "^7.0",
31+
"phpunit/phpunit": "^6.0"
2332
}
2433
}

phpunit.xml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?xml version="1.0" encoding="UTF-8" ?>
2+
<phpunit bootstrap="vendor/autoload.php">
3+
<testsuites>
4+
<testsuite name="Test">
5+
<directory>tests</directory>
6+
</testsuite>
7+
</testsuites>
8+
<filter>
9+
<whitelist processUncoveredFilesFromWhitelist="true">
10+
<directory suffix=".php">src</directory>
11+
</whitelist>
12+
</filter>
13+
<logging>
14+
<log type="coverage-clover" target="coverage.xml"/>
15+
</logging>
16+
</phpunit>

tests/Html5GenTest.php

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
<?php
2+
3+
namespace Html5Gen\Tests;
4+
5+
use Html5Gen\Html5Gen as H;
6+
use PHPUnit\Framework\TestCase;
7+
8+
class Html5GenTest extends TestCase
9+
{
10+
public function testHtmlDocument()
11+
{
12+
$html =
13+
H::html([], function () {
14+
H::head();
15+
H::body();
16+
});
17+
18+
$expect = <<<HTML
19+
<!DOCTYPE html>
20+
<html>
21+
<head></head>
22+
<body></body>
23+
</html>
24+
25+
HTML;
26+
27+
$this->assertEquals($expect, $html);
28+
}
29+
30+
public function testScript()
31+
{
32+
33+
$html =
34+
H::html([], function() {
35+
H::head([]);
36+
H::body([], function () {
37+
H::script([], function () {
38+
yield 'alert(1);';
39+
});
40+
});
41+
});
42+
43+
$expect = <<<HTML
44+
<!DOCTYPE html>
45+
<html>
46+
<head></head>
47+
<body><script>alert(1);</script></body>
48+
</html>
49+
50+
HTML;
51+
52+
$this->assertEquals($expect, $html);
53+
}
54+
}

0 commit comments

Comments
 (0)