tests/PrintKeyValueTest.php
/**
     * tests that after any given array structure the expected output is correct
     */
tests that after any given array structure the expected output is correct
tests that after any given array structure the expected output is correct
public function testIsStructureCorrect()
    {
        $kvp = new PrintKeyValue();
        $a1 = [1];
        $ex = "0:1\n";
        $kvp->clear();
        $res1 = $kvp->printKeyValues($a1);
        $this->assertContains($ex, $res1);
        $a2 = [1, 2];
        $ex2 = "0:1\n1:2\n";
        $kvp->clear();
        $res2 = $kvp->printKeyValues($a2);
        $this->assertContains($ex2, $res2);
        $a3 = [1, [2]];
        $ex3 = "0:1\n1:{\n 0:2\n}\n";
        $kvp->clear();
        $res3 = $kvp->printKeyValues($a3);
        $this->assertContains($ex3, $res3);
        $a4 = [1, 2, [3, [4]]];
        $ex4 = "0:1\n1:2\n2:{\n 0:3\n 1:{\n  0:4\n }\n}\n";
        $kvp->clear();
        $res4 = $kvp->printKeyValues($a4);
        $this->assertContains($ex4, $res4);
        $a5 = [
            "key" => "value",
            5,
            [
                "another" => "keyvalue",
                [
                    5,
                    [
                        "yes" => "no"
                    ]
                ]
            ]
        ];
        $ex5 = "key:value\n0:5\n1:{\n another:keyvalue\n 0:{\n  0:5\n  1:{\n   yes:no\n  }\n }\n}\n";
        $kvp->clear();
        $res5 = $kvp->printKeyValues($a5);
        $this->assertContains($ex5, $res5);
    }
public function testIsStructureCorrect ( ) { $ kvp = new PrintKeyValue ( ) ; $ a1 = [ 1 ] ; $ ex = " 0:1 \n " ; $ kvp -> clear ( ) ; $ res1 = $ kvp -> printKeyValues ( $ a1 ) ; $ this -> assertContains ( $ ex , $ res1 ) ; $ a2 = [ 1 , 2 ] ; $ ex2 = " 0:1 \n 1:2 \n " ; $ kvp -> clear ( ) ; $ res2 = $ kvp -> printKeyValues ( $ a2 ) ; $ this -> assertContains ( $ ex2 , $ res2 ) ; $ a3 = [ 1 , [ 2 ] ] ; $ ex3 = " 0:1 \n 1:{ \n  0:2 \n } \n " ; $ kvp -> clear ( ) ; $ res3 = $ kvp -> printKeyValues ( $ a3 ) ; $ this -> assertContains ( $ ex3 , $ res3 ) ; $ a4 = [ 1 , 2 , [ 3 , [ 4 ] ] ] ; $ ex4 = " 0:1 \n 1:2 \n 2:{ \n  0:3 \n  1:{ \n   0:4 \n  } \n } \n " ; $ kvp -> clear ( ) ; $ res4 = $ kvp -> printKeyValues ( $ a4 ) ; $ this -> assertContains ( $ ex4 , $ res4 ) ; $ a5 = [ " key " => " value " , 5 , [ " another " => " keyvalue " , [ 5 , [ " yes " => " no " ] ] ] ] ; $ ex5 = " key:value \n 0:5 \n 1:{ \n  another:keyvalue \n  0:{ \n   0:5 \n   1:{ \n    yes:no \n   } \n  } \n } \n " ; $ kvp -> clear ( ) ; $ res5 = $ kvp -> printKeyValues ( $ a5 ) ; $ this -> assertContains ( $ ex5 , $ res5 ) ; }
tests that after any given array structure the expected output is correct
tests that after any given array structure the expected output is correct
//test 1 //test 2 //test 3 //test 4 //test5