Skip to content

Commit

Permalink
support of select(*) and latest laravel dependancy added
Browse files Browse the repository at this point in the history
  • Loading branch information
Tapan-Tops committed Jan 21, 2025
1 parent ecaff8f commit 330d869
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 25 deletions.
6 changes: 3 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,9 @@
"minimum-stability": "dev",
"prefer-stable": true,
"require-dev": {
"orchestra/testbench": "^8.0",
"pestphp/pest": "^2.0",
"pestphp/pest-plugin-laravel": "^2.0"
"orchestra/testbench": "^8.0|^9.0",
"pestphp/pest": "^2.0|^3.0",
"pestphp/pest-plugin-laravel": "^2.0|^3.0"
},
"scripts": {
"test": "./vendor/bin/pest"
Expand Down
25 changes: 6 additions & 19 deletions phpunit.xml
Original file line number Diff line number Diff line change
@@ -1,23 +1,5 @@
<?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>
</coverage>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" bootstrap="vendor/autoload.php" backupGlobals="false" colors="true" processIsolation="false" stopOnFailure="false" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/11.5/phpunit.xsd" cacheDirectory=".phpunit.cache" backupStaticProperties="false">
<testsuites>
<testsuite name="Unit">
<directory suffix="Test.php">./tests/Unit</directory>
Expand All @@ -28,4 +10,9 @@
<env name="APP_KEY" value="base64:2fl+Ktvkfl+Fuz4Qp/A75G2RTiWVA/ZoKZvp6fiiM10="/>
<env name="APP_AESENCRYPT_KEY" value="secret"/>
</php>
<source>
<include>
<directory suffix=".php">src/</directory>
</include>
</source>
</phpunit>
31 changes: 31 additions & 0 deletions phpunit.xml.bak
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?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>
</coverage>
<testsuites>
<testsuite name="Unit">
<directory suffix="Test.php">./tests/Unit</directory>
</testsuite>
</testsuites>
<php>
<env name="DB_CONNECTION" value="testing"/>
<env name="APP_KEY" value="base64:2fl+Ktvkfl+Fuz4Qp/A75G2RTiWVA/ZoKZvp6fiiM10="/>
<env name="APP_AESENCRYPT_KEY" value="secret"/>
</php>
</phpunit>
4 changes: 3 additions & 1 deletion src/Scopes/DecryptSelectScope.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ public function apply(Builder $builder, Model $model)

$encryptable = $model->encryptable();

$columns = empty($columns) ? Schema::getColumnListing($model->getTable()) : $columns;
if (empty($columns) || $columns === ['*'] || $columns === '*') {
$columns = Schema::getColumnListing($model->getTable());
}

$select = collect($columns)->map(function ($column) use ($encryptable) {
return (in_array($column, $encryptable)) ? db_decrypt($column) : $column;
Expand Down
2 changes: 1 addition & 1 deletion tests/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ protected function getEnvironmentSetUp($app)
'port' => '3306',
'database' => 'testing',
'username' => 'root',
'password' => '',
'password' => 'tops12345',
'unix_socket' => '',
'charset' => 'utf8mb4',
'collation' => 'utf8mb4_unicode_ci',
Expand Down
1 change: 0 additions & 1 deletion tests/Unit/DatabaseTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@

it('can match Sql syntex', function () {
$query = Testing::query()->whereEncrypted('value', 'testing string')->toSql();
echo PHP_EOL . $query . PHP_EOL;
expect($query)->toMatch('/(AES_DECRYPT\(([^\)]+)\))/');
});

Expand Down

0 comments on commit 330d869

Please sign in to comment.