PHP Classes

File: tests/arrayForeachTest.php

Recommend this page to a friend!
  Classes of Rick Hambrook   Nest   tests/arrayForeachTest.php   Download  
File: tests/arrayForeachTest.php
Role: Unit test script
Content type: text/plain
Description: Unit test: array foreach
Class: Nest
Easily set and get values of nested arrays
Author: By
Last change: feat(meta): update namespaces and add composer file for composer/packagist support
Date: 9 years ago
Size: 835 bytes
 

Contents

Class file image Download
<?php

require_once(implode(DIRECTORY_SEPARATOR, [__DIR__, "..", "src", "Nest.php"]));

use \
Hambrook\Nest\Nest as Nest;

/**
 * Tests for PHPUnit
 *
 * @author Rick Hambrook <rick@rickhambrook.com>
 * @copyright 2015 Rick Hambrook
 * @license https://www.gnu.org/licenses/gpl.txt GNU General Public License v3
 */
class arrayForeachTest extends PHPUnit_Framework_TestCase {

    public function
testForeachIndexed() {
       
$array = [
           
"one" => "a",
           
"two" => "b",
           
"three" => "c",
        ];

       
$Nest = new Nest($array);
       
$tmp = "";
        foreach (
$Nest as $t) {
           
$tmp .= $t;
        }
       
$this->assertEquals("abc", $tmp);
    }

    public function
testForeachKeyed() {
       
$array = [
           
"a",
           
"b",
           
"c",
        ];

       
$Nest = new Nest($array);
       
$tmp = "";
        foreach (
$Nest as $t) {
           
$tmp .= $t;
        }
       
$this->assertEquals("abc", $tmp);
    }

}