本文整理汇总了PHP中Doctrine\DBAL\Connection::expects方法的典型用法代码示例。如果您正苦于以下问题:PHP Connection::expects方法的具体用法?PHP Connection::expects怎么用?PHP Connection::expects使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Doctrine\DBAL\Connection
的用法示例。
在下文中一共展示了Connection::expects方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testGetUpdateSchemaSqlShouldAffectOnlyKnownDBTableParts
public function testGetUpdateSchemaSqlShouldAffectOnlyKnownDBTableParts()
{
list($fromSchema, $toSchema) = $this->prepareSchemas();
$meta = [new \stdClass()];
$schemaManager = $this->getMockBuilder('Doctrine\\DBAL\\Schema\\AbstractSchemaManager')->setMethods(['createSchema'])->disableOriginalConstructor()->getMockForAbstractClass();
$schemaManager->expects($this->once())->method('createSchema')->willReturn($fromSchema);
$this->connection->expects($this->once())->method('getSchemaManager')->willReturn($schemaManager);
$this->schemaTool->expects($this->once())->method('getSchemaFromMetadata')->with($meta)->willReturn($toSchema);
$this->assertEquals(['DROP INDEX oro_idx_index_name ON oro_entity_extend_test_relation'], $this->schemaTool->getUpdateSchemaSql($meta, true));
}
示例2: setUp
public function setUp()
{
parent::setUp();
$this->postDecorator = new PostDecorator();
$this->conn = $this->getMock('Doctrine\\DBAL\\Connection', array(), array(), '', false);
$expressionBuilder = new ExpressionBuilder($this->conn);
$this->conn->expects($this->any())->method('getExpressionBuilder')->will($this->returnValue($expressionBuilder));
$this->queryBuilder = new QueryBuilder($this->conn);
$this->queryBuilder->select('o.*')->from('posts', 'o');
}
示例3: testCommand
public function testCommand()
{
$this->executeCommand('jackalope:init:dbal', array(), 2);
$this->executeCommand('jackalope:init:dbal', array('--dump-sql' => true), 0);
$this->executeCommand('jackalope:init:dbal', array('--dump-sql' => true, '--drop' => true), 0);
$this->executeCommand('jackalope:init:dbal', array('--force' => true), 0);
$this->executeCommand('jackalope:init:dbal', array('--force' => true, '--drop' => true), 0);
// Unfortunately PDO doesn't follow internals and uses a non integer error code, which cannot be manually created
$this->connection->expects($this->any())->method('exec')->will($this->throwException(new MockPDOException('', '42S01')));
$this->executeCommand('jackalope:init:dbal', array('--force' => true, '--drop' => true), 1);
}
示例4: testExecuteCallsLoggerStopQueryOnException
/**
* @expectedException \Doctrine\DBAL\DBALException
*/
public function testExecuteCallsLoggerStopQueryOnException()
{
$logger = $this->getMock('\\Doctrine\\DBAL\\Logging\\SQLLogger');
$this->configuration->expects($this->once())->method('getSQLLogger')->will($this->returnValue($logger));
// Needed to satisfy construction of DBALException
$this->conn->expects($this->any())->method('resolveParams')->will($this->returnValue(array()));
$logger->expects($this->once())->method('startQuery');
$logger->expects($this->once())->method('stopQuery');
$this->pdoStatement->expects($this->once())->method('execute')->will($this->throwException(new \Exception("Mock test exception")));
$statement = new Statement("", $this->conn);
$statement->execute();
}
示例5: testCollect
/**
* @covers \EzSystems\EzSupportToolsBundle\SystemInfo\Collector\DoctrineDatabaseSystemInfoCollector::collect()
*/
public function testCollect()
{
$expected = new DatabaseSystemInfo(['type' => 'mysql', 'name' => 'ezp_platform', 'host' => 'localhost', 'username' => 'ezp_user']);
$this->dbalConnectionMock->expects($this->once())->method('getDatabasePlatform')->will($this->returnValue($this->dbalPlatformMock));
$this->dbalPlatformMock->expects($this->once())->method('getName')->will($this->returnValue($expected->type));
$this->dbalConnectionMock->expects($this->once())->method('getDatabase')->will($this->returnValue($expected->name));
$this->dbalConnectionMock->expects($this->once())->method('getHost')->will($this->returnValue($expected->host));
$this->dbalConnectionMock->expects($this->once())->method('getUsername')->will($this->returnValue($expected->username));
$value = $this->databaseCollector->collect();
self::assertInstanceOf('EzSystems\\EzSupportToolsBundle\\SystemInfo\\Value\\DatabaseSystemInfo', $value);
self::assertEquals($expected, $value);
}
示例6: setUp
public function setUp()
{
$statement = $this->createMock(Statement::class);
$statement->expects($this->any())->method('fetchAll')->willReturn(array_values($this->articles));
$queryBuilder = $this->createMock(QueryBuilder::class);
$queryBuilder->expects($this->any())->method('select')->willReturnSelf();
$queryBuilder->expects($this->any())->method('setMaxResults')->willReturnSelf();
$queryBuilder->expects($this->any())->method('execute')->willReturn($statement);
$this->connection = $this->createMock(Connection::class);
$this->connection->expects($this->any())->method('createQueryBuilder')->willReturn($queryBuilder);
parent::setUp();
$this->dataMapper = new DoctrineDataMapper($this->connection, Article::class, 'articles', $this->entityRegistry);
}
示例7: setUp
public function setUp()
{
$pdoStatement = $this->getMock('\\PDOStatment', array('execute', 'bindParam', 'bindValue'));
$platform = new \Doctrine\Tests\DBAL\Mocks\MockPlatform();
$driverConnection = $this->getMock('\\Doctrine\\DBAL\\Driver\\Connection');
$driverConnection->expects($this->any())->method('prepare')->will($this->returnValue($pdoStatement));
$driver = $this->getMock('\\Doctrine\\DBAL\\Driver');
$constructorArgs = array(array('platform' => $platform), $driver);
$this->conn = $this->getMock('\\Doctrine\\DBAL\\Connection', array(), $constructorArgs);
$this->conn->expects($this->atLeastOnce())->method('getWrappedConnection')->will($this->returnValue($driverConnection));
$this->configuration = $this->getMock('\\Doctrine\\DBAL\\Configuration');
$this->conn->expects($this->any())->method('getConfiguration')->will($this->returnValue($this->configuration));
}
示例8: testCollect
public function testCollect()
{
// getPosts returns an array of size 10 => 20 loops => 20 getUrl
$this->curlUtils->expects($this->exactly(20))->method('getResource')->will($this->returnValue('whatever'));
$this->postParserUtils->expects($this->exactly(20))->method('getPosts')->will($this->returnValue(array(0 => 0, 1 => 1, 2 => 2, 3 => 3, 4 => 4, 5 => 5, 6 => 6, 7 => 7, 8 => 8, 9 => 9)));
$this->postParserUtils->expects($this->exactly(200))->method('parse')->will($this->returnValue(array("content" => "this is a content", "author" => "FOO", "created" => "2014-01-01 00:00:00")));
// insert in Db should be called 200 times
$this->conn->expects($this->exactly(200))->method('insert');
$response = $this->postController->collect();
$this->assertInstanceOf("Symfony\\Component\\HttpFoundation\\JsonResponse", $response);
$this->assertEquals(200, $response->getStatusCode());
$this->assertContains("200 posts have been added", $response->getContent());
}
示例9: testDeletedirectory
public function testDeletedirectory()
{
$statement = $this->createDbalStatementMock();
$statement->expects($this->once())->method('bindValue')->with(1, 'folder/subfolder/%');
$this->dbalMock->expects($this->once())->method('prepare')->with($this->anything())->will($this->returnValue($statement));
$this->handler->deleteDirectory('folder/subfolder/');
}
示例10: persistAllReconnectsConnectionOnFailure
/**
* @test
* @expectedException \TYPO3\Flow\Error\Exception
*/
public function persistAllReconnectsConnectionOnFailure()
{
$this->mockEntityManager->expects($this->exactly(2))->method('flush')->will($this->throwException(new \TYPO3\Flow\Error\Exception('Dummy connection error')));
$this->mockConnection->expects($this->at(0))->method('close');
$this->mockConnection->expects($this->at(1))->method('connect');
$this->persistenceManager->persistAll();
}
示例11: testExistsNot
public function testExistsNot()
{
$statement = $this->createDbalStatementMock();
$statement->expects($this->once())->method('rowCount')->will($this->returnValue(0));
$this->dbalMock->expects($this->once())->method('prepare')->with($this->anything())->will($this->returnValue($statement));
self::assertFalse($this->handler->exists('prefix/my/file.png'));
}
示例12: setUp
/**
* Sets up the fixture, for example, opens a network connection.
* This method is called before a test is executed.
*/
protected function setUp()
{
$this->em = $this->getMockBuilder('Doctrine\\ORM\\EntityManager')->disableOriginalConstructor()->getMock();
$this->conn = $this->getMockBuilder('Doctrine\\DBAL\\Connection')->disableOriginalConstructor()->getMock();
$this->conn->expects($this->any())->method('getDatabase')->will($this->returnValue('myDatabase'));
/* @var $platform AbstractPlatform */
$platform = $this->getMockForAbstractClass('Doctrine\\DBAL\\Platforms\\AbstractPlatform');
$this->conn->expects($this->any())->method('getDatabasePlatform')->will($this->returnValue($platform));
$this->em->expects($this->any())->method('getConnection')->will($this->returnValue($this->conn));
/* @var $meta ClassMetadata */
$meta = $this->getMockBuilder('Doctrine\\ORM\\Mapping\\ClassMetadata')->disableOriginalConstructor()->getMock();
$this->em->expects($this->any())->method('getClassMetadata')->will($this->returnValue($meta));
$this->sc = $this->getMockBuilder('Symfony\\Component\\Security\\Core\\SecurityContextInterface')->getMock();
$this->token = $this->getMockBuilder('Symfony\\Component\\Security\\Core\\Authentication\\Token\\TokenInterface')->getMock();
$this->sc->expects($this->any())->method('getToken')->will($this->returnValue($this->token));
$this->rh = $this->getMockBuilder('Symfony\\Component\\Security\\Core\\Role\\RoleHierarchyInterface')->getMock();
$this->object = new AclNativeHelper($this->em, $this->sc, $this->rh);
}
示例13: insertAnOrder
/**
* @test
*/
public function insertAnOrder()
{
$orderData = ['status' => 'placed'];
$this->db->expects(self::once())->method('insert')->with('order', $orderData);
$this->db->expects(self::once())->method('lastInsertId')->willReturn(1);
$order = new Order();
$order->setStatus('placed');
$this->repository->save($order);
self::assertEquals(1, $order->getId());
}
示例14: testDuplicateFailed
public function testDuplicateFailed()
{
$product = (new StubProduct())->setSku(self::PRODUCT_SKU);
$this->skuIncrementor->expects($this->once())->method('increment')->with(self::PRODUCT_SKU)->will($this->returnValue(self::PRODUCT_COPY_SKU));
$this->attachmentProvider->expects($this->once())->method('getEntityAttachments')->with($product)->will($this->returnValue([]));
$this->connection->expects($this->once())->method('beginTransaction');
$this->connection->expects($this->once())->method('commit')->will($this->throwException(new \Exception()));
$this->connection->expects($this->once())->method('rollback');
$this->setExpectedException('Exception');
$this->duplicator->duplicate($product);
}
示例15: testFiltersSequences
/**
* @group DBAL-474
*/
public function testFiltersSequences()
{
$configuration = new Configuration();
$configuration->setFilterSchemaAssetsExpression('/^schema/');
$sequences = array(array('relname' => 'foo', 'schemaname' => 'schema'), array('relname' => 'bar', 'schemaname' => 'schema'), array('relname' => 'baz', 'schemaname' => ''), array('relname' => 'bloo', 'schemaname' => 'bloo_schema'));
$this->connection->expects($this->any())->method('getConfiguration')->will($this->returnValue($configuration));
$this->connection->expects($this->at(0))->method('fetchAll')->will($this->returnValue($sequences));
$this->connection->expects($this->at(1))->method('fetchAll')->will($this->returnValue(array(array('min_value' => 1, 'increment_by' => 1))));
$this->connection->expects($this->at(2))->method('fetchAll')->will($this->returnValue(array(array('min_value' => 2, 'increment_by' => 2))));
$this->connection->expects($this->exactly(3))->method('fetchAll');
$this->assertEquals(array(new Sequence('schema.foo', 2, 2), new Sequence('schema.bar', 1, 1)), $this->schemaManager->listSequences('database'));
}