Skip to content

Commit

Permalink
chore: allow Laravel 9 and add test
Browse files Browse the repository at this point in the history
  • Loading branch information
danielsdeboer committed May 13, 2022
1 parent 1cc8b9e commit fa595f1
Show file tree
Hide file tree
Showing 6 changed files with 81 additions and 33 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
/vendor
composer.lock
phpunit.xml
.phpunit.result.cache
build

## Directory-based project format:
.idea/
9 changes: 5 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,13 @@
"require": {
"php": "^8.0",
"ext-pdo": "*",
"illuminate/support": "^6.0|^7.0|^8.0",
"illuminate/database": "^6.0|^7.0|^8.0"
"illuminate/support": "^8.0|^9.0",
"illuminate/database": "^8.0|^9.0"
},
"require-dev": {
"phpunit/phpunit": "^9.3",
"vimeo/psalm": "^3.1"
"phpunit/phpunit": "^9.5",
"vimeo/psalm": "^4.23",
"orchestra/testbench": "^7.0"
},
"autoload": {
"psr-4": {
Expand Down
47 changes: 19 additions & 28 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,38 +1,29 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" bootstrap="vendor/autoload.php" backupGlobals="false" backupStaticAttributes="false" colors="true" verbose="true" convertErrorsToExceptions="true" convertNoticesToExceptions="true" convertWarningsToExceptions="true" processIsolation="false" stopOnFailure="false" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd">
<coverage>
<include>
<directory suffix=".php">src/</directory>
</include>
<report>
<html outputDirectory="build/coverage"/>
<text outputFile="build/coverage.txt"/>
</report>
</coverage>

<phpunit
bootstrap="vendor/autoload.php"
backupGlobals="false"
backupStaticAttributes="false"
colors="true"
verbose="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false"
>
<testsuites>
<testsuite name="Test Suite">
<directory>tests</directory>
</testsuite>
</testsuites>

<filter>
<whitelist>
<directory suffix=".php">src/</directory>
</whitelist>
</filter>

<logging>
<log
type="coverage-html"
target="build/coverage"
/>
<php>
<env name="APP_KEY" value="AckfSECXIvnK5r28GVIWUAxmbBSjTsmF"/>

<log
type="coverage-text"
target="build/coverage.txt"
/>
</logging>
<env name="ODBC_DSN" value=""/>
<env name="ODBC_HOST" value=""/>
<env name="ODBC_DB" value=""/>
<env name="ODBC_USERNAME" value=""/>
<env name="ODBC_PASSWORD" value=""/>
<env name="ODBC_TEST_SELECT" value=""/>
</php>
</phpunit>
2 changes: 1 addition & 1 deletion src/Connection.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ protected function getDefaultQueryGrammar ()
protected function getDefaultSchemaGrammar ()
{
return $this->withTablePrefix(
$this->keyOrDefault('sh', Schema::class)
$this->keyOrDefault('schema', Schema::class)
);
}

Expand Down
19 changes: 19 additions & 0 deletions tests/ConnectionTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php

namespace Dbt\Odbc\Tests;

use Illuminate\Support\Facades\DB;

class ConnectionTest extends TestCase
{
/** @test */
public function getting_the_connection (): void
{


$result = DB::connection('odbc')
->select(config('database.test_select'));

$this->assertNotNull($result);
}
}
35 changes: 35 additions & 0 deletions tests/TestCase.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?php

namespace Dbt\Odbc\Tests;

use Dbt\Odbc\Provider;
use Illuminate\Config\Repository;
use Orchestra\Testbench\TestCase as Orchestra;

class TestCase extends Orchestra
{
protected function setUp (): void
{
parent::setUp();

$config = $this->app->make(Repository::class);

$config->set('database.connections', [
'odbc' => [
'driver' => 'odbc',
'dsn' => env('ODBC_DSN'),
'host' => env('ODBC_HOST'),
'database' => env('ODBC_DB'),
'username' => env('ODBC_USERNAME'),
'password' => env('ODBC_PASSWORD'),
],
]);

$config->set('database.test_select', env('ODBC_TEST_SELECT'));
}

protected function getPackageProviders ($app): array
{
return [Provider::class];
}
}

0 comments on commit fa595f1

Please sign in to comment.