Skip to content
Merged
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
1 change: 0 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ branches:
- develop

before_script:
- [ -f composer.lock ] && rm composer.lock
- composer self-update
- composer install --no-interaction

Expand Down
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
# 5.0.1
# 5.0.2
+ Fix Travis
+ Fix support for PHP > 7.1

## 5.0.1
+ Fix CIs errors

## 5.0.0
Expand Down
9 changes: 6 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,14 @@ Simple PHP wrapper for the [Bit.ly](https://bitly.com/) API V4.

## Docker development

I use a Docker image to develop (see `docker-compose.yaml`)
I use a Docker image (PHP 7.0 e PHP 7.4) to develop (see `docker-compose.yaml`)

``` bash
$ docker-compose build develop
$ docker-compose run --rm develop
$ docker-compose build develop70
$ docker-compose run --rm develop70

$ docker-compose build develop74
$ docker-compose run --rm develop74
```

To run with your own user/id, uncomment relative sections on `docker-compose.yaml` and run it with these commands
Expand Down
20 changes: 18 additions & 2 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -1,13 +1,29 @@
version: "3.7"
services:
develop:
develop70:
build:
args:
user: sineverba
#user: ${CURRENT_USER}
uid: 1000
#uid: ${CURRENT_UID}
context: ./
context: ./docker-compose/php70
container_name: bpaw-develop
image: bpaw-develop:0.1.0
volumes:
#- ./:/home/${CURRENT_USER}/app
- ./:/home/sineverba/app
networks:
- develop-bpaw

develop74:
build:
args:
user: sineverba
#user: ${CURRENT_USER}
uid: 1000
#uid: ${CURRENT_UID}
context: ./docker-compose/php74
container_name: bpaw-develop
image: bpaw-develop:0.1.0
volumes:
Expand Down
File renamed without changes.
41 changes: 41 additions & 0 deletions docker-compose/php74/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
FROM php:7.4-cli

# Arguments defined in docker-compose.yml
ARG user
ARG uid

# Install system dependencies
RUN apt-get update && apt-get install -y \
git \
curl \
libpng-dev \
libonig-dev \
libxml2-dev \
zip \
unzip

# Setup PHPXDebug
RUN pecl install xdebug
RUN docker-php-ext-enable xdebug

# Clear cache
RUN apt-get clean && rm -rf /var/lib/apt/lists/*

# Install PHP extensions
RUN docker-php-ext-install pdo_mysql mbstring exif pcntl bcmath gd

# Get latest Composer
COPY --from=composer:latest /usr/bin/composer /usr/bin/composer

# Create system user to run Composer and Artisan Commands
RUN useradd -G www-data,root -u $uid -d /home/$user $user
RUN mkdir -p /home/$user/.composer && \
chown -R $user:$user /home/$user

# Set working directory
#WORKDIR /var/www
WORKDIR /home/$user/app

USER $user

ENTRYPOINT /bin/bash
14 changes: 13 additions & 1 deletion tests/Unit/AdapterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class AdapterTest extends TestCase
private $token;
private $auth;

public function setUp()
private function initialize()
{
$token = 'd7WPz7KJ3k';
$auth = new Auth($token);
Expand All @@ -39,6 +39,8 @@ public function setUp()
*/
public function test_post_return_response_interface()
{
$this->initialize();

$fixture = dirname(__DIR__,1).'/Fixtures/httpbin/post.json';
$this->assertFileExists($fixture);

Expand Down Expand Up @@ -77,6 +79,8 @@ public function test_post_return_response_interface()
*/
public function test_request_method_post_return_response_interface()
{
$this->initialize();

$fixture = dirname(__DIR__,1).'/Fixtures/httpbin/post.json';
$this->assertFileExists($fixture);

Expand Down Expand Up @@ -115,6 +119,8 @@ public function test_request_method_post_return_response_interface()
*/
public function test_invalid_method_thrown_invalidargumentexception()
{
$this->initialize();

$this->expectException(\InvalidArgumentException::class);
$adapter = new Adapter($this->auth);
$adapter->request('invalid','shorten');
Expand All @@ -127,6 +133,8 @@ public function test_invalid_method_thrown_invalidargumentexception()
*/
public function test_custom_base_uri_returns_custom_link()
{
$this->initialize();

$custom_link = 'http://www.example.com';
$adapter = new Adapter($this->auth, $custom_link);
$this->assertEquals($custom_link,$adapter->getBaseUri());
Expand All @@ -139,6 +147,8 @@ public function test_custom_base_uri_returns_custom_link()
*/
public function test_empty_base_uri_returns_bitly_link()
{
$this->initialize();

$adapter = new Adapter($this->auth);
$bitly_link = 'https://api-ssl.bitly.com/v4/';
$this->assertEquals($bitly_link,$adapter->getBaseUri());
Expand All @@ -151,6 +161,8 @@ public function test_empty_base_uri_returns_bitly_link()
*/
public function test_can_instantiate_adapter()
{
$this->initialize();

$adapter = new Adapter($this->auth);
$this->assertInstanceOf('\Bitlywrap\Adapter\Adapter',$adapter);
}
Expand Down
6 changes: 5 additions & 1 deletion tests/Unit/WrapperTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class WrapperTest extends TestCase
private $auth;
private $adapter;

public function setUp()
private function initialize()
{
$token = 'd7WPz7KJ3k';
$auth = new Auth($token);
Expand All @@ -43,6 +43,8 @@ public function setUp()
*/
public function test_get_short_link_method_return_string()
{
$this->initialize();

$fixture = dirname(__DIR__,1).'/Fixtures/Shorten/shorten.json';
$this->assertFileExists($fixture);

Expand Down Expand Up @@ -73,6 +75,8 @@ public function test_get_short_link_method_return_string()
*/
public function test_can_instantiate_wrapper()
{
$this->initialize();

$wrapper = new Wrapper($this->adapter);
$this->assertInstanceOf('\Bitlywrap\Wrapper\Wrapper',$wrapper);
}
Expand Down