Skip to content

Commit

Permalink
Merge pull request #171 from wittfabian/fb-travis-ci
Browse files Browse the repository at this point in the history
Add travis ci and tests
  • Loading branch information
wittfabian authored May 18, 2019
2 parents 1054610 + bcd1226 commit 67f8c56
Show file tree
Hide file tree
Showing 35 changed files with 1,962 additions and 50 deletions.
2 changes: 2 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,6 @@ Summary of changes proposed in this Pull Request:
-

PR checklist:
- [ ] Updated relevant documentation
- [ ] Updated CHANGELOG.md
- [ ] Added tests for my change
10 changes: 10 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -70,3 +70,13 @@ crashlytics.properties
crashlytics-build.properties
fabric.properties

# composer
/vendor/
composer.phar

# Project
phpunit.phar
.phpunit.result.cache
phpunit.xml
/build/
.env
27 changes: 27 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
language: php

sudo: false

php:
- 7.1
- 7.2
- 7.3

branches:
only:
- master
- fb-travis-ci

before_script:
- travis_retry composer self-update
- travis_retry composer install --no-interaction --prefer-source

script:
- vendor/bin/phpunit

after_success:
- bash <(curl -s https://codecov.io/bash)

cache:
directories:
- $HOME/.composer/cache
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
## v1.2.3 (in development)

### New features & improvements:
- Update required php version to 7.1.3 (https://www.php.net/supported-versions.php)
- Add descriptions
- Add tests

### Bug fixes:
- Add missing ";"

## v1.2.2 (release date: 13th April 2019)

Expand Down
2 changes: 0 additions & 2 deletions FbBotApp.php
Original file line number Diff line number Diff line change
Expand Up @@ -580,6 +580,4 @@ public function getCurlError()
{
return $this->curl_error;
}


}
12 changes: 9 additions & 3 deletions Menu/LocalizedMenu.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,19 @@
*/
class LocalizedMenu
{
private $locale;

private $locale ;

private $composer_input_disabled ;
private $composer_input_disabled;

private $menuItems;

/**
* LocalizedMenu constructor.
*
* @param string $locale
* @param boolean $composer_input_disabled
* @param null|array $menuItems
*/
public function __construct($locale, $composer_input_disabled, $menuItems = null) {

$this->locale = $locale;
Expand Down
10 changes: 5 additions & 5 deletions Menu/MenuItem.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,14 @@ class MenuItem
*
* @var string
*/
protected $type ;
protected $type;

/**
* Button title
*
* @var string
*/
protected $title ;
protected $title;

/**
* Button url
Expand Down Expand Up @@ -70,14 +70,14 @@ class MenuItem
*
* @var null|string
*/
protected $webview_share_button = null ;
protected $webview_share_button = null;

/**
* MessageButton constructor.
*
* @param string $type
* @param string $title
* @param string $url url or postback
* @param string|array $data
*/
public function __construct($type, $title, $data, $webview_height_ratio = '', $messenger_extensions = false, $fallback_url = '', $webview_share_button = null)
{
Expand Down Expand Up @@ -133,4 +133,4 @@ public function getData()
}
return $result;
}
}
}
10 changes: 5 additions & 5 deletions Messages/AccountLink.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
*/
class AccountLink
{

/**
* Link Account title
*
Expand Down Expand Up @@ -49,8 +48,9 @@ class AccountLink
* @param string $subtitle
* @param string $url button url
* @param string $image_url
* @param boolean $logout
*/
public function __construct($title, $subtitle = '', $url = '', $image_url = '', $logout = FALSE)
public function __construct($title, $subtitle = '', $url = '', $image_url = '', $logout = false)
{
$this->title = $title;
$this->subtitle = $subtitle;
Expand All @@ -68,11 +68,11 @@ public function getData()
{
if($this->logout)
{
$buttons = new MessageButton( MessageButton::TYPE_ACCOUNT_UNLINK, '');
$buttons = new MessageButton(MessageButton::TYPE_ACCOUNT_UNLINK, '');
}
else
{
$buttons = new MessageButton( MessageButton::TYPE_ACCOUNT_LINK, '', $this->url);
$buttons = new MessageButton(MessageButton::TYPE_ACCOUNT_LINK, '', $this->url);
}

$result = [
Expand All @@ -81,7 +81,7 @@ public function getData()
'image_url' => $this->image_url,
'buttons' => [$buttons->getData()]
];

return $result;
}

}
2 changes: 1 addition & 1 deletion Messages/Address.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,4 @@ public function getData()
{
return $this->data;
}
}
}
2 changes: 1 addition & 1 deletion Messages/Adjustment.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,4 @@ public function getData()
{
return $this->data;
}
}
}
51 changes: 25 additions & 26 deletions Messages/MessageButton.php
Original file line number Diff line number Diff line change
Expand Up @@ -140,45 +140,44 @@ public function getData()
case self::TYPE_POSTBACK:
$result['title'] = $this->title;
$result['payload'] = $this->url;
break;
break;

