@@ 33-46 (lines=14) @@ | ||
30 | $this->assertTrue(false === array_search('meta', $mappedFields)); |
|
31 | } |
|
32 | ||
33 | public function testMapData_SetNewMeta() |
|
34 | { |
|
35 | $meta = array('newKey' => 'newVal'); |
|
36 | $params = array( |
|
37 | 'lastName' => 'Last Name', |
|
38 | 'meta' => $meta, |
|
39 | ); |
|
40 | $user = new User(); |
|
41 | ||
42 | $this->mapper->mapData($params, $user); |
|
43 | ||
44 | $this->assertEquals('Last Name', $user->getLastName()); |
|
45 | $this->assertEquals($meta, $user->getMeta()); |
|
46 | } |
|
47 | ||
48 | public function testMapData_RewriteExistingMeta() |
|
49 | { |
|
@@ 48-62 (lines=15) @@ | ||
45 | $this->assertEquals($meta, $user->getMeta()); |
|
46 | } |
|
47 | ||
48 | public function testMapData_RewriteExistingMeta() |
|
49 | { |
|
50 | $meta = array('newKey' => 'newVal'); |
|
51 | $params = array( |
|
52 | 'lastName' => 'Last Name', |
|
53 | 'meta' => $meta, |
|
54 | ); |
|
55 | $user = new User(); |
|
56 | $user->setMeta(array('WillBeRewrited' => true)); |
|
57 | ||
58 | $this->mapper->mapData($params, $user); |
|
59 | ||
60 | $this->assertEquals('Last Name', $user->getLastName()); |
|
61 | $this->assertEquals($meta, $user->getMeta()); |
|
62 | } |
|
63 | ||
64 | public function testMapData_ClearExisting() |
|
65 | { |
|
@@ 64-78 (lines=15) @@ | ||
61 | $this->assertEquals($meta, $user->getMeta()); |
|
62 | } |
|
63 | ||
64 | public function testMapData_ClearExisting() |
|
65 | { |
|
66 | $meta = array('WillBeErased' => true); |
|
67 | $params = array( |
|
68 | 'lastName' => 'Last Name', |
|
69 | 'meta' => '', |
|
70 | ); |
|
71 | $user = new User(); |
|
72 | $user->setMeta($meta); |
|
73 | ||
74 | $this->mapper->mapData($params, $user); |
|
75 | ||
76 | $this->assertEquals('Last Name', $user->getLastName()); |
|
77 | $this->assertEquals(array(), $user->getMeta()); |
|
78 | } |
|
79 | ||
80 | public function testMapData_WillBeNotTouched() |
|
81 | { |
|
@@ 80-94 (lines=15) @@ | ||
77 | $this->assertEquals(array(), $user->getMeta()); |
|
78 | } |
|
79 | ||
80 | public function testMapData_WillBeNotTouched() |
|
81 | { |
|
82 | $meta = array('WillExistsAfterMapping' => true); |
|
83 | $params = array( |
|
84 | 'lastName' => 'Last Name', |
|
85 | ); |
|
86 | ||
87 | $user = new User(); |
|
88 | $user->setMeta($meta); |
|
89 | ||
90 | $this->mapper->mapData($params, $user); |
|
91 | ||
92 | $this->assertEquals('Last Name', $user->getLastName()); |
|
93 | $this->assertEquals($meta, $user->getMeta()); |
|
94 | } |
|
95 | } |
|
96 |