PHP Classes

File: tests/StackTest.php

Recommend this page to a friend!
  Classes of Italo Lelis de Vietro   Collections PHP Library   tests/StackTest.php   Download  
File: tests/StackTest.php
Role: Unit test script
Content type: text/plain
Description: Unit test script
Class: Collections PHP Library
Manipulate collections of values
Author: By
Last change:
Date: 9 years ago
Size: 1,589 bytes
 

Contents

Class file image Download
<?php

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
namespace Tests\Collections;

use
Collections\Stack;
use
RuntimeException;

/**
 * @author italo
 */
class StackTest extends CollectionsTestCase
{
   
/**
     * @var Stack
     */
   
private $coll;

    protected function
setUp()
    {
       
$this->coll = new Stack();
    }

    public function
testNewInstance()
    {
       
$this->assertNotNull($this->coll);
    }

    public function
testEnqueueItem()
    {
       
$this->coll->push('testing');
       
$this->assertTrue(is_string((string)$this->coll));
    }

    public function
testEnqueueMultiple()
    {
       
$this->coll->pushMultiple(array(1, 2, 3, 4));
       
$this->assertTrue(is_string((string)$this->coll));
    }

   
/**
     * @expectedException RuntimeException
     */
   
public function testDequeueEmptyQueue()
    {
       
$this->coll->pop();
    }

    public function
testEnqueueToArray()
    {
       
$this->coll->push('testing1');
       
$this->coll->push('testing2');
       
$this->coll->push('testing3');

       
$this->assertEquals(array('testing1', 'testing2', 'testing3'), $this->coll->toArray());
    }

    public function
testEnqueueAndDequeueToArray()
    {
       
$this->coll->push('testing1');
       
$this->coll->push('testing2');
       
$this->coll->push('testing3');

       
$this->coll->pop();

       
$this->assertEquals(array('testing1', 'testing2'), $this->coll->toArray());
    }
}