Skip to content

Commit

Permalink
Merge pull request #13 from ARCANEDEV/develop
Browse files Browse the repository at this point in the history
Updating the package for Laravel 5.5
  • Loading branch information
arcanedev-maroc authored Sep 7, 2017
2 parents 5694f4d + 5651f37 commit 4ba1ea8
Show file tree
Hide file tree
Showing 25 changed files with 252 additions and 165 deletions.
2 changes: 1 addition & 1 deletion .scrutinizer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ checks:
tools:
external_code_coverage:
timeout: 600
runs: 3
runs: 2
php_code_sniffer:
enabled: true
config:
Expand Down
3 changes: 1 addition & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ language: php
sudo: false

php:
- 5.6
- 7.0
- 7.1
- nightly
Expand All @@ -13,7 +12,7 @@ matrix:
- php: nightly

env:
- TESTBENCH_VERSION=3.4.*
- TESTBENCH_VERSION=3.5.*

before_script:
- travis_retry composer self-update
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ If you discover any security related issues, please email arcanedev-maroc@gmail.

Any ideas are welcome. Feel free to submit any issues or pull requests, please check the [contribution guidelines](CONTRIBUTING.md).

[badge_laravel]: https://img.shields.io/badge/For-Laravel%205.x-orange.svg?style=flat-square
[badge_laravel]: https://img.shields.io/badge/Laravel-5.4%20to%205.5-orange.svg?style=flat-square
[badge_license]: https://img.shields.io/packagist/l/arcanedev/laravel-tracker.svg?style=flat-square

[badge_build]: https://img.shields.io/travis/ARCANEDEV/LaravelTracker.svg?style=flat-square
Expand Down
30 changes: 20 additions & 10 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,18 @@
"type": "library",
"license": "MIT",
"require": {
"php": ">=5.6.4",
"arcanedev/geo-ip": "~2.0",
"arcanedev/support": "~4.0",
"jaybizzle/crawler-detect": "~1.0",
"arcanedev/agent": "~2.0",
"ramsey/uuid": "~3.0",
"php": ">=7.0",
"arcanedev/agent": "~3.0",
"arcanedev/geo-ip": "~2.2",
"arcanedev/support": "~4.2",
"jaybizzle/crawler-detect": "~1.2",
"ramsey/uuid": "~3.6",
"snowplow/referer-parser": "~0.2",
"ua-parser/uap-php" : "~3.0"
"ua-parser/uap-php" : "~3.4"
},
"require-dev": {
"phpunit/phpcov": "~3.0",
"phpunit/phpunit": "~5.0"
"phpunit/phpcov": "~4.0",
"phpunit/phpunit": "~6.0"
},
"autoload": {
"psr-4": {
Expand All @@ -39,7 +39,17 @@
"Arcanedev\\LaravelTracker\\Tests\\": "tests/"
}
},
"extra": {
"laravel": {
"providers": [
"Arcanedev\\LaravelTracker\\LaravelTrackerServiceProvider"
],
"aliases": {
"Tracker": "Arcanedev\\LaravelTracker\\Facades\\Tracker"
}
}
},
"scripts": {
"testbench": "composer require --dev \"orchestra/testbench-browser-kit=~3.4.0\" \"orchestra/database=~3.4.0\""
"testbench": "composer require --dev \"orchestra/testbench-browser-kit=~3.5.0\" \"orchestra/database=~3.5.0\""
}
}
4 changes: 2 additions & 2 deletions src/Contracts/Trackers/RouteTracker.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,15 @@ interface RouteTracker
*
* @return bool
*/
public function isTrackable($route);
public function isTrackable(Route $route);

