File: tests/QueueTest.php

Recommend this page to a friend!
  Classes of Italo Lelis de Vietro  >  Collections PHP Library  >  tests/QueueTest.php  >  Download  
File: tests/QueueTest.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: 6 years ago
Size: 1,623 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\Queue;
use
RuntimeException;

/**
 * @author italo
 */
class QueueTest extends CollectionsTestCase
{
   
/**
     * @var Queue
     */
   
private $coll;

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

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

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

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

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

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

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

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

       
$this->coll->dequeue();

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

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