Skip to content

Commit ac19487

Browse files
committed
wip
1 parent e903f23 commit ac19487

File tree

5 files changed

+19
-26
lines changed

5 files changed

+19
-26
lines changed

.env.example

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ APP_MAINTENANCE_STORE=database
1212
CACHE_STORE=file
1313
SESSION_DRIVER=file
1414

15+
AUTH_PASSWORD_RESET_TOKEN_TABLE=password_resets
16+
1517
BCRYPT_ROUNDS=12
1618

1719
DB_DATABASE=laravel

phpunit.xml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,10 @@
2020
<env name="APP_KEY" value="base64:NXoQgjw2ZlOxnGbo5ZRhYgTdM6xLYsgYElNAgcTQJkE="/>
2121
<env name="APP_HOST" value="localhost"/>
2222
<env name="APP_URL" value="http://localhost"/>
23+
<env name="AUTH_PASSWORD_RESET_TOKEN_TABLE" value="password_resets"/>
2324
<env name="CACHE_STORE" value="array"/>
24-
<env name="DB_CONNECTION" value="sqlite"/>
25-
<env name="DB_DATABASE" value=":memory:"/>
25+
<env name="DB_CONNECTION" value="mysql"/>
26+
<env name="DB_DATABASE" value="testing"/>
2627
<env name="MAIL_MAILER" value="array"/>
2728
<env name="SESSION_DRIVER" value="array"/>
2829
<env name="QUEUE_CONNECTION" value="sync"/>

tests/Unit/Rules/DoesNotContainUrlRuleTest.php

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,13 @@
33
use App\Rules\DoesNotContainUrlRule;
44

55
it('detects a url in a string', function () {
6-
$this->assertFalse(
7-
(new DoesNotContainUrlRule())->passes('foo', 'This is a string http://example.com with an url in it.'),
8-
);
9-
});
6+
(new DoesNotContainUrlRule())->validate('foo', 'This is a string http://example.com with an url in it.', fn () => throw new Exception());
7+
})->throws(Exception::class);
108

119
it('passes when no url is present', function () {
12-
$this->assertTrue(
13-
(new DoesNotContainUrlRule())->passes('foo', 'This is a string without an url in it.'),
14-
);
15-
});
10+
(new DoesNotContainUrlRule())->validate('foo', 'This is a string without an url in it.', fn () => throw new Exception());
11+
})->throwsNoExceptions();
1612

1713
it('passes when extra spaces are present', function () {
18-
$this->assertTrue(
19-
(new DoesNotContainUrlRule())->passes('foo', 'This is a string with extra spaces.'),
20-
);
21-
});
14+
(new DoesNotContainUrlRule())->validate('foo', 'This is a string with extra spaces.', fn () => throw new Exception());
15+
})->throwsNoExceptions();

tests/Unit/Rules/HttpImageRuleTest.php

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,9 @@
33
use App\Rules\HttpImageRule;
44

55
it('passes when no http links are detected', function () {
6-
$this->assertTrue(
7-
(new HttpImageRule())->passes('body', 'some text ![](https://link.com)'),
8-
);
9-
});
6+
(new HttpImageRule())->validate('body', 'some text ![](https://link.com)', fn () => throw new Exception());
7+
})->throwsNoExceptions();
108

119
it('fails when http links are detected', function () {
12-
$this->assertFalse(
13-
(new HttpImageRule())->passes('body', 'some text ![](http://link.com)'),
14-
);
15-
});
10+
(new HttpImageRule())->validate('body', 'some text ![](http://link.com)', fn () => throw new Exception());
11+
})->throws(Exception::class);

tests/Unit/Rules/InvalidMentionRuleTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
use App\Rules\InvalidMentionRule;
44

55
it('passes when no invalid mentions are detected', function ($body) {
6-
expect((new InvalidMentionRule())->passes('body', $body))->toBeTrue();
6+
expect((new InvalidMentionRule())->validate('body', $body, fn () => throw new Exception()));
77
})->with([
88
'Hello, I\'m looking for some help',
99
'I\'ve seen [this link](https://example.com), is it legit?',
@@ -24,10 +24,10 @@
2424
[link](https://example.com)
2525
\n
2626
![image](https://example.com/image.png)",
27-
]);
27+
])->throwsNoExceptions();
2828

2929
it('fails when invalid mentions are detected', function ($body) {
30-
expect((new InvalidMentionRule())->passes('body', $body))->toBeFalse();
30+
expect((new InvalidMentionRule())->validate('body', $body, fn () => throw new Exception()));
3131
})->with([
3232
'[@driesvints](https://somethingnasty.com)',
3333
'Hey [@joedixon](https://somethingnasty.com), is it legit?',
@@ -48,4 +48,4 @@
4848
[link](https://example.com)
4949
\n
5050
![image](https://example.com/image.png)",
51-
]);
51+
])->throws(Exception::class);

0 commit comments

Comments
 (0)