Пример #1
0
 public function testStructures()
 {
     $testList = array('hello', 5, 'foo');
     $testArray = array('a' => 'b', 'never' => 'over', 'loop' => 'infinite');
     $expectedList1 = '# hello' . PHP_EOL . '# 5' . PHP_EOL . '# foo' . PHP_EOL;
     $expectedList2 = '    - hello' . PHP_EOL . '    - 5' . PHP_EOL . '    - foo' . PHP_EOL;
     $this->string(Vivian\Tools::s_list1($testList))->isEqualTo($expectedList1)->string(Vivian\Tools::s_list2($testList))->isEqualTo($expectedList2);
     $expectedArray1 = '    a     => b' . PHP_EOL . '    never => over' . PHP_EOL . '    loop  => infinite' . PHP_EOL;
     $expectedArray2 = '+-------+----------+' . PHP_EOL;
     $expectedArray2 .= '| a     | b        |' . PHP_EOL;
     $expectedArray2 .= '| never | over     |' . PHP_EOL;
     $expectedArray2 .= '| loop  | infinite |' . PHP_EOL;
     $expectedArray2 .= '+-------+----------+' . PHP_EOL;
     $this->string(Vivian\Tools::s_phpArray($testArray))->isEqualTo($expectedArray1)->string(Vivian\Tools::s_array($testArray))->isEqualTo($expectedArray2);
 }
Пример #2
0
#!/usr/bin/env php
<?php 
$autoloadFile = __DIR__ . '/../../vendor/autoload.php';
require $autoloadFile;
use Matks\Vivian\Tools;
$list = array('a', 'b', 'c');
$array = array('a' => 'hello', 'second' => 3, 'over' => 'stronger');
echo Tools::s_list1($list);
echo Tools::s_list2($list);
echo PHP_EOL;
echo Tools::s_phpArray($array);
echo Tools::s_array($array);