From c7714e63c76c2c720f84edf380e9fbdec5074fcc Mon Sep 17 00:00:00 2001 From: Akki Khare Date: Sat, 20 May 2023 11:01:20 -0400 Subject: [PATCH] chore: tests for real-time report and php 8.2 test --- .github/workflows/test.yml | 18 +++++++++--------- docker-compose-test.yml | 12 +++++++----- src/Facades/LaravelGoogleAnalytics.php | 2 ++ tests/LaravelGoogleAnalyticsTest.php | 13 ++++++++++++- 4 files changed, 30 insertions(+), 15 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 446e2db..1d2a12d 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -7,7 +7,7 @@ on: branches: [ master ] jobs: - test-php-74: + test-php-80: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 @@ -18,10 +18,10 @@ jobs: - name: Start the test docker containers run: docker-compose -f docker-compose-test.yml up -d - name: Install composer dependencies - run: docker-compose -f docker-compose-test.yml exec -T php_74 composer install + run: docker-compose -f docker-compose-test.yml exec -T php_80 composer install - name: Run PHPUnit Tests - run: docker-compose -f docker-compose-test.yml exec -T php_74 composer test - test-php-80: + run: docker-compose -f docker-compose-test.yml exec -T php_80 composer test + test-php-81: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 @@ -32,10 +32,10 @@ jobs: - name: Start the test docker containers run: docker-compose -f docker-compose-test.yml up -d - name: Install composer dependencies - run: docker-compose -f docker-compose-test.yml exec -T php_80 composer install + run: docker-compose -f docker-compose-test.yml exec -T php_81 composer install - name: Run PHPUnit Tests - run: docker-compose -f docker-compose-test.yml exec -T php_80 composer test - test-php-81: + run: docker-compose -f docker-compose-test.yml exec -T php_81 composer test + test-php-82: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 @@ -46,6 +46,6 @@ jobs: - name: Start the test docker containers run: docker-compose -f docker-compose-test.yml up -d - name: Install composer dependencies - run: docker-compose -f docker-compose-test.yml exec -T php_81 composer install + run: docker-compose -f docker-compose-test.yml exec -T php_82 composer install - name: Run PHPUnit Tests - run: docker-compose -f docker-compose-test.yml exec -T php_81 composer test + run: docker-compose -f docker-compose-test.yml exec -T php_82 composer test diff --git a/docker-compose-test.yml b/docker-compose-test.yml index 4a5aab9..a42df8d 100644 --- a/docker-compose-test.yml +++ b/docker-compose-test.yml @@ -1,18 +1,20 @@ version: '2.1' services: - php_74: - image: akkica/laravel-base:7.4 - volumes: - - .:/var/www/html - - /var/www/html/vendor php_80: image: akkica/laravel-base:8.0 volumes: - .:/var/www/html - /var/www/html/vendor + php_81: image: akkica/laravel-base:8.1 volumes: - .:/var/www/html - /var/www/html/vendor + + php_82: + image: akkica/laravel-base:8.1 + volumes: + - .:/var/www/html + - /var/www/html/vendor diff --git a/src/Facades/LaravelGoogleAnalytics.php b/src/Facades/LaravelGoogleAnalytics.php index 31e1d29..40ce32e 100644 --- a/src/Facades/LaravelGoogleAnalytics.php +++ b/src/Facades/LaravelGoogleAnalytics.php @@ -11,8 +11,10 @@ * @method static getCredentials() * @method static \Google\Analytics\Data\V1beta\BetaAnalyticsDataClient getClient() * @method static \AkkiIo\LaravelGoogleAnalytics\LaravelGoogleAnalyticsResponse get() + * @method static \AkkiIo\LaravelGoogleAnalytics\LaravelGoogleAnalyticsResponse getRealTimeReport() * @method static self dateRange(\AkkiIo\LaravelGoogleAnalytics\Period $period) * @method static self dateRanges(\AkkiIo\LaravelGoogleAnalytics\Period ...$items) + * @method static self minuteRange(int $start, int $end = 0) * @method static self metric(string $name) * @method static self metrics(string ...$items) * @method static self dimension(string $name) diff --git a/tests/LaravelGoogleAnalyticsTest.php b/tests/LaravelGoogleAnalyticsTest.php index b927cdc..3c89e13 100644 --- a/tests/LaravelGoogleAnalyticsTest.php +++ b/tests/LaravelGoogleAnalyticsTest.php @@ -33,6 +33,18 @@ protected function setUp(): void ->metricAggregation(MetricAggregation::TOTAL); } + /** @test */ + public function it_should_get_real_time_report() + { + $result = LaravelGoogleAnalytics::metrics('activeUsers') + ->minuteRange(1) + ->dimension('city') + ->getRealTimeReport(); + + + $this->assertCount(0, $result->table); + } + /** @test */ public function it_should_return_correct_count() { @@ -127,7 +139,6 @@ public function it_should_filter_dimension_with_and_group_receiving_an_filter_ob $result = $this->analytics ->whereAndGroupDimensions([ $browserFilter, - //Not sure which other metric is available, but can be something like ['country', MatchType::CONTAINS, 'India'] ]) ->get();