123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657 |
- <?php
- namespace Medoo\Tests;
- use Medoo\Medoo;
- /**
- * @coversDefaultClass \Medoo\Medoo
- */
- class RawTest extends MedooTestCase
- {
- /**
- * @covers ::raw()
- * @covers ::isRaw()
- * @covers ::buildRaw()
- * @dataProvider typesProvider
- */
- public function testRawWithPlaceholder($type)
- {
- $this->setType($type);
- $this->database->select('account', [
- 'score' => Medoo::raw('SUM(<age> + <experience>)')
- ]);
- $this->assertQuery(
- <<<EOD
- SELECT SUM("age" + "experience") AS "score"
- FROM "account"
- EOD,
- $this->database->queryString
- );
- }
- /**
- * @covers ::raw()
- * @covers ::isRaw()
- * @covers ::buildRaw()
- * @dataProvider typesProvider
- */
- public function testRawWithSamePlaceholderName($type)
- {
- $this->setType($type);
- $this->database->select('account', [
- 'system' => Medoo::raw("COUNT(<system> = 'window' OR <system> = 'mac')")
- ]);
- $this->assertQuery(
- <<<EOD
- SELECT COUNT("system" = 'window' OR "system" = 'mac') AS "system"
- FROM "account"
- EOD,
- $this->database->queryString
- );
- }
- }
|