40 lines
		
	
	
		
			1.0 KiB
		
	
	
	
		
			PHP
		
	
	
	
	
	
			
		
		
	
	
			40 lines
		
	
	
		
			1.0 KiB
		
	
	
	
		
			PHP
		
	
	
	
	
	
| <?php
 | |
| namespace nur\b\coll;
 | |
| 
 | |
| use nur\t\TestCase;
 | |
| 
 | |
| class ArrayViewStackTest extends TestCase {
 | |
|   function testBasic() {
 | |
|     $first = ["a" => 1, "b"=> 1];
 | |
|     $second = ["b" => 2, "c" => 2];
 | |
|     $third = [];
 | |
|     $stack = new ArrayViewStack();
 | |
|     $stack->push($first)->push($second)->push($third);
 | |
| 
 | |
|     self::assertSame(null, $stack->get("d"));
 | |
|     self::assertSame(2, $stack->get("c"));
 | |
|     self::assertSame(2, $stack->get("b"));
 | |
|     self::assertSame(1, $stack->get("a"));
 | |
| 
 | |
|     $stack["a"] = "x";
 | |
|     $stack["b"] = "y";
 | |
|     $stack["c"] = "z";
 | |
|     $stack["d"] = "t";
 | |
| 
 | |
|     self::assertSame("t", $stack->get("d"));
 | |
|     self::assertSame("z", $stack->get("c"));
 | |
|     self::assertSame("y", $stack->get("b"));
 | |
|     self::assertSame("x", $stack->get("a"));
 | |
| 
 | |
|     unset($stack["a"]);
 | |
|     unset($stack["b"]);
 | |
|     unset($stack["c"]);
 | |
|     unset($stack["d"]);
 | |
| 
 | |
|     self::assertSame(null, $stack->get("d"));
 | |
|     self::assertSame(2, $stack->get("c"));
 | |
|     self::assertSame(2, $stack->get("b"));
 | |
|     self::assertSame(1, $stack->get("a"));
 | |
|   }
 | |
| }
 |