Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support php8 #4

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
language: php

php:
- 7.0
- 7.1
- 7.2
- 7.3
- 8.0

before_script:
- travis_retry composer self-update --preview
- travis_retry composer self-update
- travis_retry composer install --prefer-dist --no-interaction

script:
Expand Down
6 changes: 3 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@
"require": {
"php": ">=7.0",
"botman/botman": "~2.0",
"abraham/twitteroauth": "^0.9.2"
"abraham/twitteroauth": "^0.9.2|^2.0"
},
"require-dev": {
"botman/studio-addons": "~1.0",
"illuminate/contracts": "~5.5.0",
"phpunit/phpunit": "~5.0",
"mockery/mockery": "dev-master",
"phpunit/phpunit": "~5.0|^8.0|^9.0",
"mockery/mockery": "1.3.x-dev|dev-master",
"ext-curl": "*"
},
"autoload": {
Expand Down
1 change: 0 additions & 1 deletion phpunit.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false"
syntaxCheck="false"
>
<testsuites>
<testsuite name="Package Test Suite">
Expand Down
5 changes: 2 additions & 3 deletions src/TwitterDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ public function buildPayload(Request $request)
public function matchesRequest()
{
if (isset($this->headers['x-twitter-webhooks-signature'])) {

$signature = $this->headers['x-twitter-webhooks-signature'][0];
$hash = hash_hmac('sha256', json_encode($this->payload->all()), $this->config->get('consumer_secret'), true);

Expand All @@ -75,7 +74,7 @@ public function getMessages()
$message = $event['message_create'];

return new IncomingMessage($message['message_data']['text'], $message['sender_id'], $message['target']['recipient_id'], $event);
})->toArray();
})->toArray();
}

/**
Expand Down Expand Up @@ -111,7 +110,7 @@ public function getConversationAnswer(IncomingMessage $message)
$payload = $message->getPayload();
$answer = Answer::create($message->getText())->setMessage($message);

if(isset($payload['message_create']['message_data']['quick_reply_response']['metadata'])) {
if (isset($payload['message_create']['message_data']['quick_reply_response']['metadata'])) {
$answer->setInteractiveReply(true);
$answer->setValue($payload['message_create']['message_data']['quick_reply_response']['metadata']);
}
Expand Down
14 changes: 11 additions & 3 deletions tests/TwitterDriverTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,16 @@
use BotMan\BotMan\Http\Curl;
use PHPUnit_Framework_TestCase;
use BotMan\Drivers\Twitter\TwitterDriver;
use PHPUnit\Framework\TestCase;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;

class TwitterDriverTest extends PHPUnit_Framework_TestCase
class TwitterDriverTest extends TestCase
{
const TEST_SECRET = 'test';
const TEST_KEY = 'test';

public function tearDown()
protected function tearDown(): void
{
m::close();
}
Expand Down Expand Up @@ -88,6 +90,7 @@ private function getValidDriver()

return new TwitterDriver($request, [
'twitter' => [
'consumer_key' => self::TEST_KEY,
'consumer_secret' => self::TEST_SECRET
]
], $htmlInterface);
Expand All @@ -103,7 +106,12 @@ private function getDriver($responseData, $htmlInterface = null)

$request->headers->add(['x-twitter-webhooks-signature' => 'signature']);

return new TwitterDriver($request, [], $htmlInterface);
return new TwitterDriver($request, [
'twitter' => [
'consumer_key' => self::TEST_KEY,
'consumer_secret' => self::TEST_SECRET
]
], $htmlInterface);
}

/** @test */
Expand Down