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: test fixes
Date: 8 months ago
Size: 1,446 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
MySQLReplication\Tests\Unit\BaseTest;

class
GtidTest extends BaseTest
{
   
/**
     * @test
     */
   
public function shouldGetEncoded(): 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()));
    }

   
/**
     * @throws GtidException
     */
   
private function getGtid(string $data): Gtid
   
{
        return new
Gtid($data);
    }

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

   
/**
     * @test
     */
   
public function shouldThrowErrorOnIncrrectGtid(): void
   
{
       
$this->expectException(GtidException::class);
       
$this->expectExceptionMessage(GtidException::INCORRECT_GTID_MESSAGE);
       
$this->expectExceptionCode(GtidException::INCORRECT_GTID_CODE);

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

For more information send a message to info at phpclasses dot org.