当前位置: 首页>>代码示例>>PHP>>正文


PHP Connection::expects方法代码示例

本文整理汇总了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));
 }
开发者ID:Maksold,项目名称:platform,代码行数:10,代码来源:SaveSchemaToolTest.php

示例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');
 }
开发者ID:scottie34,项目名称:silex-fwk,代码行数:10,代码来源:PostDecorator_BeforeGetListTest.php

示例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);
 }
开发者ID:wachterjohannes,项目名称:jackalope-doctrine-dbal,代码行数:11,代码来源:InitDoctrineDbalCommandTest.php

示例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();
 }
开发者ID:TheTypoMaster,项目名称:SPHERE-Framework,代码行数:15,代码来源:StatementTest.php

示例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);
 }
开发者ID:ezsystems,项目名称:ez-support-tools,代码行数:15,代码来源:DoctrineDatabaseSystemInfoCollectorTest.php

示例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);
 }
开发者ID:nibra,项目名称:joomla-pythagoras,代码行数:13,代码来源:DoctrineDataMapperTest.php

示例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));
 }
开发者ID:selimcr,项目名称:servigases,代码行数:13,代码来源:StatementTest.php

示例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());
 }
开发者ID:scottie34,项目名称:silex-fwk,代码行数:13,代码来源:PostControllerTest.php

示例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/');
 }
开发者ID:blankse,项目名称:ezpublish-kernel-1,代码行数:7,代码来源:LegacyDFSClusterTest.php

示例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();
 }
开发者ID:robertlemke,项目名称:flow-development-collection,代码行数:11,代码来源:PersistenceManagerTest.php

示例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'));
 }
开发者ID:dfritschy,项目名称:ezpublish-kernel,代码行数:7,代码来源:LegacyDFSClusterTest.php

示例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);
 }
开发者ID:axelvnk,项目名称:KunstmaanBundlesCMS,代码行数:22,代码来源:AclNativeHelperTest.php

示例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());
 }
开发者ID:Basster,项目名称:hs-bremen-web-api,代码行数:13,代码来源:OrderRepositoryTest.php

示例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);
 }
开发者ID:hafeez3000,项目名称:orocommerce,代码行数:11,代码来源:ProductDuplicatorTest.php

示例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'));
 }
开发者ID:selimcr,项目名称:servigases,代码行数:15,代码来源:PostgreSQLSchemaManagerTest.php


注:本文中的Doctrine\DBAL\Connection::expects方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。