Ejemplo n.º 1
0
 public function testAddCustomPlaceholder_setCustomsPlaceholdersSetCustomAdapter()
 {
     $db = new Database(new DSN('mysql:'));
     $myPlaceholderOne = Helper::getMockCustomPlaceholder('?x');
     $db->addCustomPlaceholder($myPlaceholderOne);
     $myAdapter = Helper::getMockCustomAdapter();
     $db->setAdapter($myAdapter);
     $myPlaceholderTwo = Helper::getMockCustomPlaceholder('?y');
     $db->addCustomPlaceholder($myPlaceholderTwo);
     $this->assertEquals($myAdapter, $db->getAdapter());
     $placeholders = $db->getPlaceholders();
     foreach ($db->getPlaceholders()->getAllPlaceholdersAsArray() as $placeholder) {
         $this->assertEquals($myAdapter, $placeholder->getQuotePerformer());
     }
     $this->assertEquals('f#_nadxy', $placeholders->getAllPlaceholdersAsString());
 }
Ejemplo n.º 2
0
 public function testTransformQuery_CustomAdapterCustomPlaceholderWithCommonNativePlaceholderWithoutExpandValueFewValues()
 {
     $myAdapter = Helper::getMockCustomAdapter();
     $placeholders = new PlaceholderCollection();
     $placeholders->addPlaceholder(Helper::getMockCustomPlaceholder('?m'));
     $transformer = new QueryTransformer($myAdapter, $placeholders);
     $result = $transformer->transformQuery(Query::create('SQL_TEXT ?m, ?m SQL_TEXT', ['in1']), false);
     $this->assertEquals('SQL_TEXT ?, ERROR_NO_VALUE SQL_TEXT', $result->getQueryAsText());
     $this->assertSame(['out1'], $result->getValues());
 }