-
Notifications
You must be signed in to change notification settings - Fork 6
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
2 changed files
with
52 additions
and
2 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
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,50 @@ | ||
<?php | ||
use Ricoa\CopyWritingCorrect\CopyWritingCorrectService; | ||
|
||
/** | ||
* 纠正器注入、重置功能 | ||
* Class CorrectorTest | ||
*/ | ||
class CorrectorTest extends \PHPUnit_Framework_TestCase | ||
{ | ||
protected function setUp() | ||
{ | ||
} | ||
|
||
protected function tearDown() | ||
{ | ||
} | ||
|
||
// tests | ||
public function testMe() | ||
{ | ||
|
||
$service=new CopyWritingCorrectService(); | ||
|
||
$correctors=[new class extends \Ricoa\CopyWritingCorrect\Correctors\Corrector{ | ||
protected static $corrector=null; | ||
/** | ||
* @param string $text | ||
* | ||
* @return mixed | ||
*/ | ||
public function handle($text) | ||
{ | ||
return $text; | ||
} | ||
}]; | ||
$service->addCorrectors($correctors);//注入纠正器 | ||
|
||
$this->assertEquals( | ||
'使用 GitHub 登录', | ||
$service->correct('使用github登录') | ||
); | ||
|
||
$service->resetCorrectors($correctors);//重置纠正器,也即废弃默认的纠正器 | ||
|
||
$this->assertEquals( | ||
'使用github登录', | ||
$service->correct('使用github登录') | ||
); | ||
} | ||
} |