1313namespace DebugKit \Test \TestCase \Panel ;
1414
1515use Cake \Controller \Controller ;
16+ use Cake \Datasource \ConnectionManager ;
1617use Cake \Event \Event ;
1718use Cake \ORM \TableRegistry ;
1819use Cake \TestSuite \TestCase ;
@@ -40,22 +41,40 @@ public function setUp() {
4041 $ this ->panel = new SqlLogPanel ();
4142 }
4243
44+ /**
45+ * Ensure that subrequests don't double proxy the logger.
46+ *
47+ * @return void
48+ */
49+ public function testInitializeTwiceNoDoubleProxy () {
50+ $ event = new Event ('Sample ' );
51+
52+ $ this ->panel ->initialize ($ event );
53+ $ db = ConnectionManager::get ('test ' );
54+ $ logger = $ db ->logger ();
55+ $ this ->assertInstanceOf ('DebugKit\Database\Log\DebugLog ' , $ logger );
56+
57+ $ this ->panel ->initialize ($ event );
58+ $ second = $ db ->logger ();
59+ $ this ->assertSame ($ second , $ logger );
60+
61+ $ this ->assertCount (2 , $ this ->panel ->data ()['loggers ' ]);
62+ }
63+
4364/**
4465 * test the parsing of source list.
4566 *
4667 * @return void
4768 */
4869 public function testData () {
4970 $ event = new Event ('Sample ' );
50- $ result = $ this ->panel ->initialize ($ event );
71+ $ this ->panel ->initialize ($ event );
5172
5273 $ articles = TableRegistry::get ('Articles ' );
5374 $ articles ->findById (1 )->first ();
5475
5576 $ result = $ this ->panel ->data ();
56-
5777 $ this ->assertArrayHasKey ('loggers ' , $ result );
58- $ this ->assertCount (3 , $ result ['loggers ' ]);
5978 }
6079
6180/**
@@ -71,7 +90,7 @@ public function testSummary() {
7190 $ articles ->findById (1 )->first ();
7291
7392 $ result = $ this ->panel ->summary ();
74- $ this ->assertRegExp ('/1 - \d+ ms/ ' , $ result );
93+ $ this ->assertRegExp ('/\d+ - \d+ ms/ ' , $ result );
7594 }
7695
7796}
0 commit comments