case self::TYPE_CALL:
$result['title'] = $this->title;
$result['payload'] = $this->url;
break;
break;

case self::TYPE_WEB:
$result['title'] = $this->title;
$result['url'] = $this->url;

if ($this->webview_height_ratio) {
$result['webview_height_ratio'] = $this->webview_height_ratio;
}

if ($this->messenger_extensions){
$result['messenger_extensions'] = $this->messenger_extensions;
$result['fallback_url'] = $this->fallback_url;
}
if($this->webview_share_button){
$result['webview_share_button'] = $this->webview_share_button ;
}
break;
$result['title'] = $this->title;
$result['url'] = $this->url;

if ($this->webview_height_ratio) {
$result['webview_height_ratio'] = $this->webview_height_ratio;
}

if ($this->messenger_extensions){
$result['messenger_extensions'] = $this->messenger_extensions;
$result['fallback_url'] = $this->fallback_url;
}

if($this->webview_share_button){
$result['webview_share_button'] = $this->webview_share_button;
}
break;

case self::TYPE_SHARE:
//only share_contents needed
if ($this->share_contents)
$result['share_contents'] = $this->share_contents->getData();
break;
//only share_contents needed
if ($this->share_contents)
$result['share_contents'] = $this->share_contents->getData();
break;

case self::TYPE_ACCOUNT_LINK:
$result['url'] = $this->url;
break;
break;

case self::TYPE_ACCOUNT_UNLINK:
//only type needed
break;

//only type needed
break;
}

return $result;
Expand Down
2 changes: 1 addition & 1 deletion Messages/MessageReceiptElement.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,4 +59,4 @@ public function getData()
'currency' => $this->currency
];
}
}
}
2 changes: 1 addition & 1 deletion Messages/SenderAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,4 +55,4 @@ public function getData()
'sender_action' => $this->action
];
}
}
}
2 changes: 1 addition & 1 deletion Messages/Summary.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,4 @@ public function getData()
{
return $this->data;
}
}
}
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
[![Build Status](https://travis-ci.com/pimax/fb-messenger-php.svg?branch=master)](https://travis-ci.com/pimax/fb-messenger-php)
[![Coverage badge](https://codecov.io/gh/pimax/fb-messenger-php/branch/master/graphs/badge.svg)](https://codecov.io/gh/pimax/fb-messenger-php)

FB Messenger Bot PHP API
========================

Expand All @@ -10,8 +13,12 @@ The minimum requirement is that your Web server supports PHP 5.4.
INSTALLATION
------------

Version 1.2.2 is the last with PHP ">=5.4.0" support.
**As of version 2.0, PHP 7.1.3 is required.**

```
composer require "pimax/fb-messenger-php" "dev-master"
composer require "pimax/fb-messenger-php" "<version>"
```

BASIC USAGE
Expand Down
13 changes: 9 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "pimax/fb-messenger-php",
"description": " Facebook Messenger Bot PHP API",
"description": "Facebook Messenger Bot PHP API",
"homepage": "https://github.com/pimax/fb-messenger-php",
"license": "MIT",
"authors": [
Expand All @@ -12,10 +12,15 @@
}
],
"require": {
"php": ">=5.4.0"
"php": "^7.1.3"
},
"require-dev": {
"phpunit/phpunit": "^7.3"
},

"autoload": {
"psr-4": { "pimax\\": "" }
},
"scripts": {
"test": "phpunit"
}
}
}
Loading

0 comments on commit 67f8c56

Please sign in to comment.