diff --git a/.scrutinizer.yml b/.scrutinizer.yml index d44a72f..282131b 100644 --- a/.scrutinizer.yml +++ b/.scrutinizer.yml @@ -22,7 +22,7 @@ checks: tools: external_code_coverage: timeout: 600 - runs: 2 + runs: 3 php_code_sniffer: enabled: true config: diff --git a/.travis.yml b/.travis.yml index 62f99f8..6a8ff58 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,18 +5,16 @@ sudo: false php: - 7.0 - 7.1 + - 7.2 - nightly matrix: allow_failures: - php: nightly -env: - - TESTBENCH_VERSION=3.5.* - before_script: - travis_retry composer self-update - - travis_retry composer require --prefer-source --no-interaction --dev "orchestra/testbench-browser-kit:${TESTBENCH_VERSION}" "orchestra/database:${TESTBENCH_VERSION}" + - travis_retry composer install --prefer-source --no-interaction script: - composer validate diff --git a/composer.json b/composer.json index 19aa003..95f1e7b 100644 --- a/composer.json +++ b/composer.json @@ -18,16 +18,18 @@ "require": { "php": ">=7.0", "arcanedev/agent": "~3.0", - "arcanedev/geo-ip": "~2.2", - "arcanedev/support": "~4.2", + "arcanedev/geo-ip": "~2.2.0", + "arcanedev/support": "~4.2.0", "jaybizzle/crawler-detect": "~1.2", "ramsey/uuid": "~3.6", "snowplow/referer-parser": "~0.2", "ua-parser/uap-php" : "~3.4" }, "require-dev": { - "phpunit/phpcov": "~4.0", - "phpunit/phpunit": "~6.0" + "orchestra/testbench": "~3.5.0", + "orchestra/database": "~3.5.0", + "phpunit/phpunit": "~6.0", + "phpunit/phpcov": "~4.0" }, "autoload": { "psr-4": { @@ -43,13 +45,7 @@ "laravel": { "providers": [ "Arcanedev\\LaravelTracker\\LaravelTrackerServiceProvider" - ], - "aliases": { - "Tracker": "Arcanedev\\LaravelTracker\\Facades\\Tracker" - } + ] } - }, - "scripts": { - "testbench": "composer require --dev \"orchestra/testbench-browser-kit=~3.5.0\" \"orchestra/database=~3.5.0\"" } } diff --git a/phpunit.xml.dist b/phpunit.xml.dist index d51813a..afca6cc 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -23,6 +23,7 @@ + diff --git a/src/Bases/Migration.php b/src/Bases/Migration.php index 18cccf0..17f36d0 100644 --- a/src/Bases/Migration.php +++ b/src/Bases/Migration.php @@ -1,6 +1,6 @@ $class) { $exception = ExceptionFactory::make($code, 'This is a message'); - $this->assertInstanceOf($class, $exception); + static::assertInstanceOf($class, $exception); } } /** @test */ public function it_can_make_default_if_not_supported() { - $this->assertInstanceOf( + static::assertInstanceOf( Errors\Error::class, ExceptionFactory::make(600, 'Kabooom!!') ); diff --git a/tests/LaravelTrackerServiceProviderTest.php b/tests/LaravelTrackerServiceProviderTest.php index e75152b..f4d8251 100644 --- a/tests/LaravelTrackerServiceProviderTest.php +++ b/tests/LaravelTrackerServiceProviderTest.php @@ -51,7 +51,7 @@ public function it_can_be_instantiated() ]; foreach ($expectations as $expected) { - $this->assertInstanceOf($expected, $this->provider); + static::assertInstanceOf($expected, $this->provider); } } @@ -62,6 +62,6 @@ public function it_can_provides() \Arcanedev\LaravelTracker\Contracts\Tracker::class, ]; - $this->assertSame($expected, $this->provider->provides()); + static::assertSame($expected, $this->provider->provides()); } } diff --git a/tests/MigrationsTest.php b/tests/MigrationsTest.php index 6e7a384..3bc0a41 100644 --- a/tests/MigrationsTest.php +++ b/tests/MigrationsTest.php @@ -23,11 +23,11 @@ public function it_can_publish_migrations() $src = $this->getMigrationsSrcPath(); $dest = $this->getMigrationsDestPath(); - $this->assertCount(0, $filesystem->allFiles($dest)); + static::assertCount(0, $filesystem->allFiles($dest)); $this->publishMigrations(); - $this->assertEquals( + static::assertEquals( count($filesystem->allFiles($src)), count($filesystem->allFiles($dest)) ); @@ -41,7 +41,7 @@ public function it_can_migrate() $this->migrate(); foreach ($this->getTablesNames() as $table) { - $this->assertTrue(Schema::hasTable($table), "The table [$table] not found in the database."); + static::assertTrue(Schema::hasTable($table), "The table [$table] not found in the database."); } } diff --git a/tests/TestCase.php b/tests/TestCase.php index 2840c63..d558228 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -1,6 +1,6 @@ settingDatabase($app['config']); $this->settingConfigs($app['config']); $this->settingRoutes($app['router']); } - /** - * Setting the database. - * - * @param \Illuminate\Contracts\Config\Repository $config - */ - private function settingDatabase($config) - { - $config->set('database.default', 'testing'); - $config->set('database.connections.testing', [ - 'driver' => 'sqlite', - 'database' => ':memory:', - 'prefix' => '', - ]); - } - /** * Setting the configs. * diff --git a/tests/TrackerTest.php b/tests/TrackerTest.php index 12c08df..a8e33c8 100644 --- a/tests/TrackerTest.php +++ b/tests/TrackerTest.php @@ -24,6 +24,7 @@ class TrackerTest extends TestCase public function setUp() { parent::setUp(); + $this->migrate(); $this->tracker = $this->app->make(\Arcanedev\LaravelTracker\Contracts\Tracker::class); @@ -51,9 +52,9 @@ public function it_can_be_instantiated() ]; foreach ($expectations as $expected) { - $this->assertInstanceOf($expected, $this->tracker); + static::assertInstanceOf($expected, $this->tracker); } - $this->assertTrue($this->tracker->isEnabled()); + static::assertTrue($this->tracker->isEnabled()); } /** @test */ @@ -67,23 +68,23 @@ public function it_can_be_instantiated_via_contract() ]; foreach ($expectations as $expected) { - $this->assertInstanceOf($expected, $this->tracker); + static::assertInstanceOf($expected, $this->tracker); } - $this->assertTrue($this->tracker->isEnabled()); + static::assertTrue($this->tracker->isEnabled()); } /** @test */ public function it_can_enable_and_disable() { - $this->assertTrue($this->tracker->isEnabled()); + static::assertTrue($this->tracker->isEnabled()); $this->tracker->disable(); - $this->assertFalse($this->tracker->isEnabled()); + static::assertFalse($this->tracker->isEnabled()); $this->tracker->enable(); - $this->assertTrue($this->tracker->isEnabled()); + static::assertTrue($this->tracker->isEnabled()); } /** @test */ @@ -94,9 +95,9 @@ public function it_can_track() $activities = \Arcanedev\LaravelTracker\Models\VisitorActivity::all(); - $this->assertCount(1, $activities); + static::assertCount(1, $activities); - $this->assertNull($activities->first()->error_id); + static::assertNull($activities->first()->error_id); // TODO: Adding more test assertions ? } diff --git a/tests/Trackers/CookieTrackerTest.php b/tests/Trackers/CookieTrackerTest.php index b71c0b1..2cabded 100644 --- a/tests/Trackers/CookieTrackerTest.php +++ b/tests/Trackers/CookieTrackerTest.php @@ -49,7 +49,7 @@ public function it_can_be_instantiated() ]; foreach ($expectations as $expected) { - $this->assertInstanceOf($expected, $this->tracker); + static::assertInstanceOf($expected, $this->tracker); } } @@ -58,9 +58,9 @@ public function it_can_track() { $uuid = '25769c6c-d34d-4bfe-ba98-e0ee856f3e7a'; - $this->assertSame(1, $this->tracker->track($uuid)); + static::assertSame(1, $this->tracker->track($uuid)); - $this->seeInDatabase('tracker_cookies', [ + static::assertDatabaseHas('tracker_cookies', [ 'id' => 1, 'uuid' => $uuid, ]); diff --git a/tests/Trackers/DeviceTrackerTest.php b/tests/Trackers/DeviceTrackerTest.php index f53357a..9bbe4c2 100644 --- a/tests/Trackers/DeviceTrackerTest.php +++ b/tests/Trackers/DeviceTrackerTest.php @@ -49,14 +49,14 @@ public function it_can_be_instantiated() ]; foreach ($expectations as $expected) { - $this->assertInstanceOf($expected, $this->tracker); + static::assertInstanceOf($expected, $this->tracker); } } /** @test */ public function it_can_track() { - $this->assertSame(1, $this->tracker->track()); + static::assertSame(1, $this->tracker->track()); // TODO: Add database assertions } diff --git a/tests/Trackers/ErrorTrackerTest.php b/tests/Trackers/ErrorTrackerTest.php index f80a441..d3d33b9 100644 --- a/tests/Trackers/ErrorTrackerTest.php +++ b/tests/Trackers/ErrorTrackerTest.php @@ -49,7 +49,7 @@ public function it_can_be_instantiated() ]; foreach ($expectations as $expected) { - $this->assertInstanceOf($expected, $this->tracker); + static::assertInstanceOf($expected, $this->tracker); } } @@ -58,9 +58,9 @@ public function it_can_track() { $exception = new \Exception('Page not found exception.', 404); - $this->assertSame(1, $this->tracker->track($exception)); + static::assertSame(1, $this->tracker->track($exception)); - $this->seeInDatabase('tracker_errors', [ + $this->assertDatabaseHas('tracker_errors', [ 'id' => 1, 'code' => $exception->getCode(), 'message' => $exception->getMessage(), @@ -77,13 +77,13 @@ public function it_can_track_an_exception_with_handler() $errors = \Arcanedev\LaravelTracker\Models\Error::all(); - $this->assertCount(1, $errors); + static::assertCount(1, $errors); /** @var \Arcanedev\LaravelTracker\Models\Error $error */ $error = $errors->first(); - $this->assertSame('404', $error->code); - $this->assertSame('', $error->message); + static::assertSame('404', $error->code); + static::assertSame('', $error->message); // TODO: Adding more test assertions ? } diff --git a/tests/Trackers/GeoIpTrackerTest.php b/tests/Trackers/GeoIpTrackerTest.php index af95967..65aa748 100644 --- a/tests/Trackers/GeoIpTrackerTest.php +++ b/tests/Trackers/GeoIpTrackerTest.php @@ -49,7 +49,7 @@ public function it_can_be_instantiated() ]; foreach ($expectations as $expected) { - $this->assertInstanceOf($expected, $this->tracker); + static::assertInstanceOf($expected, $this->tracker); } } @@ -58,9 +58,9 @@ public function it_can_track() { $ip = '128.101.101.101'; - $this->assertSame(1, $this->tracker->track($ip)); + static::assertSame(1, $this->tracker->track($ip)); - $this->seeInDatabase('tracker_geoip', [ + $this->assertDatabaseHas('tracker_geoip', [ 'iso_code' => 'US', 'country' => 'United States', 'city' => 'Minneapolis', diff --git a/tests/Trackers/LanguageTrackerTest.php b/tests/Trackers/LanguageTrackerTest.php index 6f90212..4379221 100644 --- a/tests/Trackers/LanguageTrackerTest.php +++ b/tests/Trackers/LanguageTrackerTest.php @@ -49,14 +49,14 @@ public function it_can_be_instantiated() ]; foreach ($expectations as $expected) { - $this->assertInstanceOf($expected, $this->tracker); + static::assertInstanceOf($expected, $this->tracker); } } /** @test */ public function it_can_track() { - $this->assertSame(1, $this->tracker->track()); + static::assertSame(1, $this->tracker->track()); // TODO: Add database assertions } diff --git a/tests/Trackers/PathTrackerTest.php b/tests/Trackers/PathTrackerTest.php index 364b451..b339fa3 100644 --- a/tests/Trackers/PathTrackerTest.php +++ b/tests/Trackers/PathTrackerTest.php @@ -49,7 +49,7 @@ public function it_can_be_instantiated() ]; foreach ($expectations as $expected) { - $this->assertInstanceOf($expected, $this->tracker); + static::assertInstanceOf($expected, $this->tracker); } } @@ -57,9 +57,9 @@ public function it_can_be_instantiated() public function it_can_track() { $path = 'http://www.arcanedev.net'; - $this->assertSame(1, $this->tracker->track($path)); + static::assertSame(1, $this->tracker->track($path)); - $this->seeInDatabase('tracker_paths', [ + $this->assertDatabaseHas('tracker_paths', [ 'id' => 1, 'path' => $path, ]); diff --git a/tests/Trackers/QueryTrackerTest.php b/tests/Trackers/QueryTrackerTest.php index 6ecd054..6c2c51f 100644 --- a/tests/Trackers/QueryTrackerTest.php +++ b/tests/Trackers/QueryTrackerTest.php @@ -52,7 +52,7 @@ public function it_can_track() ], ]; - $this->assertSame(1, $this->tracker->track($queries)); + static::assertSame(1, $this->tracker->track($queries)); // TODO: Add database assertions } diff --git a/tests/Trackers/RefererTrackerTest.php b/tests/Trackers/RefererTrackerTest.php index a0aba98..0a4a8ee 100644 --- a/tests/Trackers/RefererTrackerTest.php +++ b/tests/Trackers/RefererTrackerTest.php @@ -49,7 +49,7 @@ public function it_can_be_instantiated() ]; foreach ($expectations as $expected) { - $this->assertInstanceOf($expected, $this->tracker); + static::assertInstanceOf($expected, $this->tracker); } } @@ -59,7 +59,7 @@ public function it_can_track() $refererUrl = 'http://www.google.com/search?q=laravel+tracking+package'; $pageUrl = 'https://github.com/ARCANEDEV/LaravelTracker'; - $this->assertSame(1, $this->tracker->track($refererUrl, $pageUrl)); + static::assertSame(1, $this->tracker->track($refererUrl, $pageUrl)); // TODO: Add database assertions } diff --git a/tests/Trackers/RouteTrackerTest.php b/tests/Trackers/RouteTrackerTest.php index f7f7da3..880d15b 100644 --- a/tests/Trackers/RouteTrackerTest.php +++ b/tests/Trackers/RouteTrackerTest.php @@ -46,7 +46,7 @@ public function it_can_be_instantiated() ]; foreach ($expectations as $expected) { - $this->assertInstanceOf($expected, $this->tracker); + static::assertInstanceOf($expected, $this->tracker); } } @@ -55,11 +55,11 @@ public function it_can_check_if_trackable() { $route = $this->makeContactRoute(); - $this->assertTrue($this->tracker->isTrackable($route)); + static::assertTrue($this->tracker->isTrackable($route)); $route = $this->makeAdminRoute(); - $this->assertFalse($this->tracker->isTrackable($route)); + static::assertFalse($this->tracker->isTrackable($route)); } /** @test */ @@ -67,25 +67,25 @@ public function it_can_track() { $route = $this->makeContactRoute(); - $this->assertSame(1, $this->tracker->track($route, request())); + static::assertSame(1, $this->tracker->track($route, request())); $routes = \Arcanedev\LaravelTracker\Models\Route::all(); - $this->assertCount(1, $routes); + static::assertCount(1, $routes); /** @var \Arcanedev\LaravelTracker\Models\Route $route */ $route = $routes->first(); - $this->assertSame('public::contact.get', $route->name); - $this->assertSame('Closure', $route->action); + static::assertSame('public::contact.get', $route->name); + static::assertSame('Closure', $route->action); } /** @test */ public function it_can_track_route_with_parameters() { - $this->route('GET', 'blog::post.show', [1]); + $this->get(route('blog::post.show', [1])); - $this->seeInDatabase('tracker_route_path_parameters', [ + $this->assertDatabaseHas('tracker_route_path_parameters', [ 'route_path_id' => 1, 'parameter' => 'post', 'value' => '1', diff --git a/tests/Trackers/TestCase.php b/tests/Trackers/TestCase.php index 446fe34..3b64569 100644 --- a/tests/Trackers/TestCase.php +++ b/tests/Trackers/TestCase.php @@ -1,6 +1,7 @@ assertInstanceOf($expected, $this->tracker); + static::assertInstanceOf($expected, $this->tracker); } } /** @test */ public function it_can_track() { - $this->assertSame(1, $this->tracker->track()); + static::assertSame(1, $this->tracker->track()); // TODO: Add database assertions } @@ -72,7 +72,7 @@ public function it_can_get_parser() ]; foreach ($expectations as $expected) { - $this->assertInstanceOf($expected, $parser); + static::assertInstanceOf($expected, $parser); } } } diff --git a/tests/Trackers/UserTrackerTest.php b/tests/Trackers/UserTrackerTest.php index 88a66ba..6995100 100644 --- a/tests/Trackers/UserTrackerTest.php +++ b/tests/Trackers/UserTrackerTest.php @@ -49,7 +49,7 @@ public function it_can_be_instantiated() ]; foreach ($expectations as $expected) { - $this->assertInstanceOf($expected, $this->tracker); + static::assertInstanceOf($expected, $this->tracker); } } @@ -57,7 +57,7 @@ public function it_can_be_instantiated() public function it_can_track() { // No authenticated user - $this->assertSame(null, $this->tracker->track()); + static::assertSame(null, $this->tracker->track()); // TODO: Add an authenticated user // TODO: Add database assertions diff --git a/tests/Trackers/VisitorActivityTrackerTest.php b/tests/Trackers/VisitorActivityTrackerTest.php index 72ef7e1..ee19a31 100644 --- a/tests/Trackers/VisitorActivityTrackerTest.php +++ b/tests/Trackers/VisitorActivityTrackerTest.php @@ -49,7 +49,7 @@ public function it_can_be_instantiated() ]; foreach ($expectations as $expected) { - $this->assertInstanceOf($expected, $this->tracker); + static::assertInstanceOf($expected, $this->tracker); } } @@ -68,7 +68,7 @@ public function it_can_track() 'wants_json' => false, ]; - $this->assertSame(1, $this->tracker->track($activity)); + static::assertSame(1, $this->tracker->track($activity)); // TODO: add database assertions } diff --git a/tests/Trackers/VisitorTrackerTest.php b/tests/Trackers/VisitorTrackerTest.php index f835562..16ad8cd 100644 --- a/tests/Trackers/VisitorTrackerTest.php +++ b/tests/Trackers/VisitorTrackerTest.php @@ -49,7 +49,7 @@ public function it_can_be_instantiated() ]; foreach ($expectations as $expected) { - $this->assertInstanceOf($expected, $this->tracker); + static::assertInstanceOf($expected, $this->tracker); } } @@ -58,7 +58,7 @@ public function it_can_track() { $data = $this->getVisitorData(); - $this->assertSame(1, $this->tracker->track($data)); + static::assertSame(1, $this->tracker->track($data)); // TODO: Add database assertions }