-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Updated PHPUnit version to v8 (allows testing on 7.2,7.3,7.4 and PHP …
…8.0). Test cases have been updated to make it compatible with the new test framework API. GitHub Actions manifest now updated to build on PHP 8.0 too.
- Loading branch information
Showing
6 changed files
with
34 additions
and
17 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
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
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 |
---|---|---|
@@ -1,5 +1,7 @@ | ||
<?php | ||
|
||
use Ballen\Linguist\Configuration; | ||
use PHPUnit\Framework\TestCase; | ||
|
||
/** | ||
* Linguist | ||
|
@@ -10,11 +12,11 @@ | |
* | ||
* @author Bobby Allen <[email protected]> | ||
* @license http://www.gnu.org/licenses/gpl-3.0.html | ||
* @link https://github.com/bobsta63/linguist | ||
* @link https://github.com/allebb/linguist | ||
* @link http://www.bobbyallen.me | ||
* | ||
*/ | ||
class ConfigurationTest extends \PHPUnit_Framework_TestCase | ||
class ConfigurationTest extends TestCase | ||
{ | ||
|
||
/** | ||
|
@@ -37,9 +39,15 @@ public function testCustomTagConfiguaration() | |
{ | ||
$instance = new Configuration(); | ||
$instance->push('assignment', 'assign>', 'https://exampleapp.com/assign/%s'); | ||
$this->assertArrayHasKey('assignment', $instance->get()); // Check that custom assignment section has been added... | ||
$this->assertArrayHasKey( | ||
'assignment', | ||
$instance->get() | ||
); // Check that custom assignment section has been added... | ||
$instance->drop('assignment'); | ||
$this->assertArrayNotHasKey('assignment', $instance->get()); // Check that the custom config has been removed successfully. | ||
$this->assertArrayNotHasKey( | ||
'assignment', | ||
$instance->get() | ||
); // Check that the custom config has been removed successfully. | ||
} | ||
|
||
/** | ||
|
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 |
---|---|---|
@@ -1,6 +1,8 @@ | ||
<?php | ||
|
||
use Ballen\Linguist\Parser as TagParser; | ||
use Ballen\Linguist\Configuration as TagConfiguration; | ||
use PHPUnit\Framework\TestCase; | ||
|
||
/** | ||
* Linguist | ||
|
@@ -11,11 +13,11 @@ | |
* | ||
* @author Bobby Allen <[email protected]> | ||
* @license http://www.gnu.org/licenses/gpl-3.0.html | ||
* @link https://github.com/bobsta63/linguist | ||
* @link https://github.com/allebb/linguist | ||
* @link http://www.bobbyallen.me | ||
* | ||
*/ | ||
class ParserTest extends \PHPUnit_Framework_TestCase | ||
class ParserTest extends TestCase | ||
{ | ||
|
||
const EXAMPLE_TWEET_1 = "Hey @bobsta63, this example is for parsing plain-text tweet strings into HTML right? #questions #howto"; | ||
|
@@ -24,13 +26,19 @@ class ParserTest extends \PHPUnit_Framework_TestCase | |
public function testTwitterExampleToHtml() | ||
{ | ||
$instance = new TagParser(self::EXAMPLE_TWEET_1, (new TagConfiguration)->loadDefault()); | ||
$this->assertEquals('Hey <a href = "https://twitter.com/bobsta63" target="_blank">@bobsta63</a>, this example is for parsing plain-text tweet strings into HTML right? <a href = "https://twitter.com/hashtag/questions" target="_blank">#questions</a> <a href = "https://twitter.com/hashtag/howto" target="_blank">#howto</a>', $instance->html()->get()); | ||
$this->assertEquals( | ||
'Hey <a href = "https://twitter.com/bobsta63" target="_blank">@bobsta63</a>, this example is for parsing plain-text tweet strings into HTML right? <a href = "https://twitter.com/hashtag/questions" target="_blank">#questions</a> <a href = "https://twitter.com/hashtag/howto" target="_blank">#howto</a>', | ||
$instance->html()->get() | ||
); | ||
} | ||
|
||
public function testTwitterExampleToMarkdown() | ||
{ | ||
$instance = new TagParser(self::EXAMPLE_TWEET_1, (new TagConfiguration)->loadDefault()); | ||
$this->assertEquals('Hey [https://twitter.com/bobsta63](@bobsta63), this example is for parsing plain-text tweet strings into HTML right? [https://twitter.com/hashtag/questions](#questions) [https://twitter.com/hashtag/howto](#howto)', $instance->markdown()->get()); | ||
$this->assertEquals( | ||
'Hey [https://twitter.com/bobsta63](@bobsta63), this example is for parsing plain-text tweet strings into HTML right? [https://twitter.com/hashtag/questions](#questions) [https://twitter.com/hashtag/howto](#howto)', | ||
$instance->markdown()->get() | ||
); | ||
} | ||
|
||
public function testTwitterExampleGetMentions() | ||
|
@@ -62,14 +70,14 @@ public function testGetTopicConfigurationArray() | |
public function testGetInvalidTagArray() | ||
{ | ||
$instance = new TagParser(self::EXAMPLE_TWEET_1, (new TagConfiguration)->loadDefault()); | ||
$this->setExpectedException('\InvalidArgumentException', 'The tag "locations" has no results.'); | ||
$this->expectException('\InvalidArgumentException', 'The tag "locations" has no results.'); | ||
$instance->tags('locations'); | ||
} | ||
|
||
public function testGetInvalidTagConfigurationArray() | ||
{ | ||
$instance = new TagParser(self::EXAMPLE_TWEET_1, (new TagConfiguration)->loadDefault()); | ||
$this->setExpectedException('\InvalidArgumentException', 'The tag "locations" is not registered!'); | ||
$this->expectException('\InvalidArgumentException', 'The tag "locations" is not registered!'); | ||
$instance->tag('locations'); | ||
} | ||
|
||
|
@@ -98,17 +106,19 @@ public function testCallTagsUsingInvalidTagMagicMethod() | |
$custom_config = new TagConfiguration(); | ||
$custom_config->loadDefault(); | ||
$instance = new TagParser(self::EXAMPLE_TWEET_1, $custom_config); | ||
$this->setExpectedException('RuntimeException', 'Invalid tag type(s) requested.'); | ||
$this->expectException('RuntimeException', 'Invalid tag type(s) requested.'); | ||
$this->assertEquals(1, count($instance->assignment())); | ||
} | ||
|
||
public function testHtmlTransformerWithLink() | ||
{ | ||
|
||
$custom_config = new TagConfiguration(); | ||
$custom_config->push('assignment', 'assign>', 'https://exampleapp.com/assign/%s', true, 'btn btn-link'); | ||
$instance = new TagParser(self::EXAMPLE_TWEET_2); | ||
$instance->setConfiguration($custom_config); | ||
$this->assertEquals('An example support ticket reply, <a href = "https://exampleapp.com/assign/bobby" class="btn btn-link" target="_blank">assign>bobby</a> this will attempt to reassign this ticket example (to an agent who is called \'bobby\').', $instance->html()->get()); | ||
$this->assertEquals( | ||
'An example support ticket reply, <a href = "https://exampleapp.com/assign/bobby" class="btn btn-link" target="_blank">assign>bobby</a> this will attempt to reassign this ticket example (to an agent who is called \'bobby\').', | ||
$instance->html()->get() | ||
); | ||
} | ||
} |