From 0c02c45f359707e3c49750a66bea8b1fcfa0965c Mon Sep 17 00:00:00 2001 From: xinningsu Date: Sun, 21 Jul 2019 07:54:26 +0800 Subject: [PATCH 1/2] more testing functions --- README.md | 26 ++++++++++++++++++++++++++ tests/ExampleTest.php | 38 ++++++++++++++++++++++++++++++++++---- 2 files changed, 60 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 86711b4..75549ff 100644 --- a/README.md +++ b/README.md @@ -35,6 +35,32 @@ echo $hq('.content')->text(); //this is content... ``` +### Set contents +```php + + + Html Query + + +

this is title

+
this is content...
+ + +'; +$hq = HQ::html($html); + +echo $hq('.title')->html('this is new title')->html(); +//this is new title + +echo $hq('.content')->html('this is new content...'); +//this is new content... + +echo $hq('.content')->text('this is new content...')->html(); +//this is new content... +``` + ### Get attributes ```php @@ -38,7 +38,37 @@ public function testExample1() ); } - public function testExample2() + public function testSetContents() + { + $html = ' + + + Html Query + + +

this is title

+
this is content...
+ + + '; + $hq = HQ::html($html); + + $this->assertEquals( + 'this is new title', + $hq('.title')->html('this is new title')->html() + ); + $this->assertEquals( + 'this is new content...', + $hq('.content')->html('this is new content...')->html() + ); + + $this->assertEquals( + 'this is new content...', + $hq('.content')->text('this is new content...')->html() + ); + } + + public function testGetAttributes() { $html = '
@@ -75,7 +105,7 @@ public function testExample2() ); } - public function testExample3() + public function testChangeAttributes() { $html = '
@@ -136,7 +166,7 @@ public function testExample3() ); } - public function testExample4() + public function testChangeStructure() { $html = '
From 4072430e95673bd38dd849da4b18417b0cc17386 Mon Sep 17 00:00:00 2001 From: xinningsu Date: Sun, 21 Jul 2019 10:30:29 +0800 Subject: [PATCH 2/2] add coveralls --- .gitignore | 1 + .travis.yml | 4 ++++ README.md | 4 ++++ composer.json | 5 +++-- phpunit.xml | 8 ++++++++ 5 files changed, 20 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index 9f9c3c7..b16b17e 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ /.idea /.DS_Store /composer.lock +/build /vendor diff --git a/.travis.yml b/.travis.yml index 0bb31c9..fd4ca46 100644 --- a/.travis.yml +++ b/.travis.yml @@ -10,4 +10,8 @@ install: script: - vendor/bin/phpcs -n --standard=PSR12 --ignore=./vendor/ --extensions=php ./ + - mkdir -p build/logs - vendor/bin/phpunit + +after_success: + - travis_retry php vendor/bin/php-coveralls -v diff --git a/README.md b/README.md index 75549ff..5253a21 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,8 @@ # html-query + +[![MIT licensed](https://img.shields.io/badge/license-MIT-blue.svg)](./LICENSE) +[![Build Status](https://api.travis-ci.org/xinningsu/html-query.svg?branch=master)](https://travis-ci.org/xinningsu/html-query) + A jQuery-like html processor written in PHP # Quick Start diff --git a/composer.json b/composer.json index e523063..0dabfb4 100644 --- a/composer.json +++ b/composer.json @@ -17,7 +17,8 @@ }, "require-dev": { "phpunit/phpunit": "~7.5", - "squizlabs/php_codesniffer": "3.*" + "squizlabs/php_codesniffer": "3.*", + "php-coveralls/php-coveralls": "^2.1" }, "autoload": { "psr-4": { @@ -29,4 +30,4 @@ "tests/" ] } -} \ No newline at end of file +} diff --git a/phpunit.xml b/phpunit.xml index 89d9a38..94fcfd0 100644 --- a/phpunit.xml +++ b/phpunit.xml @@ -14,4 +14,12 @@ ./tests/ + + + + + + ./src + +