Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Laravel pipelines, using external database

Jacobo Misael Tapia de la Rosa May 15, 2018

I'm running a bitbucket pipeline to execute all the unit test with PHP Unit. When I execute the test on local all of them pass. But on the bitbucket pipeline it always fail. In this case, the tests are related to an external service that we are checking.

<?php

namespace Tests\Unit;

use Tests\TestCase;
use Illuminate\Foundation\Testing\RefreshDatabase;

use MyService;

class MyTest extends TestCase
{
/**
* Test the dummies in this new system
*
* @return void
*/
public function testDumies()
{
$games = DummyService::getDummies();
$this->assertTrue(count($dummies) > 0);
}

public function testDummiesOfUser()
{
$dummies = DummyService::getDummiesOfUser('someemail@mail.com');
$this->assertTrue(count($dummies) > 0);
}
}

And the following is the service to get the dummies


<?php
namespace App\Services;

class DummyService {

/**
* Get dummies
*
* @return void
*/
public function getDummies() {
$collection = [];

$games = $this->getDummiesInUrl('http://my-project/api/v1/platform/dummies');
foreach($dummies as $dummy) {
$collection[] = $dummy;
}

return $collection;
}

/**
* Retrieves the dummies in url
*
* @Param string $endpoint
* @return array
*/
public function getDummiesInUrl($endpoint) {
$client = new \GuzzleHttp\Client();
$res = $client->request('GET', $endpoint);
$body = $res->getBody();
$body = json_decode($body, true);
$data = $body['data'];
$dummies = $data['dummies'];
return $dummies;
}

/**
* Returns the dummies of an user
*
* @Param string $email
* @return array
*/
public function getDummiesOfUser($email) {
$collection = [];
$dummies = $this->getDummiesOfUserInUrl('http://myroute/api/v1/platform/dummies/user', $email);
foreach($dummies as $d) {
$collection[] = $d;
}
return $collection;
}

/**
* Get gameplays in url
*
* @Param string $endpoint
* @Param string $email
* @return array
*/
public function getDummiesOfUserInUrl($endpoint, $email) {
$client = new \GuzzleHttp\Client();
$res = $client->request('GET', $endpoint, ['query' => ['email' => $email]]);
$body = $res->getBody();
$body = json_decode($body, true);
$data = $body['data'];
$dummies = $data['dummiess'];
return $dummies;
}
}

But when that is tested on the bitbucket pipeline I got the following errors:

`PDOException: SQLSTATE[HY000] [2054] The server requested authentication method unknown to the client` and `Caused by PDOException:PDO::__construct(): The server requested authentication method unknown to the client [caching_sha2_password]`

1 answer

0 votes
Graham Gatus
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
July 23, 2018

Hi @Jacobo Misael Tapia de la Rosa

We've recently updated our documented on how to run the Laravel quick-start project with  Bitbucket Pipelines, so it might be worth having a read of that for some hints. See https://confluence.atlassian.com/bitbucket/laravel-with-bitbucket-pipelines-913473967.html 

Are you able to provide more details about your pipeline? Based on your exception, it seems there may be an authentication related issue whilst trying to connect to your DB. 

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events