Skip to content
This repository has been archived by the owner on May 28, 2023. It is now read-only.

Commit

Permalink
Refactoring according to SensioInsights analysis, correction of autol…
Browse files Browse the repository at this point in the history
…oad for test cases, where tests classes should be autoloaded in dev
  • Loading branch information
percymamedy committed Jun 10, 2016
1 parent 3e60699 commit 1d66728
Show file tree
Hide file tree
Showing 6 changed files with 56 additions and 15 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
/vendor/
composer.lock
composer.phar
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Laravel 5 IBM Watson Translate

[![StyleCI](https://styleci.io/repos/50762162/shield?style=flat)](https://styleci.io/repos/50762162)
[![Build Status](https://travis-ci.org/findbrok/laravel-watson-translate.svg?branch=master)](https://travis-ci.org/findbrok/laravel-watson-translate)
[![Latest Stable Version](https://poser.pugx.org/findbrok/laravel-watson-translate/v/stable)](https://packagist.org/packages/findbrok/laravel-watson-translate)
[![Total Downloads](https://poser.pugx.org/findbrok/laravel-watson-translate/downloads)](https://packagist.org/packages/findbrok/laravel-watson-translate)
Expand Down
22 changes: 15 additions & 7 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
],
"require": {
"php": ">=5.5.0",
"laravel/framework": "~5.0|~5.1|~5.2",
"findbrok/php-watson-api-bridge": "^1.0"
"laravel/framework": "5.0.*|5.1.*|5.2.*",
"findbrok/php-watson-api-bridge": "1.0.*"
},
"require-dev": {
"fzaninotto/faker": "~1.4",
Expand All @@ -22,12 +22,20 @@
"guzzlehttp/guzzle": "~5.3|~6.0|~6.2"
},
"autoload": {
"classmap": [
"tests/TestCase.php"
],
"psr-4": {
"FindBrok\\WatsonTranslate\\": "src/",
"FindBrok\\WatsonTranslate\\": "src/"
}
},
"autoload-dev": {
"psr-4": {
"FindBrok\\WatsonTranslate\\Tests\\": "tests/"
}
}
},
"extra": {
"branch-alias": {
"dev-master": "1.0.x-dev"
}
},
"minimum-stability": "dev",
"prefer-stable": true
}
4 changes: 2 additions & 2 deletions src/Presenters/ResultsCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ public function languagesNames($asCollection = false)
$languagesName = collect($this->collectResults()->get('languages'))->transform(function ($item) {
return isset($item['name']) ? $item['name'] : null;
})->reject(function ($item) {
return $item == null;
return is_null($item);
});

//No language
Expand All @@ -113,7 +113,7 @@ public function languagesCodes($asCollection = false)
$languagesCodes = collect($this->collectResults()->get('languages'))->transform(function ($item) {
return isset($item['language']) ? $item['language'] : null;
})->reject(function ($item) {
return $item == null;
return is_null($item);
});

//No language
Expand Down
6 changes: 3 additions & 3 deletions src/Translator.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public function textTranslate($text)
'target' => $this->to,
'text' => $text,
])->reject(function ($item) {
return $item == null || $item == '';
return is_null($item) || empty($item);
})->all())->getBody()->getContents();
//Return translator object
return $this;
Expand All @@ -51,7 +51,7 @@ public function bulkTranslate($text )
'target' => $this->to,
'text' => $text
])->reject(function ($item) {
return $item == null || $item == '';
return is_null($item) || empty($item);
})->all())->getBody()->getContents();
//Return translator object
return $this;
Expand Down Expand Up @@ -111,7 +111,7 @@ public function listModels($defaultOnly = null, $sourceFilter = null, $targetFil
'target' => $targetFilter,
'default' => $defaultOnly,
])->reject(function ($item) {
return $item == null || $item == '';
return is_null($item) || empty($item);
})->all())->getBody()->getContents();
//Return translator object
return $this;
Expand Down
36 changes: 33 additions & 3 deletions tests/TestCase.php → tests/TestTranslator.php
Original file line number Diff line number Diff line change
@@ -1,15 +1,45 @@
<?php

use FindBrok\WatsonTranslate\Tests\Mocks\MockResponses;
use Orchestra\Testbench\TestCase as TestBenchTestCase;
use Orchestra\Testbench\TestCase;

/**
* Class TestCase
*/
class TestCase extends TestBenchTestCase
class TestTranslator extends TestCase
{
/**
* Setup
* Mock Responses
*
* @var MockResponses
*/
protected $mockResponses;

/**
* Translator class to use
*
* @var string
*/
protected $translatorClass;

/**
* Translator instance
*
* @var mixed
*/
protected $translator;

/**
* Watson Bridge
*
* @var \FindBrok\WatsonBridge\Bridge
*/
protected $bridge;

/**
* Setup the test environment.
*
* @return void
*/
public function setUp()
{
Expand Down

0 comments on commit 1d66728

Please sign in to comment.