php-serialization 0.5.3 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,49 +0,0 @@
1
- require File.dirname(__FILE__) + "/spec_helper"
2
-
3
- describe "Serialization" do
4
- it "should serialize a integer" do
5
- PhpSerialization.dump(10).should == "i:10;"
6
- end
7
-
8
- it "should serialize a string" do
9
- PhpSerialization.dump("Name").should == 's:4:"Name";'
10
- end
11
-
12
- it "should serialize a symbol string" do
13
- PhpSerialization.dump(:name).should == 's:4:"name";'
14
- end
15
-
16
- it "should serialize true" do
17
- PhpSerialization.dump(true).should == 'b:1;'
18
- end
19
-
20
- it "should serialize false" do
21
- PhpSerialization.dump(false).should == 'b:0;'
22
- end
23
-
24
- it "should serialize nil" do
25
- PhpSerialization.dump(nil).should == 'N;'
26
- end
27
-
28
- it "should unzerialize an array" do
29
- PhpSerialization.dump([true, "foo"]).should == 'a:2:{i:0;b:1;i:1;s:3:"foo";}'
30
- end
31
-
32
- it "should serialize a hash" do
33
- PhpSerialization.dump("name" => "Rodrigo", "age" => 23).should == 'a:2:{s:4:"name";s:7:"Rodrigo";s:3:"age";i:23;}'
34
- end
35
-
36
- it "should serialize object with class existant" do
37
- class Person
38
- attr_accessor :name, :age
39
- end
40
-
41
- person = Person.new
42
- person.name = "Rodrigo"
43
- person.age = 23
44
-
45
- PhpSerialization.dump(person).should == 'O:6:"Person":2:{s:4:"name";s:7:"Rodrigo";s:3:"age";i:23;}'
46
-
47
- Object.send(:remove_const, :Person)
48
- end
49
- end
@@ -1,21 +0,0 @@
1
- require File.dirname(__FILE__) + "/spec_helper"
2
-
3
- describe "Session serialization" do
4
- it "should store session correctly" do
5
- PhpSessionSerialization.load("userId|i:123;store|s:3:\"foo\";someArr|a:2:{i:0;b:1;i:1;s:3:\"foo\";}").should == {
6
- "userId" => 123,
7
- "store" => "foo",
8
- "someArr" => [true, "foo"]
9
- }
10
- end
11
-
12
- it "should dump a hash as session" do
13
- session_hash = {
14
- "userId" => 123,
15
- "store" => "foo",
16
- "someArr" => [true, "foo"]
17
- }
18
-
19
- PhpSessionSerialization.load(PhpSessionSerialization.dump(session_hash)).should == session_hash
20
- end
21
- end
@@ -1,3 +0,0 @@
1
- --diff u
2
- --color
3
- --format profile
@@ -1,9 +0,0 @@
1
- $LOAD_PATH.unshift(File.dirname(__FILE__))
2
- $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
3
- require 'php_serialization'
4
- require 'spec'
5
- require 'spec/autorun'
6
-
7
- Spec::Runner.configure do |config|
8
-
9
- end
@@ -1,51 +0,0 @@
1
- require File.dirname(__FILE__) + "/spec_helper"
2
-
3
- describe "Unserialization" do
4
- it "should unserialize a integer" do
5
- PhpSerialization.load("i:10;").should == 10
6
- end
7
-
8
- it "should unserialize a string" do
9
- PhpSerialization.load('s:4:"Name";').should == "Name"
10
- end
11
-
12
- it "should unserialize true" do
13
- PhpSerialization.load('b:1;').should == true
14
- end
15
-
16
- it "should unserialize false" do
17
- PhpSerialization.load('b:0;').should == false
18
- end
19
-
20
- it "should unserialize nil" do
21
- PhpSerialization.load('N;').should == nil
22
- end
23
-
24
- it "should unzerialize an array" do
25
- PhpSerialization.load('a:2:{i:0;b:1;i:1;s:3:"foo";}').should == [true, "foo"]
26
- end
27
-
28
- it "should unserialize a hash" do
29
- PhpSerialization.load('a:2:{s:4:"name";s:7:"Rodrigo";s:3:"age";i:23;}').should == {"name" => "Rodrigo", "age" => 23}
30
- end
31
-
32
- it "should unserialize object with class existant" do
33
- class Person
34
- attr_accessor :name, :age, :gender
35
- end
36
-
37
- person = PhpSerialization.load('O:6:"Person":2:{s:4:"name";s:7:"Rodrigo";s:3:"age";i:23;}')
38
- person.should be_instance_of(Person)
39
- person.name.should == "Rodrigo"
40
- person.age.should == 23
41
-
42
- Object.send(:remove_const, :Person)
43
- end
44
-
45
- it "should unserialize object without class as a struct" do
46
- person = PhpSerialization.load('O:6:"Person":2:{s:4:"name";s:7:"Rodrigo";s:3:"age";i:23;}')
47
- person.should be_instance_of(Struct::Person)
48
- person.name.should == "Rodrigo"
49
- person.age.should == 23
50
- end
51
- end