Skip to content

Commit

Permalink
Merge pull request #255 from ash-jc-allen/analysis-newQvN
Browse files Browse the repository at this point in the history
Apply fixes from StyleCI
  • Loading branch information
ash-jc-allen authored Apr 25, 2024
2 parents b64ee6d + b9369a4 commit 66aff45
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 24 deletions.
2 changes: 1 addition & 1 deletion src/Classes/Resolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ protected function trackVisit(ShortURL $shortURL, ShortURLVisit $visit, Request
* Guess and return the device type that was used to visit the short URL. Null
* will be returned if we cannot determine the device type.
*
* @param UserAgentDriver $userAgentParser
* @param UserAgentDriver $userAgentParser
* @return string|null
*/
protected function guessDeviceType(UserAgentDriver $userAgentParser): ?string
Expand Down
47 changes: 24 additions & 23 deletions tests/Unit/Classes/ResolverTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -101,15 +101,15 @@ public function request_is_aborted_if_url_is_single_use_and_has_already_been_vis

$shortURL = ShortURL::create([
'destination_url' => 'https://google.com',
'default_short_url' => config('short-url.default_url') . '/short/12345',
'default_short_url' => config('short-url.default_url').'/short/12345',
'url_key' => '12345',
'single_use' => true,
'track_visits' => true,
]);

ShortURLVisit::create(['short_url_id' => $shortURL->id, 'visited_at' => now()]);

$request = Request::create(config('short-url.default_url') . '/short/12345');
$request = Request::create(config('short-url.default_url').'/short/12345');

$resolver = new Resolver();
$resolver->handleVisit($request, $shortURL);
Expand All @@ -120,14 +120,14 @@ public function request_is_not_aborted_if_url_is_single_use_and_has_not_been_vis
{
$shortURL = ShortURL::create([
'destination_url' => 'https://google.com',
'default_short_url' => config('short-url.default_url') . '/short/12345',
'default_short_url' => config('short-url.default_url').'/short/12345',
'url_key' => '12345',
'single_use' => true,
'track_visits' => true,
'activated_at' => now()->subSecond(),
]);

$request = Request::create(config('short-url.default_url') . '/short/12345');
$request = Request::create(config('short-url.default_url').'/short/12345');

$resolver = new Resolver();
$result = $resolver->handleVisit($request, $shortURL);
Expand All @@ -140,7 +140,7 @@ public function request_is_not_aborted_if_url_is_not_single_use_and_has_been_vis
{
$shortURL = ShortURL::create([
'destination_url' => 'https://google.com',
'default_short_url' => config('short-url.default_url') . '/short/12345',
'default_short_url' => config('short-url.default_url').'/short/12345',
'url_key' => '12345',
'single_use' => false,
'track_visits' => true,
Expand All @@ -149,7 +149,7 @@ public function request_is_not_aborted_if_url_is_not_single_use_and_has_been_vis

ShortURLVisit::create(['short_url_id' => $shortURL->id, 'visited_at' => now()]);

$request = Request::create(config('short-url.default_url') . '/short/12345');
$request = Request::create(config('short-url.default_url').'/short/12345');

$resolver = new Resolver();
$result = $resolver->handleVisit($request, $shortURL);
Expand All @@ -161,14 +161,14 @@ public function visit_details_are_not_recorded_if_url_does_not_have_tracking_ena
{
$shortURL = ShortURL::create([
'destination_url' => 'https://google.com',
'default_short_url' => config('short-url.default_url') . '/short/12345',
'default_short_url' => config('short-url.default_url').'/short/12345',
'url_key' => '12345',
'single_use' => false,
'track_visits' => false,
'activated_at' => now()->subSecond(),
]);

$request = Request::create(config('short-url.default_url') . '/short/12345');
$request = Request::create(config('short-url.default_url').'/short/12345');

$resolver = new Resolver();
$result = $resolver->handleVisit($request, $shortURL);
Expand All @@ -187,13 +187,14 @@ public function visit_details_are_not_recorded_if_url_does_not_have_tracking_ena

/**
* @test
*
* @dataProvider trackingFieldsProvider
*/
public function visit_is_recorded_if_url_has_tracking_enabled(string $userAgent, array $expectedTrackingData): void
{
$shortURL = ShortURL::create([
'destination_url' => 'https://google.com',
'default_short_url' => config('short-url.default_url') . '/short/12345',
'default_short_url' => config('short-url.default_url').'/short/12345',
'url_key' => '12345',
'single_use' => false,
'track_visits' => true,
Expand All @@ -208,7 +209,7 @@ public function visit_is_recorded_if_url_has_tracking_enabled(string $userAgent,
]);

$request = Request::create(
uri: config('short-url.default_url') . '/short/12345',
uri: config('short-url.default_url').'/short/12345',
server: [
'HTTP_USER_AGENT' => $userAgent,
]
Expand All @@ -231,7 +232,7 @@ public function visit_is_recorded_if_url_has_tracking_enabled_and_the_user_agent
{
$shortURL = ShortURL::create([
'destination_url' => 'https://google.com',
'default_short_url' => config('short-url.default_url') . '/short/12345',
'default_short_url' => config('short-url.default_url').'/short/12345',
'url_key' => '12345',
'single_use' => false,
'track_visits' => true,
Expand All @@ -246,7 +247,7 @@ public function visit_is_recorded_if_url_has_tracking_enabled_and_the_user_agent
]);

$request = Request::create(
uri: config('short-url.default_url') . '/short/12345',
uri: config('short-url.default_url').'/short/12345',
server: [
'HTTP_USER_AGENT' => 'INVALID',
]
Expand All @@ -273,7 +274,7 @@ public function visit_is_recorded_if_url_has_tracking_enabled_and_the_user_agent
{
$shortURL = ShortURL::create([
'destination_url' => 'https://google.com',
'default_short_url' => config('short-url.default_url') . '/short/12345',
'default_short_url' => config('short-url.default_url').'/short/12345',
'url_key' => '12345',
'single_use' => false,
'track_visits' => true,
Expand All @@ -288,7 +289,7 @@ public function visit_is_recorded_if_url_has_tracking_enabled_and_the_user_agent
]);

$request = Request::create(
uri: config('short-url.default_url') . '/short/12345',
uri: config('short-url.default_url').'/short/12345',
server: [
'HTTP_USER_AGENT' => null,
]
Expand Down Expand Up @@ -318,7 +319,7 @@ public function only_specific_fields_are_recorded_if_enabled()

$shortURL = ShortURL::create([
'destination_url' => 'https://google.com',
'default_short_url' => config('short-url.default_url') . '/short/12345',
'default_short_url' => config('short-url.default_url').'/short/12345',
'url_key' => '12345',
'single_use' => false,
'track_visits' => true,
Expand All @@ -333,7 +334,7 @@ public function only_specific_fields_are_recorded_if_enabled()
]);

$request = Request::create(
uri: config('short-url.default_url') . '/short/12345',
uri: config('short-url.default_url').'/short/12345',
server: [
'HTTP_referer' => 'https://google.com',
'HTTP_USER_AGENT' => self::trackingFieldsProvider()[1][0],
Expand Down Expand Up @@ -362,14 +363,14 @@ public function request_is_aborted_if_url_is_single_use_and_the_tracking_is_not_
{
$shortURL = ShortURL::create([
'destination_url' => 'https://google.com',
'default_short_url' => config('short-url.default_url') . '/short/12345',
'default_short_url' => config('short-url.default_url').'/short/12345',
'url_key' => '12345',
'single_use' => true,
'track_visits' => false,
'activated_at' => now()->subSecond(),
]);

$request = Request::create(config('short-url.default_url') . '/short/12345');
$request = Request::create(config('short-url.default_url').'/short/12345');

$resolver = new Resolver();

Expand All @@ -387,7 +388,7 @@ public function referer_url_is_stored_if_it_is_enabled()
{
$shortURL = ShortURL::create([
'destination_url' => 'https://google.com',
'default_short_url' => config('short-url.default_url') . '/short/12345',
'default_short_url' => config('short-url.default_url').'/short/12345',
'url_key' => '12345',
'single_use' => false,
'track_visits' => true,
Expand All @@ -401,9 +402,9 @@ public function referer_url_is_stored_if_it_is_enabled()
'activated_at' => now()->subSecond(),
]);

$request = Request::create(config('short-url.default_url') . '/short/12345', 'GET', [], [], [], [
$request = Request::create(config('short-url.default_url').'/short/12345', 'GET', [], [], [], [
'HTTP_referer' => 'https://google.com',
'HTTP_USER_AGENT' => static::trackingFieldsProvider()[1][0]
'HTTP_USER_AGENT' => static::trackingFieldsProvider()[1][0],
]);

$resolver = new Resolver();
Expand All @@ -423,7 +424,7 @@ public function fields_are_not_recorded_if_all_are_true_but_track_visits_is_disa
{
$shortURL = ShortURL::create([
'destination_url' => 'https://google.com',
'default_short_url' => config('short-url.default_url') . '/short/12345',
'default_short_url' => config('short-url.default_url').'/short/12345',
'url_key' => '12345',
'single_use' => false,
'track_visits' => false,
Expand All @@ -437,7 +438,7 @@ public function fields_are_not_recorded_if_all_are_true_but_track_visits_is_disa
'activated_at' => now()->subSecond(),
]);

$request = Request::create(config('short-url.default_url') . '/short/12345', 'GET', [], [], [], [
$request = Request::create(config('short-url.default_url').'/short/12345', 'GET', [], [], [], [
'HTTP_referer' => 'https://google.com',
'HTTP_USER_AGENT' => static::trackingFieldsProvider()[1][0],
]);
Expand Down

0 comments on commit 66aff45

Please sign in to comment.