-
-
Notifications
You must be signed in to change notification settings - Fork 443
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
74 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
<?php | ||
/** | ||
* Created by PhpStorm. | ||
* User: Jaeger <[email protected]> | ||
* Date: 18/12/12 | ||
* Time: 下午12:25 | ||
*/ | ||
|
||
namespace Tests\Dom; | ||
|
||
|
||
use QL\QueryList; | ||
use Tests\TestCaseBase; | ||
use Tightenco\Collect\Support\Collection; | ||
|
||
class RulesTest extends TestCaseBase | ||
{ | ||
protected $html; | ||
protected $ql; | ||
|
||
public function setUp() | ||
{ | ||
$this->html = $this->getSnippet('snippet-2'); | ||
$this->ql = QueryList::html($this->html); | ||
} | ||
|
||
/** | ||
* @test | ||
*/ | ||
public function get_data_by_rules() | ||
{ | ||
$rules = [ | ||
'a' => ['a','text'], | ||
'img_src' => ['img','src'], | ||
'img_alt' => ['img','alt'] | ||
]; | ||
$range = 'ul>li'; | ||
$data = QueryList::rules($rules)->range($range)->html($this->html)->query()->getData(); | ||
$this->assertInstanceOf(Collection::class,$data); | ||
$this->assertCount(3,$data); | ||
$this->assertEquals('http://querylist.com/2.jpg',$data[1]['img_src']); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<div id="one"> | ||
<ul> | ||
<li> | ||
<a href="http://querylist.cc">QueryList官网</a> | ||
<img src="http://querylist.com/1.jpg" alt="这是图片1" abc="这是一个自定义属性1"> | ||
</li> | ||
<li> | ||
<a href="http://v3.querylist.cc">QueryList V3文档</a> | ||
<img src="http://querylist.com/2.jpg" alt="这是图片2" abc="这是一个自定义属性2"> | ||
</li> | ||
<li> | ||
<a href="http://v4.querylist.cc">QueryList V4文档</a> | ||
<img src="http://querylist.com/3.jpg" alt="这是图片3" abc="这是一个自定义属性3"> | ||
</li> | ||
</ul> | ||
</div> |