/** * Create a new database connection mock object for every test. * * @return void */ protected function setUp() { parent::setUp(); $this->connection = $this->prophesize(Connection::class); $this->connection->quoteIdentifier(Argument::cetera())->will(function ($args) { return '"' . join('"."', explode('.', $args[0])) . '"'; }); $this->connection->quote(Argument::cetera())->will(function ($args) { return "'" . $args[0] . "'"; }); $this->connection->getDatabasePlatform()->willReturn(new MockPlatform()); $this->queryContext = GeneralUtility::makeInstance(QueryContext::class); $this->expressionBuilder = GeneralUtility::makeInstance(ExpressionBuilder::class, $this->connection->reveal()); }
/** * @test */ public function literalQuotesValue() { $this->connectionProphet->quote('aField', 'Doctrine\\DBAL\\Types\\StringType')->shouldBeCalled()->willReturn('"aField"'); $result = $this->subject->literal('aField', 'Doctrine\\DBAL\\Types\\StringType'); $this->assertSame('"aField"', $result); }
/** * Quotes a given input parameter. * * @param mixed $input The parameter to be quoted. * @param string|null $type The type of the parameter. * * @return string */ public function literal($input, string $type = null) : string { return $this->connection->quote($input, $type); }