PHP Classes

File: tests/StructArrayTest.php

Recommend this page to a friend!
  Classes of WsdlToPhp   Package Base   tests/StructArrayTest.php   Download  
File: tests/StructArrayTest.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: Add Sonar tools, minor improvements

Date: 1 year ago
Size: 4,326 bytes
 

Contents

Class file image Download
<?php

declare(strict_types=1);

namespace
WsdlToPhp\PackageBase\Tests;

class
StructArrayTest extends TestCase
{
    public function
testSetState(): void
   
{
       
$object = new StructArrayObject();
       
$object
           
->setFoo([
               
'1',
               
2,
               
'3',
            ]);

       
$this->assertEquals($object, StructArrayObject::__set_state([
           
'foo' => [
               
'1',
               
2,
               
'3',
            ],
        ]));
    }

    public function
testGetAttributeName(): void
   
{
       
$object = new StructArrayObject();

       
$this->assertSame('foo', $object->getAttributeName());
    }

    public function
testLength(): void
   
{
       
$object = new StructArrayObject();
       
$object
           
->setFoo([
               
'1',
               
2,
               
'3',
            ]);

       
$this->assertSame(3, $object->length());
    }

    public function
testAdd(): void
   
{
       
$object = new StructArrayObject();
       
$object
           
->setFoo([
               
'1',
               
2,
               
'3',
            ])
            ->
add(4);

       
$this->assertSame('1', $object->current());
    }

    public function
testAddOnEmpty(): void
   
{
       
$object = new StructArrayObject();
       
$object
           
->add(4)
            ->
add(5)
            ->
add(6);

       
$this->assertSame(4, $object->current());
    }

    public function
testFirst(): void
   
{
       
$object = new StructArrayObject();
       
$object
           
->setFoo([
               
'1',
               
2,
               
'3',
            ])
            ->
add(4);

       
$this->assertSame('1', $object->first());
    }

    public function
testLast(): void
   
{
       
$object = new StructArrayObject();
       
$object
           
->setFoo([
               
'1',
               
2,
               
'3',
            ])
            ->
add(4);

       
$this->assertSame(4, $object->last());
    }

    public function
testOffsetExists(): void
   
{
       
$object = new StructArrayObject();
       
$object
           
->setFoo([
               
'1',
               
2,
               
'3',
            ])
            ->
add(4);

       
$this->assertTrue($object->offsetExists(3));
    }

    public function
testOffsetNotExists(): void
   
{
       
$object = new StructArrayObject();
       
$object
           
->setFoo([
               
'1',
               
2,
               
'3',
            ])
            ->
add(4);

       
$this->assertFalse($object->offsetExists(4));
    }

    public function
testOffsetGet(): void
   
{
       
$object = new StructArrayObject();
       
$object
           
->setFoo([
               
'1',
               
2,
               
'3',
            ])
            ->
add(4);

       
$this->assertSame(4, $object->offsetGet(3));
    }

    public function
testOffsetGetNull(): void
   
{
       
$object = new StructArrayObject();
       
$object
           
->setFoo([
               
'1',
               
2,
               
'3',
            ])
            ->
add(4);

       
$this->assertNull($object->offsetGet(4));
    }

    public function
testOffsetSet(): void
   
{
       
$object = new StructArrayObject();
       
$object
           
->setFoo([
               
'1',
               
2,
               
'3',
            ])
            ->
offsetSet(2, 4);

       
$this->assertSame(4, $object->offsetGet(2));
    }

    public function
testOffsetUnset(): void
   
{
       
$object = new StructArrayObject();
       
$object
           
->setFoo([
               
'1',
               
2,
               
'3',
            ])
            ->
offsetUnset(2);

       
$this->assertFalse($object->offsetExists(2));
    }

    public function
testIteratorMethods(): void
   
{
       
$object = new StructArrayObject();
       
$object
           
->setFoo($items = [
               
'1',
               
2,
               
'3',
            ])
            ->
offsetUnset(2);

        foreach (
$object as $index => $item) {
           
$this->assertSame($items[$index], $item);
        }
    }

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