Skip to content

Commit ef5928b

Browse files
authored
Merge pull request #11 from gdebrauwer/delete-old-codes-query-fix-2
Fix deletion of old codes again
2 parents 8f3d914 + 9dcaefe commit ef5928b

File tree

4 files changed

+45
-4
lines changed

4 files changed

+45
-4
lines changed

.travis.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
language: php
22

3+
services:
4+
- mysql
5+
36
env:
47
global:
58
- COVERAGE=0
@@ -25,6 +28,7 @@ matrix:
2528

2629
before_script:
2730
- composer config discard-changes true
31+
- mysql -e 'create database testing;'
2832

2933
before_install:
3034
- travis_retry composer self-update
@@ -37,7 +41,7 @@ install:
3741
- travis_retry composer update ${COMPOSER_FLAGS} --prefer-dist --no-interaction --no-suggest
3842

3943
script:
40-
- vendor/bin/phpunit --coverage-text --coverage-clover=coverage.clover
44+
- vendor/bin/phpunit --configuration=phpunit.travis.xml.dist --coverage-text --coverage-clover=coverage.clover
4145

4246
after_success:
4347
- if [[ $COVERAGE = 1 ]]; then php vendor/bin/ocular code-coverage:upload --format=php-clover coverage.clover report; fi

phpunit.travis.xml.dist

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<phpunit bootstrap="vendor/autoload.php"
3+
backupGlobals="false"
4+
backupStaticAttributes="false"
5+
colors="true"
6+
verbose="true"
7+
convertErrorsToExceptions="true"
8+
convertNoticesToExceptions="true"
9+
convertWarningsToExceptions="true"
10+
processIsolation="false"
11+
stopOnFailure="false">
12+
<testsuites>
13+
<testsuite name="Next Apps Test Suite">
14+
<directory>tests</directory>
15+
</testsuite>
16+
</testsuites>
17+
<filter>
18+
<whitelist>
19+
<directory suffix=".php">src/</directory>
20+
</whitelist>
21+
</filter>
22+
<logging>
23+
<log type="tap" target="build/report.tap"/>
24+
<log type="junit" target="build/report.junit.xml"/>
25+
<log type="coverage-text" target="build/coverage.txt"/>
26+
<log type="coverage-clover" target="build/logs/clover.xml"/>
27+
</logging>
28+
<php>
29+
<env name="DB_CONNECTION" value="mysql"/>
30+
<env name="DB_DATABASE" value="testing"/>
31+
<env name="DB_USERNAME" value="root"/>
32+
</php>
33+
</phpunit>

src/Models/VerificationCode.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,12 +63,14 @@ public static function boot()
6363
return;
6464
}
6565

66-
VerificationCode::for($verificationCode->verifiable)
66+
$oldVerificationCodeIds = VerificationCode::for($verificationCode->verifiable)
6767
->orderByDesc('expires_at')
6868
->orderByDesc('id')
6969
->skip($maxCodes)
7070
->take(PHP_INT_MAX)
71-
->delete();
71+
->pluck('id');
72+
73+
VerificationCode::whereIn('id', $oldVerificationCodeIds)->delete();
7274
});
7375
}
7476

tests/TestCase.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,16 @@
22

33
namespace NextApps\VerificationCode\Tests;
44

5+
use Illuminate\Foundation\Testing\DatabaseMigrations;
56
use Illuminate\Foundation\Testing\WithFaker;
67
use Illuminate\Support\Facades\Notification;
78
use NextApps\VerificationCode\VerificationCodeServiceProvider;
89
use Orchestra\Testbench\TestCase as Orchestra;
910

1011
abstract class TestCase extends Orchestra
1112
{
12-
use WithFaker;
13+
use WithFaker,
14+
DatabaseMigrations;
1315

1416
/**
1517
* Setup the test environment.

0 commit comments

Comments
 (0)