func TestDecodeMultidimensionalArrayValue(t *testing.T) {
	decoder := NewPhpDecoder("arr3|a:1:{s:4:\"dim1\";a:5:{i:0;s:4:\"dim2\";i:1;i:0;i:2;i:3;i:3;i:5;i:4;a:2:{i:0;s:4:\"dim3\";i:1;i:5;}}}")
	if result, err := decoder.Decode(); err != nil {
		t.Errorf("Can not decode array value %#v \n", err)
	} else {
		if v, ok := (result)["arr3"]; !ok {
			t.Errorf("Array value was not decoded \n")
		} else if arrValue, ok := v.(php_serialize.PhpArray); ok != true {
			t.Errorf("Array value was decoded incorrectly: %#v \n", v)
		} else if dim1, ok := arrValue["dim1"]; !ok {
			t.Errorf("Second dimension of array was decoded incorrectly: %#v\n", dim1)
		} else if dim1Value, ok := dim1.(php_serialize.PhpArray); ok != true {
			t.Errorf("Second dimension of array was decoded incorrectly: %#v\n", dim1Value)
		} else if value1, ok := dim1Value[php_serialize.PhpValue(0)]; !ok || value1 != "dim2" {
			t.Errorf("Second dimension of array was decoded incorrectly: %#v\n", value1)
		} else if value2, ok := dim1Value[php_serialize.PhpValue(3)]; !ok || value2 != 5 {
			t.Errorf("Second dimension of array was decoded incorrectly: %#v\n", value2)
		} else if dim2, ok := dim1Value[php_serialize.PhpValue(4)]; !ok {
			t.Errorf("Third dimension of array was decoded incorrectly: %#v\n", dim2)
		} else if dim2Value, ok := dim2.(php_serialize.PhpArray); ok != true {
			t.Errorf("Third dimension of array was decoded incorrectly: %#v\n", dim2Value)
		} else if value3, ok := dim2Value[php_serialize.PhpValue(0)]; !ok || value3 != "dim3" {
			t.Errorf("Third dimension of array was decoded incorrectly: %#v\n", value3)
		}
	}
}
func TestEncodeSerializableObjectValue(t *testing.T) {
	arr := php_serialize.PhpArray{
		"a": 5,
		"b": "priv",
		"c": 8,
	}
	obj := php_serialize.NewPhpObjectSerialized("TestObject")
	obj.SetValue(php_serialize.PhpValue(arr))
	data := PhpSession{
		"obj": obj,
	}

	encoder := NewPhpEncoder(data)
	encoder.SetSerializedEncodeFunc(php_serialize.SerializedEncodeFunc(php_serialize.Serialize))
	if result, err := encoder.Encode(); err != nil {
		t.Errorf("Can not encode object value %#v \n", err)
	} else {
		if !strings.Contains(result, "C:10:\"TestObject\"") {
			t.Errorf("Object value was encoded incorrectly %v\n", result)
		} else if !strings.Contains(result, "s:1:\"a\";i:5;") {
			t.Errorf("Object value was encoded incorrectly %v\n", result)
		} else if !strings.Contains(result, "s:1:\"b\";s:4:\"priv\";") {
			t.Errorf("Object value was encoded incorrectly %v\n", result)
		} else if !strings.Contains(result, "s:1:\"c\";i:8;") {
			t.Errorf("Object value was encoded incorrectly %v\n", result)
		}
	}
}
func TestDecodeArrayValue(t *testing.T) {
	decoder := NewPhpDecoder("arr|a:3:{s:4:\"test\";b:1;i:0;i:5;s:5:\"test2\";N;};")
	if result, err := decoder.Decode(); err != nil {
		t.Errorf("Can not decode array value %#v \n", err)
	} else {
		if v, ok := (result)["arr"]; !ok {
			t.Errorf("Array value was not decoded \n")
		} else if arrValue, ok := v.(php_serialize.PhpArray); ok != true {
			t.Errorf("Array value was decoded incorrectly: %#v \n", v)
		} else if value1, ok := arrValue["test"]; !ok || value1 != true {
			t.Errorf("Array value was decoded incorrectly: %#v\n", v)
		} else if value2, ok := arrValue[php_serialize.PhpValue(0)]; !ok || value2 != 5 {
			t.Errorf("Array value was decoded incorrectly: %#v\n", v)
		} else if value3, ok := arrValue["test2"]; !ok || value3 != nil {
			t.Errorf("Array value was decoded incorrectly: %#v\n", v)
		}
	}
}