diff --git a/composer.json b/composer.json index c14f601..d5e2232 100644 --- a/composer.json +++ b/composer.json @@ -24,7 +24,13 @@ "QL\\":"src" } }, + "autoload-dev": { + "psr-4": { + "Tests\\": "tests/" + } + }, "require-dev": { - "symfony/var-dumper": "^3.3" + "symfony/var-dumper": "^3.3", + "phpunit/phpunit": "^7.5" } } diff --git a/phpunit.xml b/phpunit.xml new file mode 100644 index 0000000..ba72a84 --- /dev/null +++ b/phpunit.xml @@ -0,0 +1,19 @@ + + + + ./tests + + + + + + src + + + + \ No newline at end of file diff --git a/tests/Feature/InstanceTest.php b/tests/Feature/InstanceTest.php new file mode 100644 index 0000000..58c268d --- /dev/null +++ b/tests/Feature/InstanceTest.php @@ -0,0 +1,48 @@ +html = $this->getSnippet('snippet-1'); + } + /** + * @test + */ + public function singleton_instance_mode() + { + $ql = QueryList::getInstance()->html($this->html); + $ql2 = QueryList::getInstance(); + $this->assertEquals($ql->getHtml(),$ql2->getHtml()); + + + } + + /** + * @test + */ + public function get_new_object() + { + $ql = (new QueryList())->html($this->html); + $ql2 = new QueryList(); + $this->assertNotEquals($ql->getHtml(),$ql2->getHtml()); + + $ql = QueryList::range('')->html($this->html); + $ql2 = QueryList::range(''); + $this->assertNotEquals($ql->getHtml(),$ql2->getHtml()); + } +} \ No newline at end of file diff --git a/tests/TestCaseBase.php b/tests/TestCaseBase.php new file mode 100644 index 0000000..c88d73e --- /dev/null +++ b/tests/TestCaseBase.php @@ -0,0 +1,20 @@ + +
+ QueryList官网 + 这是图片 + 这是图片2 + QueryList文档 +
+ 其它的一些文本 + \ No newline at end of file diff --git a/tests/bootstrap.php b/tests/bootstrap.php new file mode 100644 index 0000000..eace7af --- /dev/null +++ b/tests/bootstrap.php @@ -0,0 +1,5 @@ +