Skip to content

Commit

Permalink
Add test-case for Fix parameter output if parameter is Datetime or ar…
Browse files Browse the repository at this point in the history
…ray [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>
  • Loading branch information
barryvdh and aliusa authored Sep 9, 2024
1 parent 02d26db commit 1b5cabe
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 3 deletions.
Binary file modified chromedriver
Binary file not shown.
3 changes: 2 additions & 1 deletion demo/bridge/doctrine/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,10 @@

$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();
8 changes: 8 additions & 0 deletions demo/bridge/doctrine/src/Demo/Product.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ class Product
protected $id;
/** @Column(type="string") **/
protected $name;
/** @Column(type="datetime", nullable=true) **/
protected $updated;

public function getId()
{
Expand All @@ -26,4 +28,10 @@ public function setName($name)
{
$this->name = $name;
}

public function setUpdated(): void
{
// will NOT be saved in the database
$this->updated = new \DateTime('now');
}
}
4 changes: 2 additions & 2 deletions tests/DebugBar/Tests/Browser/Bridge/DoctrineTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ public function testMonologCollector(): void
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);
}

}

0 comments on commit 1b5cabe

Please sign in to comment.