1<?php 2 3namespace Rubix\ML\Tests\Persisters\Serializers; 4 5use Rubix\ML\Encoding; 6use Rubix\ML\Persistable; 7use Rubix\ML\Classifiers\DummyClassifier; 8use Rubix\ML\Persisters\Serializers\Igbinary; 9use Rubix\ML\Persisters\Serializers\Serializer; 10use PHPUnit\Framework\TestCase; 11 12/** 13 * @group Serializers 14 * @requires extension igbinary 15 * @covers \Rubix\ML\Persisters\Serializers\Igbinary 16 */ 17class IgbinaryTest extends TestCase 18{ 19 /** 20 * @var \Rubix\ML\Persistable 21 */ 22 protected $persistable; 23 24 /** 25 * @var \Rubix\ML\Persisters\Serializers\Igbinary 26 */ 27 protected $serializer; 28 29 /** 30 * @before 31 */ 32 protected function setUp() : void 33 { 34 $this->persistable = new DummyClassifier(); 35 } 36 37 /** 38 * @test 39 */ 40 public function build() : void 41 { 42 $this->expectDeprecation(); 43 44 $this->serializer = new Igbinary(); 45 46 $this->assertInstanceOf(Igbinary::class, $this->serializer); 47 $this->assertInstanceOf(Serializer::class, $this->serializer); 48 } 49 50 /** 51 * @test 52 */ 53 public function serializeUnserialize() : void 54 { 55 $this->expectDeprecation(); 56 57 $this->serializer = new Igbinary(); 58 59 $data = $this->serializer->serialize($this->persistable); 60 61 $this->assertInstanceOf(Encoding::class, $data); 62 63 $persistable = $this->serializer->unserialize($data); 64 65 $this->assertInstanceOf(DummyClassifier::class, $persistable); 66 $this->assertInstanceOf(Persistable::class, $persistable); 67 } 68} 69