Skip to content

Commit da85190

Browse files
atymicreliq
andauthored
Remove tmhoauth & replace with Guzzle (#273)
* chore: add code coverage to ci * feat: switch to guzzle WIP * feat: fix tests + laravel construct * feat: handle exceptions * fix: test bench vers, fast fail off * fix: case delimeter in handleClientException() * restore tests, progress * chore: cutover to phpunit.xml.dist * chore: oauth/guzzle implementation * fix: github actions workflow * chore: update skip message * pr changes Co-authored-by: Reliq <[email protected]>
1 parent c6bb315 commit da85190

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+1427
-4452
lines changed

.github/workflows/php.yml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,12 @@ jobs:
77
runs-on: ubuntu-latest
88
strategy:
99
max-parallel: 15
10+
fail-fast: false
1011
matrix:
1112
laravel-version: ['5.8.*', '^6.0']
1213
stabilty: ['stable', 'lowest']
1314
php-versions: ['7.2', '7.3']
14-
name: PHP ${{ matrix.php-versions }} on ${{ matrix.laravel-version }} (${{ matrix.stabilty }})
15+
name: PHP ${{ matrix.php-versions }} on Laravel ${{ matrix.laravel-version }} (${{ matrix.stabilty }})
1516
steps:
1617
- name: Checkout
1718
uses: actions/checkout@master
@@ -29,3 +30,9 @@ jobs:
2930
run: composer validate
3031
- name: Run Tests
3132
run: composer test:ci
33+
env:
34+
CI_TESTING: 'github-actions'
35+
- name: Upload code coverage
36+
uses: codecov/[email protected]
37+
with:
38+
token: ${{secrets.CODECOV_TOKEN}}

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,8 @@
44
composer.phar
55
composer.lock
66
.DS_Store
7+
*.cache
78
.idea
89
.phpunit.result.cache
10+
phpunit.xml
11+
temp/

.php_cs

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
<?php
2+
3+
$finder = PhpCsFixer\Finder::create()
4+
->exclude([
5+
'.github',
6+
])
7+
->in(__DIR__);
8+
9+
$config = PhpCsFixer\Config::create()
10+
->setRiskyAllowed(true)
11+
->setRules([
12+
'@PHP56Migration' => true,
13+
'@PHPUnit60Migration:risky' => true,
14+
'@Symfony' => true,
15+
'@Symfony:risky' => false,
16+
'align_multiline_comment' => true,
17+
'array_indentation' => true,
18+
'array_syntax' => ['syntax' => 'short'],
19+
'blank_line_before_statement' => true,
20+
'binary_operator_spaces' => ['default' => 'single_space'],
21+
'combine_consecutive_issets' => true,
22+
'combine_consecutive_unsets' => true,
23+
'comment_to_phpdoc' => true,
24+
'compact_nullable_typehint' => true,
25+
'cast_spaces' => ['space' => 'none'],
26+
'concat_space' => ['spacing' => 'one'],
27+
'escape_implicit_backslashes' => true,
28+
'explicit_indirect_variable' => true,
29+
'explicit_string_variable' => true,
30+
'final_internal_class' => true,
31+
'fully_qualified_strict_types' => true,
32+
'function_to_constant' => ['functions' => ['get_class', 'get_called_class', 'php_sapi_name', 'phpversion', 'pi']],
33+
// 'header_comment' => ['header' => $header],
34+
'heredoc_to_nowdoc' => true,
35+
'list_syntax' => ['syntax' => 'long'],
36+
'logical_operators' => true,
37+
'method_argument_space' => ['on_multiline' => 'ensure_fully_multiline'],
38+
'method_chaining_indentation' => true,
39+
'multiline_comment_opening_closing' => true,
40+
'no_alternative_syntax' => true,
41+
'no_binary_string' => true,
42+
'no_extra_blank_lines' => ['tokens' => ['break', 'continue', 'extra', 'return', 'throw', 'use', 'parenthesis_brace_block', 'square_brace_block', 'curly_brace_block']],
43+
'no_null_property_initialization' => true,
44+
'no_short_echo_tag' => true,
45+
'no_superfluous_elseif' => true,
46+
'no_unneeded_curly_braces' => true,
47+
'no_unneeded_final_method' => true,
48+
'no_unreachable_default_argument_value' => true,
49+
'no_unset_on_property' => true,
50+
'no_useless_else' => true,
51+
'no_useless_return' => true,
52+
'ordered_class_elements' => true,
53+
'ordered_imports' => true,
54+
'php_unit_internal_class' => true,
55+
'php_unit_method_casing' => true,
56+
'php_unit_ordered_covers' => true,
57+
'php_unit_set_up_tear_down_visibility' => true,
58+
'php_unit_strict' => true,
59+
'php_unit_test_annotation' => true,
60+
'php_unit_test_case_static_method_calls' => ['call_type' => 'this'],
61+
'php_unit_test_class_requires_covers' => true,
62+
'phpdoc_add_missing_param_annotation' => true,
63+
'phpdoc_order' => true,
64+
'phpdoc_trim_consecutive_blank_line_separation' => true,
65+
'phpdoc_types_order' => true,
66+
'return_assignment' => true,
67+
'semicolon_after_instruction' => true,
68+
'single_line_comment_style' => true,
69+
'strict_comparison' => true,
70+
'strict_param' => true,
71+
'string_line_ending' => true,
72+
'yoda_style' => false,
73+
])
74+
->setFinder($finder);
75+
76+
// special handling of fabbot.io service if it's using too old PHP CS Fixer version
77+
if (false !== getenv('FABBOT_IO')) {
78+
try {
79+
PhpCsFixer\FixerFactory::create()
80+
->registerBuiltInFixers()
81+
->registerCustomFixers($config->getCustomFixers())
82+
->useRuleSet(new PhpCsFixer\RuleSet($config->getRules()));
83+
} catch (PhpCsFixer\ConfigurationException\InvalidConfigurationException $e) {
84+
$config->setRules([]);
85+
} catch (UnexpectedValueException $e) {
86+
$config->setRules([]);
87+
} catch (InvalidArgumentException $e) {
88+
$config->setRules([]);
89+
}
90+
}
91+
92+
return $config;

composer.json

Lines changed: 29 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,58 @@
11
{
2-
"name": "thujohn/twitter",
3-
"description": "Twitter API for Laravel",
4-
"keywords": ["twitter", "laravel", "laravel4", "laravel5"],
2+
"name": "atymic/twitter",
3+
"description": "Twitter API for PHP & Laravel",
4+
"keywords": ["twitter", "laravel", "laravel5", "laravel6"],
55
"license": "MIT",
6+
"type": "library",
67
"authors": [
7-
{
8-
"name": "thujohn",
9-
"email": "[email protected]"
10-
},
118
{
129
"name": "atymic",
1310
"email": "[email protected]",
1411
"homepage": "https://atymic.dev"
12+
},
13+
{
14+
"name": "reliq",
15+
"email": "[email protected]",
16+
"homepage": "https://iamreliq.com"
1517
}
1618
],
1719
"require": {
18-
"php": ">7.0",
20+
"php": ">7.2",
21+
"ext-json": "*",
1922
"illuminate/support": "~5.5 || ~6.0",
20-
"themattharris/tmhoauth": "0.8.4"
23+
"guzzlehttp/guzzle": "^6.4",
24+
"psr/log": "^1.1",
25+
"nesbot/carbon": "^2.26",
26+
"guzzlehttp/oauth-subscriber": "^0.3.0"
2127
},
2228
"require-dev": {
23-
"phpunit/phpunit": "^8.3"
29+
"phpunit/phpunit": "^8.3",
30+
"orchestra/testbench": "~3.8.0 || ~4.0.0"
2431
},
2532
"autoload": {
26-
"psr-0": {
27-
"Thujohn\\Twitter": "src/"
33+
"psr-4": {
34+
"Atymic\\Twitter\\": "src/"
2835
}
2936
},
37+
"autoload-dev": {
38+
"psr-4": {
39+
"Atymic\\Twitter\\Tests\\": "tests"
40+
},
41+
"files": [
42+
"vendor/phpunit/phpunit/src/Framework/Assert/Functions.php"
43+
]
44+
},
3045
"scripts": {
3146
"test": "phpunit",
3247
"test:ci": "phpunit --verbose --coverage-clover=coverage.xml"
3348
},
3449
"extra": {
3550
"laravel": {
3651
"providers": [
37-
"Thujohn\\Twitter\\TwitterServiceProvider"
52+
"Atymic\\Twitter\\TwitterServiceProvider"
3853
],
3954
"aliases": {
40-
"Twitter": "Thujohn\\Twitter\\Facades\\Twitter"
55+
"Twitter": "Atymic\\Twitter\\Facades\\Twitter"
4156
}
4257
}
4358
},

config/twitter.php

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<?php
2+
3+
// You can find the keys here : https://apps.twitter.com/
4+
5+
return [
6+
'debug' => env('APP_DEBUG', false),
7+
8+
'api_url' => 'api.twitter.com',
9+
'upload_url' => 'upload.twitter.com',
10+
'api_version' => '1.1',
11+
12+
'consumer_key' => env('TWITTER_CONSUMER_KEY'),
13+
'consumer_secret' => env('TWITTER_CONSUMER_SECRET'),
14+
'access_token' => env('TWITTER_ACCESS_TOKEN'),
15+
'access_token_secret' => env('TWITTER_ACCESS_TOKEN_SECRET'),
16+
17+
// todo deal with these
18+
'authenticate_url' => 'https://api.twitter.com/oauth/authenticate',
19+
'authorize_url' => 'https://api.twitter.com/oauth/authorize',
20+
'access_token_url' => 'https://api.twitter.com/oauth/access_token',
21+
'request_token_url' => 'https://api.twitter.com/oauth/request_token',
22+
];

phpunit.xml

Lines changed: 0 additions & 17 deletions
This file was deleted.

phpunit.xml.dist

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<phpunit backupGlobals="false"
3+
backupStaticAttributes="false"
4+
bootstrap="vendor/autoload.php"
5+
colors="true"
6+
convertErrorsToExceptions="true"
7+
convertNoticesToExceptions="true"
8+
convertWarningsToExceptions="true"
9+
processIsolation="false"
10+
stopOnFailure="false">
11+
<testsuites>
12+
<testsuite name="package">
13+
<directory suffix="Test.php">tests</directory>
14+
</testsuite>
15+
</testsuites>
16+
<filter>
17+
<whitelist processUncoveredFilesFromWhitelist="true">
18+
<directory suffix=".php">src</directory>
19+
</whitelist>
20+
</filter>
21+
<php>
22+
<env name="APP_ENV" value="testing"/>
23+
<env name="CACHE_DRIVER" value="array"/>
24+
<env name="SESSION_DRIVER" value="array"/>
25+
<env name="DB_DATABASE" value="test"/>
26+
<env name="DB_USERNAME" value="testing"/>
27+
<env name="DB_PASSWORD" value="testing"/>
28+
<env name="TWITTER_CONSUMER_KEY" value=""/>
29+
<env name="TWITTER_CONSUMER_SECRET" value=""/>
30+
<env name="TWITTER_ACCESS_TOKEN" value=""/>
31+
<env name="TWITTER_ACCESS_TOKEN_SECRET" value=""/>
32+
</php>
33+
</phpunit>

0 commit comments

Comments
 (0)