/**
* Track the matched route.
*
* @param \Illuminate\Routing\Route $route
* @param \Illuminate\Http\Request $request
*
* @return mixed
* @return int
*/
public function track(Route $route, Request $request);
}
18 changes: 10 additions & 8 deletions src/Trackers/RouteTracker.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ protected function getModel()
*
* @return bool
*/
public function isTrackable($route)
public function isTrackable(Route $route)
{
return ! $this->isInIgnoredRouteNames($route) &&
! $this->isInIgnoredUris($route);
Expand Down Expand Up @@ -91,7 +91,7 @@ private function trackRoute(Route $route)
*
* @return bool
*/
private function isInIgnoredRouteNames($route)
private function isInIgnoredRouteNames(Route $route)
{
return $this->checkPatterns(
$route->getName(), $this->getConfig('routes.ignore.names', [])
Expand All @@ -105,7 +105,7 @@ private function isInIgnoredRouteNames($route)
*
* @return bool
*/
private function isInIgnoredUris($route)
private function isInIgnoredUris(Route $route)
{
return $this->checkPatterns(
$route->uri(), $this->getConfig('routes.ignore.uris', [])
Expand Down Expand Up @@ -174,11 +174,13 @@ private function trackRoutePathParameters(Route $route, Models\RoutePath $routeP
{
$parameters = [];

foreach ($route->parameters() as $parameter => $value) {
$parameters[] = $this->makeModel(BindingManager::MODEL_ROUTE_PATH_PARAMETER)->fill([
'parameter' => $parameter,
'value' => $this->checkIfValueIsEloquentModel($value),
]);
if ($route->hasParameters()) {
foreach ($route->parameters() as $parameter => $value) {
$parameters[] = $this->makeModel(BindingManager::MODEL_ROUTE_PATH_PARAMETER)->fill([
'parameter' => $parameter,
'value' => $this->checkIfValueIsEloquentModel($value),
]);
}
}

if (count($parameters) > 0)
Expand Down
14 changes: 8 additions & 6 deletions tests/Exceptions/ExceptionFactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,11 @@
*/
class ExceptionFactoryTest extends TestCase
{
/* ------------------------------------------------------------------------------------------------
| Test Functions
| ------------------------------------------------------------------------------------------------
/* -----------------------------------------------------------------
| Tests
| -----------------------------------------------------------------
*/

/** @test */
public function it_can_make()
{
Expand All @@ -37,10 +38,11 @@ public function it_can_make_default_if_not_supported()
);
}

/* ------------------------------------------------------------------------------------------------
| Other Functions
| ------------------------------------------------------------------------------------------------
/* -----------------------------------------------------------------
| Other Methods
| -----------------------------------------------------------------
*/

/**
* Get the supported error exceptions.
*
Expand Down
19 changes: 11 additions & 8 deletions tests/LaravelTrackerServiceProviderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,19 @@
*/
class LaravelTrackerServiceProviderTest extends TestCase
{
/* ------------------------------------------------------------------------------------------------
/* -----------------------------------------------------------------
| Properties
| ------------------------------------------------------------------------------------------------
| -----------------------------------------------------------------
*/

/** @var \Arcanedev\LaravelTracker\LaravelTrackerServiceProvider */
protected $provider;

/* ------------------------------------------------------------------------------------------------
| Main Functions
| ------------------------------------------------------------------------------------------------
/* -----------------------------------------------------------------
| Main Methods
| -----------------------------------------------------------------
*/

public function setUp()
{
parent::setUp();
Expand All @@ -33,10 +35,11 @@ public function tearDown()
parent::tearDown();
}

/* ------------------------------------------------------------------------------------------------
| Test Functions
| ------------------------------------------------------------------------------------------------
/* -----------------------------------------------------------------
| Tests
| -----------------------------------------------------------------
*/

/** @test */
public function it_can_be_instantiated()
{
Expand Down
14 changes: 8 additions & 6 deletions tests/MigrationsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,11 @@
*/
class MigrationsTest extends TestCase
{
/* ------------------------------------------------------------------------------------------------
| Test Functions
| ------------------------------------------------------------------------------------------------
/* -----------------------------------------------------------------
| Tests
| -----------------------------------------------------------------
*/

/** @test */
public function it_can_publish_migrations()
{
Expand Down Expand Up @@ -44,10 +45,11 @@ public function it_can_migrate()
}
}

/* ------------------------------------------------------------------------------------------------
| Other Functions
| ------------------------------------------------------------------------------------------------
/* -----------------------------------------------------------------
| Other Methods
| -----------------------------------------------------------------
*/

private function getTablesNames($prefix = 'tracker_')
{
$tables = array_map(function ($table) use ($prefix) {
Expand Down
14 changes: 8 additions & 6 deletions tests/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,11 @@
*/
abstract class TestCase extends BaseTestCase
{
/* ------------------------------------------------------------------------------------------------
| Main Functions
| ------------------------------------------------------------------------------------------------
/* -----------------------------------------------------------------
| Main Methods
| -----------------------------------------------------------------
*/

public function setUp()
{
parent::setUp();
Expand Down Expand Up @@ -138,10 +139,11 @@ function () {
});
}

/* ------------------------------------------------------------------------------------------------
| Other Functions
| ------------------------------------------------------------------------------------------------
/* -----------------------------------------------------------------
| Other Methods
| -----------------------------------------------------------------
*/

/**
* Migrate the migrations.
*/
Expand Down
27 changes: 18 additions & 9 deletions tests/TrackerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,19 @@
*/
class TrackerTest extends TestCase
{
/* ------------------------------------------------------------------------------------------------
/* -----------------------------------------------------------------
| Properties
| ------------------------------------------------------------------------------------------------
| -----------------------------------------------------------------
*/

/** @var \Arcanedev\LaravelTracker\Tracker */
private $tracker;

/* ------------------------------------------------------------------------------------------------
| Main Functions
| ------------------------------------------------------------------------------------------------
/* -----------------------------------------------------------------
| Main Methods
| -----------------------------------------------------------------
*/

public function setUp()
{
parent::setUp();
Expand All @@ -35,10 +37,11 @@ public function tearDown()
parent::tearDown();
}

/* ------------------------------------------------------------------------------------------------
| Test Functions
| ------------------------------------------------------------------------------------------------
/* -----------------------------------------------------------------
| Tests
| -----------------------------------------------------------------
*/

/** @test */
public function it_can_be_instantiated()
{
Expand Down Expand Up @@ -89,6 +92,12 @@ public function it_can_track()
// Without an authenticated user
$this->call('GET', '/');

// TODO: Complete the implementation
$activities = \Arcanedev\LaravelTracker\Models\VisitorActivity::all();

$this->assertCount(1, $activities);

$this->assertNull($activities->first()->error_id);

// TODO: Adding more test assertions ?
}
}
19 changes: 11 additions & 8 deletions tests/Trackers/CookieTrackerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,19 @@
*/
class CookieTrackerTest extends TestCase
{
/* ------------------------------------------------------------------------------------------------
/* -----------------------------------------------------------------
| Properties
| ------------------------------------------------------------------------------------------------
| -----------------------------------------------------------------
*/

/** @var \Arcanedev\LaravelTracker\Contracts\Trackers\CookieTracker */
private $tracker;

/* ------------------------------------------------------------------------------------------------
| Main Functions
| ------------------------------------------------------------------------------------------------
/* -----------------------------------------------------------------
| Main Methods
| -----------------------------------------------------------------
*/

public function setUp()
{
parent::setUp();
Expand All @@ -33,10 +35,11 @@ public function tearDown()
parent::tearDown();
}

/* ------------------------------------------------------------------------------------------------
| Test Functions
| ------------------------------------------------------------------------------------------------
/* -----------------------------------------------------------------
| Tests
| -----------------------------------------------------------------
*/

/** @test */
public function it_can_be_instantiated()
{
Expand Down
Loading

0 comments on commit 4ba1ea8

Please sign in to comment.