PHP Classes

File: tests/sortTest.php

Recommend this page to a friend!
  Classes of Rick Hambrook  >  Nest  >  tests/sortTest.php  >  Download  
File: tests/sortTest.php
Role: Unit test script
Content type: text/plain
Description: Unit test: sort
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: 6 years ago
Size: 2,246 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 sortTest extends PHPUnit_Framework_TestCase {

    private
$data = [
       
"foo" => "bar",
       
"one" => [
           
"z" => "zz",
            
3 => 33,
           
"a" => "aa",
            
1 => 11,
           
"B" => "BB",
            
2 => 22
       
]
    ];

    public function
testAsort() {
       
$Nest = new Nest($this->data);
       
$data = $this->data["one"];
       
asort($data);
       
$this->assertEquals($data, $Nest->sort("one", "a")->get("one"));
    }

    public function
testARsort() {
       
$Nest = new Nest($this->data);
       
$data = $this->data["one"];
       
arsort($data);
       
$this->assertEquals($data, $Nest->sort("one", "ar")->get("one"));
    }

    public function
testKsort() {
       
$Nest = new Nest($this->data);
       
$data = $this->data["one"];
       
ksort($data);
       
$this->assertEquals($data, $Nest->sort("one", "k")->get("one"));
    }

    public function
testKRsort() {
       
$Nest = new Nest($this->data);
       
$data = $this->data["one"];
       
krsort($data);
       
$this->assertEquals($data, $Nest->sort("one", "kr")->get("one"));
    }

    public function
testNatSort() {
       
$Nest = new Nest($this->data);
       
$data = $this->data["one"];
       
natsort($data);
       
$this->assertEquals($data, $Nest->sort("one", "nat")->get("one"));
    }

    public function
testNatCaseSort() {
       
$Nest = new Nest($this->data);
       
$data = $this->data["one"];
       
natcasesort($data);
       
$this->assertEquals($data, $Nest->sort("one", "natcase")->get("one"));
    }

   
/*
    public function testUASort() {
        $Nest = new Nest($this->data);
        $data = $this->data["one"];
        uasort($data);
        $this->assertEquals($data, $Nest->sort("one", "ua")->get("one"));
    }

    public function testUKSort() {
        $Nest = new Nest($this->data);
        $data = $this->data["one"];
        uksort($data);
        $this->assertEquals($data, $Nest->sort("one", "uk")->get("one"));
    }
    */

   
public function testFullNamesort() {
       
$Nest = new Nest($this->data);
       
$data = $this->data["one"];
       
asort($data);
       
$this->assertEquals($data, $Nest->sort("one", "asort")->get("one"));
    }

}

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