<commit_before><?php

require_once dirname(dirname(dirname(dirname(__DIR__)))). '/include/GoogleSync/GoogleSync.php';

class GoogleSyncTest extends \SuiteCRM\StateCheckerUnitAbstract
{
    /** @var UnitTester */
    protected $tester;

    /** @var ReflectionClass */
    protected static $relection;

    /** @var ReflectionProperty */
    protected static $dbProperty;

    public function _before()
    {
        parent::_before();

        // Use reflection to access private properties and methods
        if (self::$relection === null) {
            self::$relection = new ReflectionClass(GoogleSync::class);
            self::$dbProperty = self::$relection->getProperty('db');
            self::$dbProperty->setAccessible(true);
        }
    }

    public function test__construct()
    {

        // Set up object for testing
        global $sugar_config;
        // base64 encoded of {"web":"test"}
        $sugar_config['google_auth_json'] = '<KEY>';

        $object = new GoogleSync();

        // Test GoogleSync::timezone
        $this->assertNotEmpty($object->timezone);
        $this->assertEquals("string", gettype($object->timezone));

        // Test GoogleSync::authJson
        $this->assertNotEmpty($object->authJson);
        $this->assertEquals("array", gettype($object->authJson));

        // Test GoogleSync::db
        $expectedClass = DBManager::class;
        $actualClass = self::$dbProperty->getValue($object);
        $this->assertInstanceOf($expectedClass, $actualClass);

        // Test setting log level
        $_SERVER['GSYNC_LOGLEVEL'] = 'debug';
        $object = new GoogleSync();
        $expectedLogLevel = 'debug';
        $actualLogLevel = LoggerManager::getLogLevel();
        $this->assertEquals($expectedLogLevel, $actualLogLevel);
    }

    public function testGetGoogleEventById()
    {
        $this->markTestIncomplete('TODO: Implement Tests');
    }

    public function testGetClient()
    {
        $this->markTestIncomplete('TODO: Implement Tests');
    }

    public function testGetAuthJson()
    {
    
        // Set up object for testing
        global $sugar_config;

        // base64 encoded of {"web":"test"}
        $sugar_config['google_auth_json'] = '<KEY>';

        $object = new GoogleSync();

        $expectedAuthJson = json_decode(base64_decode('<KEY>'), true);
        $actualAuthJson = $object->getAuthJson();

        $this->assertEquals($expectedAuthJson, $actualAuthJson);
        $this->assertArrayHasKey('web', $actualAuthJson);
    }

    public function testAddUser()
    {

        $object = new GoogleSync();
        $return = $object->addUser('ABC123', 'End User');

        $this->assertTrue($return);
        $this->assertArrayHasKey('ABC123', $object->users);

    }

    public function testPullEvent()
    {
        $this->markTestIncomplete('TODO: Implement Tests');
    }

    public function testSetGService()
    {
        $this->markTestIncomplete('TODO: Implement Tests');
    }

    public function testGetUserMeetings()
    {
        $this->markTestIncomplete('TODO: Implement Tests');
    }

    public function testGetUserGoogleEvents()
    {
        $this->markTestIncomplete('TODO: Implement Tests');
    }

    public function testGetGoogleEventByMeetingId()
    {
        $this->markTestIncomplete('TODO: Implement Tests');
    }

    public function testCreateSuitecrmMeetingEvent()
    {

        $state = new \SuiteCRM\StateSaver();
        $state->pushTable('reminders');
        $state->pushTable('reminders_invitees');
<commit_msg>Add test for getUserMeetings method<commit_after><?php

require_once dirname(dirname(dirname(dirname(__DIR__)))). '/include/GoogleSync/GoogleSync.php';

class GoogleSyncTest extends \SuiteCRM\StateCheckerUnitAbstract
{
    /** @var UnitTester */
    protected $tester;

    /** @var ReflectionClass */
    protected static $relection;

    /** @var ReflectionProperty */
    protected static $dbProperty;

    public function _before()
    {
        parent::_before();

        // Use reflection to access private properties and methods
        if (self::$relection === null) {
            self::$relection = new ReflectionClass(GoogleSync::class);
            self::$dbProperty = self::$relection->getProperty('db');
            self::$dbProperty->setAccessible(true);
        }
    }

    public function test__construct()
    {

        // Set up object for testing
        global $sugar_config;
        // base64 encoded of {"web":"test"}
        $sugar_config['google_auth_json'] = '<KEY>';

        $object = new GoogleSync();

        // Test GoogleSync::timezone
        $this->assertNotEmpty($object->timezone);
        $this->assertEquals("string", gettype($object->timezone));

        // Test GoogleSync::authJson
        $this->assertNotEmpty($object->authJson);
        $this->assertEquals("array", gettype($object->authJson));

        // Test GoogleSync::db
        $expectedClass = DBManager::class;
        $actualClass = self::$dbProperty->getValue($object);
        $this->assertInstanceOf($expectedClass, $actualClass);

        // Test setting log level
        $_SERVER['GSYNC_LOGLEVEL'] = 'debug';
        $object = new GoogleSync();
        $expectedLogLevel = 'debug';
        $actualLogLevel = LoggerManager::getLogLevel();
        $this->assertEquals($expectedLogLevel, $actualLogLevel);
    }

    public function testGetGoogleEventById()
    {
        $this->markTestIncomplete('TODO: Implement Tests');
    }

    public function testGetClient()
    {
        $this->markTestIncomplete('TODO: Implement Tests');
    }

    public function testGetAuthJson()
    {
    
        // Set up object for testing
        global $sugar_config;

        // base64 encoded of {"web":"test"}
        $sugar_config['google_auth_json'] = '<KEY>';

        $object = new GoogleSync();

        $expectedAuthJson = json_decode(base64_decode('<KEY>'), true);
        $actualAuthJson = $object->getAuthJson();

        $this->assertEquals($expectedAuthJson, $actualAuthJson);
        $this->assertArrayHasKey('web', $actualAuthJson);
    }

    public function testAddUser()
    {

        $object = new GoogleSync();
        $return = $object->addUser('ABC123', 'End User');

        $this->assertTrue($return);
        $this->assertArrayHasKey('ABC123', $object->users);

    }

    public function testPullEvent()
    {
        $this->markTestIncomplete('TODO: Implement Tests');
    }

    public function testSetGService()
    {
        $this->markTestIncomplete('TODO: Implement Tests');
    }

    public function testGetUserMeetings()
    {
        $state = new \SuiteCRM\StateSaver();
        $state->pushTable('meetings');

        $object = new GoogleSync();
        $object->workingUser = BeanFactory::getBean('Users');
        $object->workingUser->retrieve('seed_sarah_id');

        $return = $object->getUserMeetings($object->workingUser->id);

        $this->assertEquals(14, count($return));

        $state->popTable('meetings');
    }

    public function testGetUserGoogleEvents()
    {
        $this->markTestIncomplete('TODO: Implement Tests');
    }

    public function testGetGoogleEventByMeetingId()
    {
        $this->markTestIncomplete('TODO: Implement Tests');
    }

    public function testCreateSuitecrmMeetingEvent()
    {

        $state = new \SuiteCRM\StateSaver();
        $state->pushTable('reminders');
        $state->pushTable('reminders_invitees');

{'fraction_non_alphanumeric': 0.13808373590982287, 'fraction_numerical': 0.003488996242619431, 'mean_word_length': 2.831876606683805, 'pattern_counts': {'":': 4, '<': 11, '<?xml version=': 0, '>': 75, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2361030', 'n_tokens_mistral': 2114, 'n_tokens_neox': 2059, 'n_words': 388}