HEX
Server: nginx/1.28.1
System: Linux 10-41-63-61 6.8.0-31-generic #31-Ubuntu SMP PREEMPT_DYNAMIC Sat Apr 20 00:40:06 UTC 2024 x86_64
User: www (1001)
PHP: 7.4.33
Disabled: passthru,exec,system,putenv,chroot,chgrp,chown,shell_exec,popen,proc_open,pcntl_exec,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,imap_open,apache_setenv
Upload Files
File: /www/wwwroot/www.shooperm.com/tests/Browser/Modules/GeneralSetting/AnalyticsToolSetupTest.php
<?php

namespace Tests\Browser\Modules\GeneralSetting;

use Illuminate\Foundation\Testing\DatabaseMigrations;
use Laravel\Dusk\Browser;
use Tests\DuskTestCase;

class AnalyticsToolSetupTest extends DuskTestCase
{

    public function setUp(): void
    {
        parent::setUp();

        $path = base_path('.env');
        if (file_exists($path)) {
            $path = base_path('.env');

            if (file_exists($path)) {
                $a = "ANALYTICS_TRACKING_ID";
                $b = "ANATYTIC_RESULT_DASHBOARD";
                $c = "ANALYTICS_VIEW_ID";

                $a = '"'.trim($a).'"';
                $b = '"'.trim($b).'"';
                $c = '"'.trim($c).'"';

                file_put_contents($path, str_replace(
                    $a . '=' . env($a), $a . '=' . 'UA-199985068-1', file_get_contents($path)
                ));
                file_put_contents($path, str_replace(
                    $b . '=' . env($b), $b . '=' . '0', file_get_contents($path)
                ));
                file_put_contents($path, str_replace(
                    $c . '=' . env($c), $c . '=' . '245178355', file_get_contents($path)
                ));
            }
        }

        

    }

    public function tearDown(): void
    {

        parent::tearDown(); // TODO: Change the autogenerated stub
    }

    /**
     * A Dusk test example.
     *
     * @return void
     */
    public function test_for_visit_index_page()
    {
        $this->browse(function (Browser $browser) {
            $browser->loginAs(1)
                ->visit('/generalsetting/analytics')
                ->assertSee('Google Analytics');
        });
    }

    public function test_for_validate_check_goggle_analytics(){
        $this->test_for_visit_index_page();
        $this->browse(function (Browser $browser) {
            $browser->click('#google_analytics_form > div > div > div.col-xl-12 > div > ul > li:nth-child(1) > label > span')
                ->type('#tracking_id', '')
                ->click('#google_analytics_form > div > div > div:nth-child(6) > div > ul > li > label > span')
                ->pause(1000)
                ->type('#tracking_id', '')
                ->click('#google_submit_btn')
                ->assertPathIs('/generalsetting/analytics')
                ->assertSeeIn('#google_analytics_form > div > div > div:nth-child(4) > div > span', 'The a n a l y t i c s t r a c k i n g i d field is required.')
                ->assertSeeIn('#google_analytics_form > div > div > div.col-lg-12.analytics_view_div > div > span', 'The a n a l y t i c s v i e w i d field is required.');
        });
    }

    public function test_for_google_analytics_update(){
        $this->test_for_visit_index_page();
        $this->browse(function (Browser $browser) {
            $browser->click('#google_analytics_form > div > div > div.col-xl-12 > div > ul > li:nth-child(1) > label > span')
                ->type('#tracking_id', 'UA-199985068-1')
                ->click('#google_analytics_form > div > div > div:nth-child(6) > div > ul > li > label > span')
                ->pause(1000)
                ->type('#google_analytics_form > div > div > div.col-lg-12.analytics_view_div > div > input', '245178355')
                ->attach('#json', __DIR__.'/files/google_analytics.json')
                ->click('#google_submit_btn')
                ->assertPathIs('/generalsetting/analytics')
                ->waitFor('.toast-message',25)
                ->assertSeeIn('.toast-message', 'Updated successfully!');
        });
    }

    public function test_for_without_show_dashboard_update_google_analytics(){
        $this->test_for_visit_index_page();
        $this->browse(function (Browser $browser) {
            $browser->click('#google_analytics_form > div > div > div.col-xl-12 > div > ul > li:nth-child(1) > label > span')
                ->type('#tracking_id', 'UA-199985068-1')
                ->click('#google_submit_btn')
                ->assertPathIs('/generalsetting/analytics')
                ->waitFor('.toast-message',25)
                ->assertSeeIn('.toast-message', 'Updated successfully!');
        });
    }

    public function test_for_validate_facebook_pixel(){
        $this->test_for_visit_index_page();
        $this->browse(function (Browser $browser) {
            $browser->type('#facebook_pixel_id', '')
                ->click('#facebook_submit_btn')
                ->waitFor('.toast-message',25)
                ->assertSeeIn('.toast-message', 'Facebook Pixel ID Required');
        });
    }

    public function test_for_facebook_pixel_update(){
        $this->test_for_visit_index_page();
        $this->browse(function (Browser $browser) {
            $browser->click('#facebook_pixel_form > div > div > div.col-xl-6 > div > ul > li > label > span')
                ->type('#facebook_pixel_id', '24544178355')
                ->click('#facebook_submit_btn')
                ->waitFor('.toast-message',25)
                ->assertSeeIn('.toast-message', 'Updated successfully!');
        });
    }

}