PHP Classes

File: tests/Unit/Gtid/GtidCollectionTest.php

Recommend this page to a friend!
  Classes of Kacper Rowinski   PHP MySQL Replication   tests/Unit/Gtid/GtidCollectionTest.php   Download  
File: tests/Unit/Gtid/GtidCollectionTest.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
Support doctrine/dbal ^3.0 (#75)

* Upgrade doctrine/dbal to ^3.0

* Update composer.json

* Added test cases for PHP 7.3 and 7.4

* Use Exception instead of the removed DBALException

* Doctrine\DBAL\Exception is avaliable in v2.11

* Fixed the removed methods

* Don't support php7.1 and 7.2

* Fixed `ping()` does not works.

* Fixed PHPUnit.

* Added sort-packages
Date: 3 years ago
Size: 1,447 bytes
 

Contents

Class file image Download
<?php

declare(strict_types=1);

namespace
MySQLReplication\Tests\Unit\Gtid;

use
MySQLReplication\Gtid\Gtid;
use
MySQLReplication\Gtid\GtidCollection;
use
MySQLReplication\Gtid\GtidException;
use
MySQLReplication\Tests\Unit\BaseTest;

class
GtidCollectionTest extends BaseTest
{
   
/**
     * @var GtidCollection
     */
   
private $gtidCollection;

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

       
$this->gtidCollection = new GtidCollection();

       
$this->gtidCollection->add(new Gtid('9b1c8d18-2a76-11e5-a26b-000c2976f3f3:1-177592'));
       
$this->gtidCollection->add(new Gtid('BBBBBBBB-CCCC-FFFF-DDDD-AAAAAAAAAAAA:1'));
    }

   
/**
     * @test
     */
   
public function shouldGetEncodedLength(): void
   
{
       
self::assertSame(88, $this->gtidCollection->getEncodedLength());
    }

   
/**
     * @test
     */
   
public function shouldGetEncoded(): void
   
{
       
self::assertSame(
           
'02000000000000009b1c8d182a7611e5a26b000c2976f3f301000000000000000100000000000000b8b5020000000000bbbbbbbbccccffffddddaaaaaaaaaaaa010000000000000001000000000000000200000000000000',
           
bin2hex($this->gtidCollection->getEncoded())
        );
    }

   
/**
     * @test
     * @throws GtidException
     */
   
public function shouldCreateCollection(): void
   
{
       
self::assertCount(1, GtidCollection::makeCollectionFromString('9b1c8d18-2a76-11e5-a26b-000c2976f3f3:1-177592'));
    }
}