Skip to content

Commit

Permalink
laravel 7
Browse files Browse the repository at this point in the history
  • Loading branch information
denisdulici committed Mar 7, 2020
1 parent 3ab35b8 commit 3c3bef7
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 33 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:

steps:
- name: Checkout code
uses: actions/checkout@v1
uses: actions/checkout@v2

- name: Cache composer
uses: actions/cache@v1
Expand All @@ -24,7 +24,7 @@ jobs:
key: php-${{ matrix.php }}-composer-${{ hashFiles('composer.json') }}

- name: Setup PHP
uses: shivammathur/setup-php@v1
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
extension-csv: bcmath, ctype, dom, fileinfo, intl, gd, json, mbstring, pdo, pdo_sqlite, openssl, sqlite, xml, zip
Expand All @@ -34,4 +34,4 @@ jobs:
run: composer install --no-interaction --no-scripts --no-suggest --prefer-source

- name: Execute tests
run: vendor/bin/phpunit
run: vendor/bin/phpunit
8 changes: 4 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
{
"name": "akaunting/firewall",
"description": "Web Application Firewall (WAF) package for Laravel",
"keywords": [
Expand All @@ -14,7 +14,7 @@
],
"license": "MIT",
"authors": [
{
{
"name": "Denis Duliçi",
"email": "info@akaunting.com",
"homepage": "https://akaunting.com",
Expand All @@ -28,8 +28,8 @@
"jenssegers/agent": "2.6.*"
},
"require-dev": {
"phpunit/phpunit": "5.7.*",
"orchestra/testbench": "3.4.*|3.5.*|3.6.*|3.7.*|3.8.*"
"phpunit/phpunit": ">=5.7",
"orchestra/testbench": ">=3.4"
},
"autoload": {
"psr-4": {
Expand Down
1 change: 1 addition & 0 deletions phpunit.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,6 @@
<env name="QUEUE_DRIVER" value="sync"/>
<env name="QUEUE_CONNECTION" value="sync"/>
<env name="MAIL_DRIVER" value="array"/>
<env name="MAIL_MAILER" value="array"/>
</php>
</phpunit>
38 changes: 12 additions & 26 deletions tests/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@

abstract class TestCase extends BaseTestCase
{
protected $database;

protected function setUp(): void
{
parent::setUp();
Expand All @@ -24,8 +22,6 @@ protected function setUp(): void
protected function tearDown(): void
{
parent::tearDown();

$this->deleteDatabase();
}

protected function getPackageProviders($app)
Expand All @@ -35,6 +31,18 @@ protected function getPackageProviders($app)
];
}

protected function setUpDatabase()
{
config(['database.default' => 'testbench']);

config(['database.connections.testbench' => [
'driver' => 'sqlite',
'database' => ':memory:',
'prefix' => '',
],
]);
}

protected function setUpConfig()
{
config(['firewall' => require __DIR__ . '/../src/Config/firewall.php']);
Expand All @@ -47,28 +55,6 @@ protected function setUpConfig()
config(['firewall.middleware.xss.methods' => ['all']]);
}

protected function setUpDatabase()
{
if (!file_exists($path = __DIR__ . '/databases')) {
mkdir($path);
}

touch($this->database = tempnam($path, 'database.sqlite.'));

app()->config->set(
'database.connections.testbench', [
'driver' => 'sqlite',
'database' => $this->database,
'prefix' => '',
]
);
}

protected function deleteDatabase()
{
@unlink($this->database);
}

public function getNextClosure()
{
return function () {
Expand Down

0 comments on commit 3c3bef7

Please sign in to comment.