A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/cakephp/phinx/commit/524ebdeb0e1838a845d752a3418726b38cd1e654 below:

Fix using Cake\I18n\Date and DateTime in insert dry-run (#2359) · cakephp/phinx@524ebde · GitHub

File tree Expand file treeCollapse file tree 2 files changed

+38

-17

lines changed

Filter options

Expand file treeCollapse file tree 2 files changed

+38

-17

lines changed Original file line number Diff line number Diff line change

@@ -403,6 +403,12 @@ protected function quoteValue(mixed $value): mixed

403 403

return (string)$value;

404 404

}

405 405 406 +

if ($value instanceof DateTime) {

407 +

$value = $value->toDateTimeString();

408 +

} elseif ($value instanceof Date) {

409 +

$value = $value->toDateString();

410 +

}

411 + 406 412

return $this->getConnection()->quote($value);

407 413

}

408 414 Original file line number Diff line number Diff line change

@@ -3,9 +3,12 @@

3 3 4 4

namespace Test\Phinx\Db\Adapter;

5 5 6 +

use Cake\I18n\Date;

7 +

use Cake\I18n\DateTime;

6 8

use PDO;

7 9

use PDOException;

8 10

use Phinx\Config\Config;

11 +

use Phinx\Util\Literal;

9 12

use PHPUnit\Framework\TestCase;

10 13

use ReflectionMethod;

11 14

use RuntimeException;

@@ -205,31 +208,42 @@ public function testExecuteRightTrimsSemiColons()

205 208

$this->adapter->execute('SELECT 1;;');

206 209

}

207 210 208 -

public function testQuoteValueNumeric()

211 +

public function quoteValueDataProvider(): array

209 212

{

210 -

$method = new ReflectionMethod($this->adapter, 'quoteValue');

211 -

$this->assertSame(1.0, $method->invoke($this->adapter, 1.0));

212 -

$this->assertSame(2, $method->invoke($this->adapter, 2));

213 +

return [

214 +

[1.0, 1.0],

215 +

[2, 2],

216 +

[true, 1],

217 +

[false, 0],

218 +

[null, 'null'],

219 +

[Literal::from('CURRENT_TIMESTAMP'), 'CURRENT_TIMESTAMP'],

220 +

];

213 221

}

214 222 215 -

public function testQuoteValueBoolean()

223 +

/**

224 +

* @dataProvider quoteValueDataProvider

225 +

*/

226 +

public function testQuoteValue($input, $expected): void

216 227

{

217 228

$method = new ReflectionMethod($this->adapter, 'quoteValue');

218 -

$this->assertSame(1, $method->invoke($this->adapter, true));

219 -

$this->assertSame(0, $method->invoke($this->adapter, false));

229 +

$this->assertSame($expected, $method->invoke($this->adapter, $input));

220 230

}

221 231 222 -

public function testQuoteValueNull()

232 +

public function quoteValueStringDataProvider(): array

223 233

{

224 -

$method = new ReflectionMethod($this->adapter, 'quoteValue');

225 -

$this->assertSame('null', $method->invoke($this->adapter, null));

234 +

return [

235 +

['mockvalue', "'mockvalue'"],

236 +

[new Date('2023-01-01'), "'2023-01-01'"],

237 +

[new DateTime('2023-01-01 12:00:00'), "'2023-01-01 12:00:00'"],

238 +

];

226 239

}

227 240 228 -

public function testQuoteValueString()

229 -

{

230 -

$mockValue = 'mockvalue';

231 -

$expectedValue = 'mockvalueexpected';

241 +

/**

242 +

* @dataProvider quoteValueStringDataProvider

243 +

*/

232 244 245 +

public function testQuoteValueString($input, $expected): void

246 +

{

233 247

/** @var \PDO&\PHPUnit\Framework\MockObject\MockObject $pdo */

234 248

$pdo = $this->getMockBuilder(PDO::class)

235 249

->disableOriginalConstructor()

@@ -238,12 +252,13 @@ public function testQuoteValueString()

238 252 239 253

$pdo->expects($this->once())

240 254

->method('quote')

241 -

->with($mockValue)

242 -

->willReturn($expectedValue);

255 +

->willReturnCallback(function (string $input) {

256 +

return "'$input'";

257 +

});

243 258 244 259

$this->adapter->setConnection($pdo);

245 260 246 261

$method = new ReflectionMethod($this->adapter, 'quoteValue');

247 -

$this->assertSame($expectedValue, $method->invoke($this->adapter, $mockValue));

262 +

$this->assertSame($expected, $method->invoke($this->adapter, $input));

248 263

}

249 264

}

You can’t perform that action at this time.


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4