PHP Classes

File: tests/Unit/Gtid/GtidTest.php

Recommend this page to a friend!
  Classes of Kacper Rowinski   PHP MySQL Replication   tests/Unit/Gtid/GtidTest.php   Download  
File: tests/Unit/Gtid/GtidTest.php
Role: Unit test script
Content type: text/plain
Description: Unit test script
Class: PHP MySQL Replication
Client to get MySQL replication events in pure PHP
Author: By
Last change: New release (#104)

* - Change: drop support for < 8.2
- Change: moved to enums, promoted properties
- Added: logger for more socket info
- Added: slave_uuid support
- Change: config no longer static
- Chore: typos in README/code
- Chore: replace/remove old urls from code
- Chore: changed variables to underscore
- Added: support caching_sha2_password
- Change: BinLogServerInfo static calls removed also added method getServerInfo to MySQLReplicationFactory
Date: 2 days ago
Size: 1,386 bytes
 

 

Contents

Class file image Download
<?php

/** @noinspection PhpUnhandledExceptionInspection */

declare(strict_types=1);

namespace
MySQLReplication\Tests\Unit\Gtid;

use
MySQLReplication\Gtid\Gtid;
use
MySQLReplication\Gtid\GtidException;
use
PHPUnit\Framework\TestCase;

class
GtidTest extends TestCase
{
    public function
testShouldGetEncoded(): void
   
{
       
self::assertSame(
           
'9b1c8d182a7611e5a26b000c2976f3f301000000000000000100000000000000b8b5020000000000',
           
bin2hex($this->getGtid('9b1c8d18-2a76-11e5-a26b-000c2976f3f3:1-177592')->getEncoded())
        );
       
self::assertSame(
           
'9b1c8d182a7611e5a26b000c2976f3f3010000000000000001000000000000000200000000000000',
           
bin2hex($this->getGtid('9b1c8d18-2a76-11e5-a26b-000c2976f3f3:1')->getEncoded())
        );
    }

    public function
testShouldGetEncodedLength(): void
   
{
       
self::assertSame(40, $this->getGtid('9b1c8d18-2a76-11e5-a26b-000c2976f3f3:1-177592')->getEncodedLength());
    }

    public function
testShouldThrowErrorOnIncrrectGtid(): void
   
{
       
$this->expectException(GtidException::class);
       
$this->expectExceptionMessage(GtidException::INCORRECT_GTID_MESSAGE);
       
$this->expectExceptionCode(GtidException::INCORRECT_GTID_CODE);

       
$this->getGtid('not gtid');
    }

    private function
getGtid(string $data): Gtid
   
{
        return new
Gtid($data);
    }
}