@@ -60,27 +60,41 @@ public function testSerialize()
6060
6161 public function testSerializeWithI18nFilter ()
6262 {
63- $ table = $ this ->conn ->getTable ('I18nFilterTest ' );
63+ try {
64+ $ table = $ this ->conn ->getTable ('I18nFilterTest ' );
6465
65- $ record = $ table ->create ();
66- $ record ['name ' ] = 'foo ' ;
67- $ this ->assertEqual ('foo ' , $ record ['name ' ]);
66+ $ record = $ table ->create ();
67+ $ record ['name ' ] = 'foo ' ;
68+ $ this ->assertEqual ('foo ' , $ record ['name ' ]);
6869
69- // Test the I18nFilterTest record that include the second filter.
70- $ this ->assertTrue (in_array ('I18nFilterTestFilter ' , array_map ('get_class ' , $ table ->getFilters ())));
71- $ expectedFilterNames = array_map ('get_class ' , $ table ->getFilters ());
70+ // Test the I18nFilterTest record that include the second filter.
71+ $ this ->assertTrue (in_array ('I18nFilterTestFilter ' , array_map ('get_class ' , $ table ->getFilters ())));
72+ $ expectedFilterNames = array_map ('get_class ' , $ table ->getFilters ());
7273
73- $ serializedTable = serialize ($ table );
74+ $ serializedTable = serialize ($ table );
7475
75- $ unserializedTable = unserialize ($ serializedTable );
76- $ unserializedTable ->initializeFromCache ($ this ->conn );
76+ // Remove the table from internal class cache.
77+ $ tables = $ this ->conn ->getTables ();
78+ $ relf = new ReflectionProperty ($ this ->conn , 'tables ' );
79+ unset($ tables ['I18nFilterTest ' ]);
80+ unset($ tables ['I18nFilterTestTranslation ' ]);
81+ $ relf ->setAccessible (true );
82+ $ relf ->setValue ($ this ->conn , $ tables );
83+ $ relf ->setAccessible (false );
7784
78- $ record = $ unserializedTable ->create ();
85+ $ unserializedTable = unserialize ($ serializedTable );
86+ $ unserializedTable ->initializeFromCache ($ this ->conn );
87+ $ this ->conn ->addTable ($ unserializedTable );
7988
80- $ this -> assertEqual ( $ expectedFilterNames , array_map ( ' get_class ' , $ unserializedTable ->getFilters ()) );
89+ $ record = $ unserializedTable ->create ( );
8190
82- $ record ['name ' ] = 'foo ' ;
83- $ this ->assertEqual ('foo ' , $ record ['name ' ]);
91+ $ this ->assertEqual ($ expectedFilterNames , array_map ('get_class ' , $ unserializedTable ->getFilters ()));
92+
93+ $ record ['name ' ] = 'foo ' ;
94+ $ this ->assertEqual ('foo ' , $ record ['name ' ]);
95+ } catch (Exception $ e ) {
96+ $ this ->failFromException ($ e );
97+ }
8498 }
8599
86100 public function testFieldConversion ()
0 commit comments