Skip to content

Commit

Permalink
Updated PHPUnit version to v8 (allows testing on 7.2,7.3,7.4 and PHP …
Browse files Browse the repository at this point in the history
…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
allebb committed Dec 22, 2020
1 parent 42301da commit 88a54e2
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 17 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
fail-fast: false
matrix:
#php-versions: [ '7.3', '7.4', '8.0' ]
php-versions: [ '7.2', '7.3', '7.4' ]
php-versions: [ '7.2', '7.3', '7.4', '8.0' ]

steps:
- name: Checkout
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Requirements

* PHP >= 7.2.0

This library is unit tested against PHP 7.2, 7.3 and 7.4!
This library is unit tested against PHP 7.2, 7.3, 7.4 and 8.0!

License
-------
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"php": ">=7.2.0"
},
"require-dev": {
"phpunit/phpunit": "5.7.*"
"phpunit/phpunit": "^8.0"
},
"autoload": {
"psr-4": {
Expand Down
1 change: 0 additions & 1 deletion phpunit.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
processIsolation="false"
stopOnError="false"
stopOnFailure="false"
syntaxCheck="true"
verbose="true"
>
<testsuites>
Expand Down
16 changes: 12 additions & 4 deletions tests/ConfigurationTest.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

use Ballen\Linguist\Configuration;
use PHPUnit\Framework\TestCase;

/**
* Linguist
Expand All @@ -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
{

/**
Expand All @@ -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.
}

/**
Expand Down
28 changes: 19 additions & 9 deletions tests/ParserTest.php
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
Expand All @@ -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";
Expand All @@ -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()
Expand Down Expand Up @@ -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');
}

Expand Down Expand Up @@ -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()
);
}
}

0 comments on commit 88a54e2

Please sign in to comment.