2121use Yiisoft \Db \Schema \Column \DoubleColumn ;
2222use Yiisoft \Db \Schema \Column \IntegerColumn ;
2323use Yiisoft \Db \Schema \Column \StringColumn ;
24+ use Yiisoft \Db \Schema \Data \StringableStream ;
2425use Yiisoft \Db \Tests \Common \CommonColumnTest ;
2526
2627use function iterator_to_array ;
2728use function str_repeat ;
28- use function stream_get_contents ;
2929use function version_compare ;
3030
3131/**
@@ -65,7 +65,7 @@ protected function assertTypecastedValues(array $result, bool $allTypecasted = f
6565 $ this ->assertSame (str_repeat ('x ' , 100 ), $ result ['char_col ' ]);
6666 $ this ->assertNull ($ result ['char_col3 ' ]);
6767 $ this ->assertSame (1.234 , $ result ['float_col ' ]);
68- $ this ->assertSame ("\x10\x11\x12" , stream_get_contents ( $ result ['blob_col ' ]) );
68+ $ this ->assertSame ("\x10\x11\x12" , ( string ) $ result ['blob_col ' ]);
6969 $ this ->assertEquals (new DateTimeImmutable ('2023-07-11 14:50:23 ' , $ utcTimezone ), $ result ['timestamp_col ' ]);
7070 $ this ->assertEquals (new DateTimeImmutable ('2023-07-11 14:50:23 ' , $ utcTimezone ), $ result ['timestamp_local ' ]);
7171 $ this ->assertEquals (new DateTimeImmutable ('14:50:23 ' ), $ result ['time_col ' ]);
@@ -75,7 +75,7 @@ protected function assertTypecastedValues(array $result, bool $allTypecasted = f
7575 if ($ allTypecasted ) {
7676 $ this ->assertSame ([['a ' => 1 , 'b ' => null , 'c ' => [1 , 3 , 5 ]]], $ result ['json_col ' ]);
7777 } else {
78- $ this ->assertSame ('[{"a":1,"b":null,"c":[1,3,5]}] ' , stream_get_contents ( $ result ['json_col ' ]) );
78+ $ this ->assertSame ('[{"a":1,"b":null,"c":[1,3,5]}] ' , ( string ) $ result ['json_col ' ]);
7979 }
8080 }
8181
@@ -240,11 +240,20 @@ public function testBinaryColumn(): void
240240 $ binaryCol = new BinaryColumn ();
241241 $ binaryCol ->dbType ('blob ' );
242242
243- $ this ->assertInstanceOf (Expression::class, $ binaryCol ->dbTypecast ("\x10\x11\x12" ));
244- $ this ->assertInstanceOf (
245- Expression::class,
243+ $ expected = new Expression ('TO_BLOB(UTL_RAW.CAST_TO_RAW(:value)) ' , ['value ' => "\x10\x11\x12" ]);
244+
245+ $ this ->assertEquals (
246+ $ expected ,
247+ $ binaryCol ->dbTypecast ("\x10\x11\x12" ),
248+ );
249+ $ this ->assertEquals (
250+ $ expected ,
246251 $ binaryCol ->dbTypecast (new Param ("\x10\x11\x12" , PDO ::PARAM_LOB )),
247252 );
253+ $ this ->assertEquals (
254+ $ expected ,
255+ $ binaryCol ->dbTypecast (new StringableStream ("\x10\x11\x12" )),
256+ );
248257 }
249258
250259 public function testJsonColumn (): void
0 commit comments