diff --git a/app/Libraries/MultiDB.php b/app/Libraries/MultiDB.php index 2fed0652a6b9..aa84ef5993fb 100644 --- a/app/Libraries/MultiDB.php +++ b/app/Libraries/MultiDB.php @@ -160,7 +160,8 @@ class MultiDB public static function userFindAndSetDb($email) : bool { - //multi-db active + //multi-db active + foreach (self::$dbs as $db) { if (User::on($db)->where(['email' => $email])->get()->count() >= 1) { // if user already exists, validation will fail return true; @@ -172,6 +173,8 @@ class MultiDB public static function findAndSetDb($token) :bool { + nlog($token); + foreach (self::$dbs as $db) { if ($ct = CompanyToken::on($db)->whereRaw('BINARY `token`= ?', [$token])->first()) { self::setDb($ct->company->db); diff --git a/phpunit.xml b/phpunit.xml index e1b0575994e1..e1ef466e8b20 100644 --- a/phpunit.xml +++ b/phpunit.xml @@ -22,7 +22,7 @@ - + diff --git a/tests/Unit/InvitationTest.php b/tests/Unit/InvitationTest.php index 76db0cd24020..0bee7f83e1d1 100644 --- a/tests/Unit/InvitationTest.php +++ b/tests/Unit/InvitationTest.php @@ -34,6 +34,7 @@ class InvitationTest extends TestCase public function testInvitationSanity() { + $this->assertEquals($this->invoice->invitations->count(), 2); $invitations = $this->invoice->invitations()->get(); @@ -46,11 +47,20 @@ class InvitationTest extends TestCase $this->invoice->line_items = []; + $response = null; + + try { + $response = $this->withHeaders([ 'X-API-SECRET' => config('ninja.api_secret'), 'X-API-TOKEN' => $this->token, - ])->put('/api/v1/invoices/'.$this->encodePrimaryKey($this->invoice->id), $this->invoice->toArray()) - ->assertStatus(200); + ])->put('/api/v1/invoices/'.$this->encodePrimaryKey($this->invoice->id), $this->invoice->toArray()); + } catch (\Exception $e) { + + nlog($e->getMessage()); + } + + $response->assertStatus(200); $arr = $response->json();