Skip to content

Commit

Permalink
Merge pull request #21 from nojimage/develop
Browse files Browse the repository at this point in the history
Update to v2.0.2
  • Loading branch information
nojimage authored Feb 15, 2018
2 parents a963299 + 79043c3 commit c2f3f18
Show file tree
Hide file tree
Showing 7 changed files with 35 additions and 55 deletions.
20 changes: 20 additions & 0 deletions Changes.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Changes

## 2.0.2

- Pass twitter-text conformance 2.0.5
- Change default configuration to v2 in `Validator`.

## 2.0.1

- Fixes wrong method call in Extractor::extract() #19

## 2.0.0

- Pass twitter-text conformance 2.0.0
- Add to required php extension, `mbstring` and `intl`.
- Add `Parser`, `ParseResults`, `Configuration` class for twitter-text 2.0 "weighted" tweets.
- Twtter\Text classes no longer extended Regex class.
- Deprecated `Validator::isValidTweetText()`, `Validator::getTweetLength()`.
- `Extractor` constractor no longer accepts `$tweet`
- `Validator` constractor no longer accepts `$tweet` and `$config`. `Validator` constractor only accepts `Configuration` incetance.
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@
"type": "package",
"package": {
"name": "twitter/twitter-text",
"version": "2.0.3",
"version": "2.0.5",
"source": {
"url": "https://github.com/twitter/twitter-text.git",
"type": "git",
"reference": "v2.0.3"
"reference": "v2.0.5"
}
}
}
Expand Down
10 changes: 3 additions & 7 deletions lib/Twitter/Text/Regex.php
Original file line number Diff line number Diff line change
Expand Up @@ -351,9 +351,9 @@ private static function getValidDomain()
$validCcTLD = TldLists::getValidCcTLD();

return ''
// subdomains + domain + TLD
// e.g. www.twitter.com, foo.co.jp, bar.co.uk
. '(?:' . $validSubdomain . '+' . $validDomainName
// optional sub-domain + domain + TLD
// e.g. twitter.com, foo.co.jp, bar.co.uk
. '(?:' . $validSubdomain . '*' . $validDomainName
. '(?:' . $validGTLD . '|' . $validCcTLD . '|' . static::$validPunycode . '))'
// domain + gTLD | protocol + unicode domain + gTLD
. '|(?:'
Expand All @@ -363,10 +363,6 @@ private static function getValidDomain()
. ')'
. $validGTLD
. ')'
// domain + gTLD | some ccTLD
// e.g. twitter.com
. '|(?:' . $validDomainName
. '(?:' . static::$validPunycode . '|' . static::$validSpecialCcTLD . '))'
// protocol + (domain | unicode domain) + ccTLD
. '|(?:(?<=http:\/\/|https:\/\/)'
. '(?:' . $validDomainName . '|' . $validUnicodeDomainName . ')'
Expand Down
4 changes: 2 additions & 2 deletions lib/Twitter/Text/Validator.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,8 @@ public function __construct(Configuration $config = null)
public function setConfiguration(Configuration $config = null)
{
if (is_null($config)) {
// default use v1 config
$this->config = Configuration::v1();
// default use v2 config
$this->config = new Configuration();
} elseif (is_a($config, '\Twitter\Text\Configuration')) {
$this->config = $config;
} else {
Expand Down
23 changes: 2 additions & 21 deletions tests/Twitter/Text/ConformanceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -445,9 +445,9 @@ public function highlightProvider()
* @group Validation
* @dataProvider isValidTweetTextProvider
*/
public function testIsValidTweetText($description, $text, $expected)
public function testV1TweetValidity($description, $text, $expected)
{
$validated = $this->validator->isValidTweetText($text);
$validated = $this->validator->isValidTweetText($text, Configuration::v1());
$this->assertSame($expected, $validated, $description);
}

Expand Down Expand Up @@ -554,25 +554,6 @@ public function isValidURLWithoutProtocolProvider()
return $this->providerHelper('validate', 'urls_without_protocol');
}

/**
* @group conformance
* @group Validation
* @dataProvider getTweetLengthProvider
*/
public function testGetTweetLength($description, $text, $expected)
{
$validated = $this->validator->getTweetLength($text);
$this->assertSame($expected, $validated, $description);
}

/**
*
*/
public function getTweetLengthProvider()
{
return $this->providerHelper('validate', 'lengths');
}

/**
* @group conformance
* @group Validaion
Expand Down
23 changes: 2 additions & 21 deletions tests/Twitter/Text/InternalEncodingTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -448,9 +448,9 @@ public function highlightProvider()
* @group Validation
* @dataProvider isValidTweetTextProvider
*/
public function testIsValidTweetText($description, $text, $expected)
public function testV1TweetValidity($description, $text, $expected)
{
$validated = $this->validator->isValidTweetText($text);
$validated = $this->validator->isValidTweetText($text, Configuration::v1());
$this->assertSame($expected, $validated, $description);
}

Expand Down Expand Up @@ -557,25 +557,6 @@ public function isValidURLWithoutProtocolProvider()
return $this->providerHelper('validate', 'urls_without_protocol');
}

/**
* @group encoding
* @group Validation
* @dataProvider getTweetLengthProvider
*/
public function testGetTweetLength($description, $text, $expected)
{
$validated = $this->validator->getTweetLength($text);
$this->assertSame($expected, $validated, $description);
}

/**
*
*/
public function getTweetLengthProvider()
{
return $this->providerHelper('validate', 'lengths');
}

/**
* @group encoding
* @group Validaion
Expand Down
6 changes: 4 additions & 2 deletions tests/Twitter/Text/ValidatorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,11 @@ protected function providerHelper($test)
/**
* @group Validation
*/
public function testDefaultConfigraionIsV1()
public function testDefaultConfigraionIsV2()
{
$this->assertSame(Configuration::v1()->toArray(), $this->validator->getConfiguration()->toArray());
$v2Config = new Configuration();
$this->assertSame($v2Config->toArray(), $this->validator->getConfiguration()->toArray());
$this->assertSame(2, $this->validator->getConfiguration()->version);
}

/**
Expand Down

0 comments on commit c2f3f18

Please sign in to comment.