PHP Classes

File: Tests/GDM/Framework/Types/ArrayWrapperTest.php

Recommend this page to a friend!
  Classes of Corey Sewell   GDM Types   Tests/GDM/Framework/Types/ArrayWrapperTest.php   Download  
File: Tests/GDM/Framework/Types/ArrayWrapperTest.php
Role: Unit test script
Content type: text/plain
Description: Auxiliary script
Class: GDM Types
Manipulate scalar data types as objects
Author: By
Last change: Update of Tests/GDM/Framework/Types/ArrayWrapperTest.php
Date: 3 months ago
Size: 5,741 bytes
 

Contents

Class file image Download
<?php

namespace GDM\Framework\Types;

/**
 * Generated by PHPUnit_SkeletonGenerator on 2014-07-04 at 20:48:22.
 */
class ArrayWrapperTest extends \PHPUnit_Framework_TestCase
{
   
/**
     * @var ArrayWrapper
     */
   
protected $object;

   
/**
     * Sets up the fixture, for example, opens a network connection.
     * This method is called before a test is executed.
     */
   
protected function setUp()
    {
       
$this->object = new ArrayWrapper;
    }

   
/**
     * Tears down the fixture, for example, closes a network connection.
     * This method is called after a test is executed.
     */
   
protected function tearDown()
    {
       
    }

   
/**
     * @covers GDM\Framework\Types\ArrayWrapper::trim
     */
   
public function testTrim()
    {
       
$array = [' 1foo ', ' 2bar ', ' 3foo ', ' 4bar '];
       
$arrayObject = \GDM\Framework\Types\ArrayWrapper::create($array);
       
$arrayObject->trim();
        foreach (
$arrayObject as $i => $value) {
           
$this->assertEquals(trim($array[$i]), $value);
        }
    }

   
/**
     * @covers GDM\Framework\Types\ArrayWrapper::get
     */
   
public function testGet()
    {
       
$array = [' 1foo ', ' 2bar ', ' 3foo ', ' 4bar '];
       
$arrayObj = \GDM\Framework\Types\ArrayWrapper::create($array);
       
$this->assertEquals($array, $arrayObj->get());
    }

   
/**
     * @covers GDM\Framework\Types\ArrayWrapper::fromObject
     */
   
public function testFromObject()
    {
       
$obj = new \stdClass();
       
$arrayObj = \GDM\Framework\Types\ArrayWrapper::create()->fromObject($obj);
       
$this->assertEquals([$obj], $arrayObj->get());
    }

   
/**
     * @covers GDM\Framework\Types\ArrayWrapper::fromBool
     */
   
public function testFromBool()
    {
       
$bool = false;
       
$arrayObj = \GDM\Framework\Types\ArrayWrapper::create()->fromObject($bool);
       
$this->assertEquals([$bool], $arrayObj->get());
    }

   
/**
     * @covers GDM\Framework\Types\ArrayWrapper::fromInt
     */
   
public function testFromInt()
    {
       
$int = 69;
       
$arrayObj = \GDM\Framework\Types\ArrayWrapper::create()->fromObject($int);
       
$this->assertEquals([$int], $arrayObj->get());
    }

   
/**
     * @covers GDM\Framework\Types\ArrayWrapper::fromDouble
     */
   
public function testFromDouble()
    {
       
$float = 6.9;
       
$arrayObj = \GDM\Framework\Types\ArrayWrapper::create()->fromObject($float);
       
$this->assertEquals([$float], $arrayObj->get());
    }

   
/**
     * @covers GDM\Framework\Types\ArrayWrapper::fromString
     */
   
public function testFromString()
    {
       
$string = "foo bar";
       
$arrayObj = \GDM\Framework\Types\ArrayWrapper::create()->fromObject($string);
       
$this->assertEquals([$string], $arrayObj->get());
    }

   
/**
     * @covers GDM\Framework\Types\ArrayWrapper::fromArray
     * @todo Implement testFromArray().
     */
   
public function testFromArray()
    {
       
$array = [' 1foo ', ' 2bar ', ' 3foo ', ' 4bar '];
       
$arrayObj = \GDM\Framework\Types\ArrayWrapper::create($array);
       
$this->assertEquals($array, $arrayObj->get());
    }

   
/**
     * @covers GDM\Framework\Types\ArrayWrapper::offsetSet
     * @todo Implement testOffsetSet().
     */
   
public function testOffsetSet()
    {
       
$array = ['foo', 'bar'];
       
$arrayObj = \GDM\Framework\Types\ArrayWrapper::create($array);
       
$this->assertEquals("bar", $arrayObj->offsetGet(1));
    }

   
/**
     * @covers GDM\Framework\Types\ArrayWrapper::offsetExists
     * @todo Implement testOffsetExists().
     */
   
public function testOffsetExists()
    {
       
$array = ['foo', 'bar'];
       
$arrayObj = \GDM\Framework\Types\ArrayWrapper::create($array);
       
$this->assertTrue($arrayObj->offsetExists(0));
       
$this->assertTrue($arrayObj->offsetExists(1));
       
$this->assertFalse($arrayObj->offsetExists(2));
    }

   
/**
     * @covers GDM\Framework\Types\ArrayWrapper::offsetUnset
     * @todo Implement testOffsetUnset().
     */
   
public function testOffsetUnset()
    {
       
$array = ['foo', 'bar'];
       
$arrayObj = \GDM\Framework\Types\ArrayWrapper::create($array);
       
$arrayObj->offsetUnset(0);
       
$this->assertEquals([1 => 'bar'], $arrayObj->get());
    }

   
/**
     * @covers GDM\Framework\Types\ArrayWrapper::offsetGet
     * @todo Implement testOffsetGet().
     */
   
public function testOffsetGet()
    {
       
$array = ['foo', 'bar'];
       
$arrayObj = \GDM\Framework\Types\ArrayWrapper::create($array);
       
$this->assertEquals('bar', $arrayObj->offsetGet(1));
    }

   
/**
     * @covers GDM\Framework\Types\ArrayWrapper::count
     * @todo Implement testCount().
     */
   
public function testCount()
    {
       
$array = ['foo', 'bar'];
       
$arrayObj = \GDM\Framework\Types\ArrayWrapper::create($array);
       
$this->assertEquals(2, count($arrayObj));
       
$this->assertEquals(2, $arrayObj->count());
    }

   
/**
     * @covers GDM\Framework\Types\ArrayWrapper::length
     * @todo Implement testLength().
     */
   
public function testLength()
    {
       
$array = ['foo', 'bar'];
       
$arrayObj = \GDM\Framework\Types\ArrayWrapper::create($array);
       
$this->assertEquals(2, $arrayObj->length());
    }

   
/**
     * @covers GDM\Framework\Types\ArrayWrapper::getIterator
     * @todo Implement testGetIterator().
     */
   
public function testGetIterator()
    {
       
$array = ['foo', 'bar'];
       
$arrayObj = \GDM\Framework\Types\ArrayWrapper::create($array);
       
$this->assertInstanceOf('\ArrayIterator', $arrayObj->getIterator());
    }
}