@@ -1921,6 +1921,40 @@ public function testQueryReturnsRejectedPromiseAfterConnectionIsClosed()
19211921 $ ret ->then ($ this ->expectCallableNever (), $ this ->expectCallableOnce ());
19221922 }
19231923
1924+ public function testQueryThrowsForInvalidQueryParamsWithoutCreatingNewConnection ()
1925+ {
1926+ $ factory = $ this ->getMockBuilder ('React\Mysql\Io\Factory ' )->disableOriginalConstructor ()->getMock ();
1927+ $ factory ->expects ($ this ->never ())->method ('createConnection ' );
1928+ $ loop = $ this ->getMockBuilder ('React\EventLoop\LoopInterface ' )->getMock ();
1929+
1930+ $ connection = new MysqlClient ('' , null , $ loop );
1931+
1932+ $ ref = new \ReflectionProperty ($ connection , 'factory ' );
1933+ $ ref ->setAccessible (true );
1934+ $ ref ->setValue ($ connection , $ factory );
1935+
1936+ $ this ->setExpectedException ('InvalidArgumentException ' , 'Query param must be of type string|int|float|bool|null, array given ' );
1937+ $ connection ->query ('SELECT ? ' , [[]]);
1938+ }
1939+
1940+ public function testQueryThrowsForInvalidQueryParamsWhenConnectionIsAlreadyClosed ()
1941+ {
1942+ $ factory = $ this ->getMockBuilder ('React\Mysql\Io\Factory ' )->disableOriginalConstructor ()->getMock ();
1943+ $ factory ->expects ($ this ->never ())->method ('createConnection ' );
1944+ $ loop = $ this ->getMockBuilder ('React\EventLoop\LoopInterface ' )->getMock ();
1945+
1946+ $ connection = new MysqlClient ('' , null , $ loop );
1947+
1948+ $ ref = new \ReflectionProperty ($ connection , 'factory ' );
1949+ $ ref ->setAccessible (true );
1950+ $ ref ->setValue ($ connection , $ factory );
1951+
1952+ $ connection ->close ();
1953+
1954+ $ this ->setExpectedException ('InvalidArgumentException ' , 'Query param must be of type string|int|float|bool|null, array given ' );
1955+ $ connection ->query ('SELECT ? ' , [[]]);
1956+ }
1957+
19241958 public function testQueryStreamThrowsAfterConnectionIsClosed ()
19251959 {
19261960 $ factory = $ this ->getMockBuilder ('React\Mysql\Io\Factory ' )->disableOriginalConstructor ()->getMock ();
@@ -1939,6 +1973,40 @@ public function testQueryStreamThrowsAfterConnectionIsClosed()
19391973 $ connection ->queryStream ('SELECT 1 ' );
19401974 }
19411975
1976+ public function testQueryStreamThrowsForInvalidQueryParamsWithoutCreatingNewConnection ()
1977+ {
1978+ $ factory = $ this ->getMockBuilder ('React\Mysql\Io\Factory ' )->disableOriginalConstructor ()->getMock ();
1979+ $ factory ->expects ($ this ->never ())->method ('createConnection ' );
1980+ $ loop = $ this ->getMockBuilder ('React\EventLoop\LoopInterface ' )->getMock ();
1981+
1982+ $ connection = new MysqlClient ('' , null , $ loop );
1983+
1984+ $ ref = new \ReflectionProperty ($ connection , 'factory ' );
1985+ $ ref ->setAccessible (true );
1986+ $ ref ->setValue ($ connection , $ factory );
1987+
1988+ $ this ->setExpectedException ('InvalidArgumentException ' , 'Query param must be of type string|int|float|bool|null, stdClass given ' );
1989+ $ connection ->queryStream ('SELECT ? ' , [new \stdClass ()]);
1990+ }
1991+
1992+ public function testQueryStreamThrowsForInvalidQueryParamsWhenConnectionIsAlreadyClosed ()
1993+ {
1994+ $ factory = $ this ->getMockBuilder ('React\Mysql\Io\Factory ' )->disableOriginalConstructor ()->getMock ();
1995+ $ factory ->expects ($ this ->never ())->method ('createConnection ' );
1996+ $ loop = $ this ->getMockBuilder ('React\EventLoop\LoopInterface ' )->getMock ();
1997+
1998+ $ connection = new MysqlClient ('' , null , $ loop );
1999+
2000+ $ ref = new \ReflectionProperty ($ connection , 'factory ' );
2001+ $ ref ->setAccessible (true );
2002+ $ ref ->setValue ($ connection , $ factory );
2003+
2004+ $ connection ->close ();
2005+
2006+ $ this ->setExpectedException ('InvalidArgumentException ' , 'Query param must be of type string|int|float|bool|null, stdClass given ' );
2007+ $ connection ->queryStream ('SELECT ? ' , [new \stdClass ()]);
2008+ }
2009+
19422010 public function testPingReturnsRejectedPromiseAfterConnectionIsClosed ()
19432011 {
19442012 $ factory = $ this ->getMockBuilder ('React\Mysql\Io\Factory ' )->disableOriginalConstructor ()->getMock ();
0 commit comments