Skip to content

Commit 12ba472

Browse files
Atualização da versão do laravel
Inclusão de testes
1 parent 866b759 commit 12ba472

File tree

8 files changed

+43
-78
lines changed

8 files changed

+43
-78
lines changed

composer.json

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,19 +22,18 @@
2222
"extra": {
2323
"laravel": {
2424
"providers": [
25-
"Igrejanet\\Firebird\\Providers\\FirebirdServiceProvider"
2625
]
2726
}
2827
},
2928
"require": {
30-
"php": ">=7.2.5",
29+
"php": ">=7.4|^8.0",
3130
"ext-pdo": "*",
3231
"ext-pdo_firebird": "*",
3332
"illuminate/database": "^7.0|^8.0",
34-
"harrygulliford/laravel-firebird": "^2.3"
33+
"harrygulliford/laravel-firebird": "^2.4"
3534
},
3635
"require-dev": {
37-
"phpunit/phpunit": "^8.5",
36+
"phpunit/phpunit": "^9.3.3",
3837
"fzaninotto/faker": "^1.9",
3938
"illuminate/config": "^7.0|^8.0"
4039
}

src/Database/FirebirdDatabaseManager.php

Lines changed: 0 additions & 21 deletions
This file was deleted.

src/FirebirdModel.php

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,9 @@
1515
*/
1616
class FirebirdModel extends Model
1717
{
18-
/**
19-
* @var null|string
20-
*/
21-
protected $generator = null;
18+
private const DRIVER_NAME = 'firebird';
19+
20+
protected ?string $generator = null;
2221

2322
/**
2423
* @param Builder $query
@@ -49,7 +48,7 @@ protected function insertAndSetId(Builder $query, $attributes)
4948

5049
public function runningFirebird() : bool
5150
{
52-
return $this->getConnection()->getDriverName() == 'firebird';
51+
return $this->getConnection()->getDriverName() == self::DRIVER_NAME;
5352
}
5453

5554
/**

src/Increasers/IncreaseByGenerator.php

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,23 +11,14 @@
1111
*/
1212
class IncreaseByGenerator
1313
{
14-
/**
15-
* @var string
16-
*/
17-
protected $sql;
14+
protected string $sql;
1815

19-
/**
20-
* @param string $generator
21-
*/
2216
public function __construct(string $generator)
2317
{
2418
$this->sql = 'SELECT GEN_ID('. $generator .', 1) AS CODIGO FROM RDB$DATABASE';
2519
}
2620

27-
/**
28-
* @return string
29-
*/
30-
public function __toString()
21+
public function __toString(): string
3122
{
3223
return $this->sql;
3324
}

src/Increasers/IncreaseById.php

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,24 +11,14 @@
1111
*/
1212
class IncreaseById
1313
{
14-
/**
15-
* @var string
16-
*/
17-
protected $sql;
14+
protected string $sql;
1815

19-
/**
20-
* @param string $keyName
21-
* @param string $tableName
22-
*/
2316
public function __construct(string $keyName, string $tableName)
2417
{
2518
$this->sql = 'SELECT COALESCE(MAX('. $keyName .'), 0) + 1 as CODIGO FROM ' . $tableName;
2619
}
2720

28-
/**
29-
* @return string
30-
*/
31-
public function __toString()
21+
public function __toString(): string
3222
{
3323
return $this->sql;
3424
}

src/Providers/FirebirdServiceProvider.php

Lines changed: 0 additions & 25 deletions
This file was deleted.

tests/IncreaseByGeneratorTest.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?php
2+
3+
namespace Tests;
4+
5+
use Igrejanet\Firebird\Increasers\IncreaseByGenerator;
6+
use PHPUnit\Framework\TestCase;
7+
8+
class IncreaseByGeneratorTest extends TestCase
9+
{
10+
public function testIncreaseByGenerator()
11+
{
12+
$sql = (string) (new IncreaseByGenerator('GEN_USERS'));
13+
14+
$this->assertEquals('SELECT GEN_ID(GEN_USERS, 1) AS CODIGO FROM RDB$DATABASE', $sql);
15+
}
16+
}

tests/IncreaseByIdTest.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?php
2+
3+
namespace Tests;
4+
5+
use Igrejanet\Firebird\Increasers\IncreaseById;
6+
use PHPUnit\Framework\TestCase;
7+
8+
class IncreaseByIdTest extends TestCase
9+
{
10+
public function testIfSqlForIncreaserWillBeGenerated()
11+
{
12+
$sql = (string) (new IncreaseById('ID', 'USUARIOS'));
13+
14+
$this->assertEquals('SELECT COALESCE(MAX(ID), 0) + 1 as CODIGO FROM USUARIOS', $sql);
15+
}
16+
}

0 commit comments

Comments
 (0)