Skip to content

Commit

Permalink
Modify docblock and style
Browse files Browse the repository at this point in the history
  • Loading branch information
mpociot committed Sep 27, 2017
1 parent 1e897d2 commit 75af49c
Showing 1 changed file with 35 additions and 37 deletions.
72 changes: 35 additions & 37 deletions src/Testing/BotManTester.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,17 @@
namespace BotMan\Studio\Testing;

use BotMan\BotMan\BotMan;
use Illuminate\Support\Collection;
use PHPUnit\Framework\Assert as PHPUnit;
use BotMan\BotMan\Drivers\Tests\FakeDriver;
use BotMan\BotMan\Messages\Outgoing\Question;
use BotMan\BotMan\Messages\Incoming\IncomingMessage;
use BotMan\BotMan\Messages\Outgoing\OutgoingMessage;
use BotMan\BotMan\Messages\Attachments\Audio;
use BotMan\BotMan\Messages\Attachments\File;
use BotMan\BotMan\Messages\Attachments\Audio;
use BotMan\BotMan\Messages\Attachments\Image;
use BotMan\BotMan\Messages\Attachments\Location;
use BotMan\BotMan\Messages\Attachments\Video;

use Illuminate\Support\Collection;
use BotMan\BotMan\Messages\Outgoing\Question;
use BotMan\BotMan\Messages\Attachments\Location;
use BotMan\BotMan\Messages\Incoming\IncomingMessage;
use BotMan\BotMan\Messages\Outgoing\OutgoingMessage;

/**
* Class BotManTester.
Expand Down Expand Up @@ -68,17 +67,19 @@ protected function getReply()
public function setDriver($driver)
{
$this->driver->setName($driver::DRIVER_NAME);

return $this;
}

/**
* @param Array $user_info
* @param array $user_info
* @return $this
*/
public function setUser($user_info)
{
$this->user_id = $user_info['id'] ?? $this->user_id;
$this->driver->setUser($user_info);

return $this;
}

Expand Down Expand Up @@ -124,22 +125,21 @@ public function receivesInteractiveMessage($message)
public function receivesLocation($latitude = 24, $longitude = 57)
{
$message = new IncomingMessage(Location::PATTERN, $this->user_id, $this->channel);
$message->setLocation( new Location($latitude, $longitude, null));
$message->setLocation(new Location($latitude, $longitude, null));

return $this->receivesRaw($message);
}

/**
* @param Array $urls
* @param array $urls
* @return $this
*/
public function receivesImages(Array $urls = null)
public function receivesImages(array $urls = null)
{
if(is_null($urls)){
$images = [new Image('https://via.placeholder.com/350x150')]; // TODO : default image
}
if(is_array($urls)){
$images = Collection::make($urls)->map(function($url){
if (is_null($urls)) {
$images = [new Image('https://via.placeholder.com/350x150')];
} else {
$images = Collection::make($urls)->map(function ($url) {
return new Image(($url));
})->toArray();
}
Expand All @@ -150,16 +150,16 @@ public function receivesImages(Array $urls = null)
}

/**
* @param Array $urls
* @param array $urls
* @return $this
*/
public function receivesAudio(Array $urls = null)
public function receivesAudio(array $urls = null)
{
if(is_null($urls)){
$audio = [new Audio('https://www.youtube.com/watch?v=4zzSw-0IShE')]; // TODO : default audio
if (is_null($urls)) {
$audio = [new Audio('https://www.youtube.com/watch?v=4zzSw-0IShE')];
}
if(is_array($urls)){
$audio = Collection::make($urls)->map(function($url){
if (is_array($urls)) {
$audio = Collection::make($urls)->map(function ($url) {
return new Audio(($url));
})->toArray();
}
Expand All @@ -170,16 +170,15 @@ public function receivesAudio(Array $urls = null)
}

/**
* @param $message
* @param array|null $urls
* @return $this
*/
public function receivesVideos(Array $urls = null)
public function receivesVideos(array $urls = null)
{
if(is_null($urls)){
$videos = [new Video('https://www.youtube.com/watch?v=4zzSw-0IShE')]; // TODO : default video
}
if(is_array($urls)){
$videos = Collection::make($urls)->map(function($url){
if (is_null($urls)) {
$videos = [new Video('https://www.youtube.com/watch?v=4zzSw-0IShE')];
} else {
$videos = Collection::make($urls)->map(function ($url) {
return new Video(($url));
})->toArray();
}
Expand All @@ -190,16 +189,15 @@ public function receivesVideos(Array $urls = null)
}

/**
* @param $message
* @param array|null $urls
* @return $this
*/
public function receivesFiles(Array $urls = null)
public function receivesFiles(array $urls = null)
{
if(is_null($urls)){
if (is_null($urls)) {
$files = [new File('https://www.youtube.com/watch?v=4zzSw-0IShE')]; // TODO : default video
}
if(is_array($urls)){
$files = Collection::make($urls)->map(function($url){
} else {
$files = Collection::make($urls)->map(function ($url) {
return new File(($url));
})->toArray();
}
Expand All @@ -214,10 +212,10 @@ public function receivesFiles(Array $urls = null)
* @param $payload
* @return $this
*/
public function receivesEvent($name, $payload = null) {
public function receivesEvent($name, $payload = null)
{
$this->driver->setEventName($name);
$this->driver->setEventPayload($payload);
//$this->driver->hasMatchingEvent();

return $this->receives(new IncomingMessage('', $this->user_id, $this->channel));
}
Expand Down

0 comments on commit 75af49c

Please sign in to comment.