1
0
mirror of https://github.com/maximebf/php-debugbar.git synced 2025-01-16 21:08:34 +01:00

Add test-case for Fix parameter output if parameter is Datetime or array [v1.22.4] #671 (#673)

* Fix parameter output if parameter is Datetime or array

* use array_map for parsing parameters

* Add test-case for Doctrine datetime

* Fix doctrine query

---------

Co-authored-by: Alius <aliusa@users.noreply.github.com>
This commit is contained in:
Barry vd. Heuvel 2024-09-09 10:05:55 +02:00 committed by GitHub
parent 02d26dbb2e
commit 1b5cabe0ce
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 12 additions and 3 deletions

Binary file not shown.

View File

@ -11,9 +11,10 @@ $debugbar->addCollector(new DebugBar\Bridge\DoctrineCollector($debugStack));
$product = new Demo\Product();
$product->setName("foobar");
$product->setUpdated();
$entityManager->persist($product);
$entityManager->flush();
$entityManager->createQuery("select p from Demo\\Product p where p.updated>:u")->setParameter("u", new \DateTime('1 hour ago'))->execute();
$entityManager->createQuery("select p from Demo\\Product p where p.name=:c")->setParameter("c", "<script>alert();</script>")->execute();
render_demo_page();

View File

@ -11,6 +11,8 @@ class Product
protected $id;
/** @Column(type="string") **/
protected $name;
/** @Column(type="datetime", nullable=true) **/
protected $updated;
public function getId()
{
@ -26,4 +28,10 @@ class Product
{
$this->name = $name;
}
public function setUpdated(): void
{
// will NOT be saved in the database
$this->updated = new \DateTime('now');
}
}

View File

@ -32,8 +32,8 @@ class DoctrineTest extends AbstractBrowserTest
return $node->getText();
});
$this->assertEquals('INSERT INTO products (name) VALUES (?)', $statements[1]);
$this->assertCount(4, $statements);
$this->assertEquals('INSERT INTO products (name, updated) VALUES (?, ?)', $statements[1]);
$this->assertCount(5, $statements);
}
}