File: tests/StructBaseTest.php

Recommend this page to a friend!
  Classes of WsdlToPhp  >  Package Base  >  tests/StructBaseTest.php  >  Download  
File: tests/StructBaseTest.php
Role: Unit test script
Content type: text/plain
Description: Unit test script
Class: Package Base
Base classes for implementing a package generator
Author: By
Last change: issue #32 - migrate to PHP >= 7.4
Date: 1 month ago
Size: 1,628 bytes
 

Contents

Class file image Download
<?php

declare(strict_types=1);

namespace
WsdlToPhp\PackageBase\Tests;

use
InvalidArgumentException;

class
StructBaseTest extends TestCase
{
    public function
testSetState()
    {
       
$object = new StructObject();
       
$object
           
->setBar('foo')
            ->
setFoo('bar');

       
$this->assertEquals($object, StructObject::__set_state([
           
'bar' => 'foo',
           
'foo' => 'bar',
        ]));
    }

    public function
testSetStateException()
    {
       
$this->expectException(InvalidArgumentException::class);

       
StructObject::__set_state([
           
'bar' => 'foo',
           
'foo' => 'bar',
           
'sample' => 'data',
        ]);
    }

    public function
testSetGet()
    {
       
$object = new StructObject();
       
$object
           
->setBar('foo')
            ->
setFoo('bar');
       
$this->assertSame('foo', $object->_get('bar'));
    }

    public function
testSetGetWithException()
    {
       
$this->expectException(InvalidArgumentException::class);

       
$object = new StructObject();
       
$object
           
->setBar('foo')
            ->
setFoo('bar');
       
$object->_get('sample');
    }

    public function
testJsonSerialize()
    {
       
$object = new StructObject();
       
$object
           
->setBar('foo')
            ->
setFoo('bar');
       
$this->assertSame([
           
'foo' => 'bar',
           
'bar' => 'foo',
        ],
$object->jsonSerialize());
    }

    public function
test__toStringMustReturnTheClassNameOfTheInstance()
    {
       
$this->assertSame(StructObject::class, (string) new StructObject());
    }
}


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