/**
  * @dataProvider callbackDataProvider
  *
  * @param string $expectedMessage
  * @param string $expectedMethod
  * @param string $exceptionClass
  * @throws
  */
 public function testMainFlow($expectedMessage, $expectedMethod, $exceptionClass)
 {
     $this->_testCase->expects($this->any())->method($expectedMethod)->with($this->stringStartsWith($expectedMessage));
     $this->_invoker->__invoke(function () use($exceptionClass) {
         throw new $exceptionClass('Some meaningful message.');
     }, [[0]]);
 }
Exemplo n.º 2
0
 /**
  * @SuppressWarnings(PHPMD.ExcessiveMethodLength)
  */
 public function testMerge()
 {
     $fieldData = $this->createFieldData();
     $fieldMetadataData = $this->createFieldMetadata();
     $entityData = $this->createEntityData();
     $masterEntity = new EntityStub(1);
     $sourceEntity = new EntityStub(2);
     $collectionItem1 = new CollectionItemStub(1);
     $collectionItem2 = new CollectionItemStub(2);
     $masterEntity->addCollectionItem($collectionItem1);
     $sourceEntity->addCollectionItem($collectionItem2);
     $entities = [$masterEntity, $sourceEntity];
     $relatedEntities = [$collectionItem1, $collectionItem2];
     $fieldData->expects($this->once())->method('getEntityData')->will($this->returnValue($entityData));
     $fieldData->expects($this->once())->method('getMetadata')->will($this->returnValue($fieldMetadataData));
     $entityData->expects($this->once())->method('getEntities')->will($this->returnValue($entities));
     $entityData->expects($this->once())->method('getMasterEntity')->will($this->returnValue($masterEntity));
     $this->doctrineHelper->expects($this->any())->method('getEntityIdentifierValue')->will($this->returnCallback(function ($value) {
         return $value->getId();
     }));
     $fieldDoctrineMetadata = $this->createDoctrineMetadata();
     $fieldDoctrineMetadata->expects($this->any())->method('getFieldName')->will($this->returnValue('field_name'));
     $fieldMetadataData->expects($this->any())->method('getDoctrineMetadata')->will($this->returnValue($fieldDoctrineMetadata));
     $fieldMetadataData->expects($this->any())->method('getFieldName')->will($this->returnValue('collection'));
     $fieldMetadataData->expects($this->any())->method('has')->will($this->returnValue(true));
     $fieldMetadataData->expects($this->any())->method('get')->will($this->returnValue('setEntityStub'));
     $repository = $this->getMockBuilder('Doctrine\\Common\\Persistence\\ObjectRepository')->disableOriginalConstructor()->getMock();
     $this->doctrineHelper->expects($this->any())->method('getEntityRepository')->will($this->returnValue($repository));
     $repository->expects($this->any())->method('findBy')->will($this->returnCallback(function ($values) use($relatedEntities) {
         return [$relatedEntities[$values['field_name']->getId() - 1]];
     }));
     $this->strategy->merge($fieldData);
     $this->assertEquals($masterEntity, $collectionItem1->getEntityStub());
     $this->assertEquals($masterEntity, $collectionItem2->getEntityStub());
 }
 /**
  * @test should accept only REQ sockets
  */
 public function testShouldAcceptOnlyREQSockets()
 {
     $this->socket = $this->getMockBuilder('\\ZMQSocket')->disableOriginalConstructor()->getMock();
     $this->socket->expects($this->any())->method('getSocketType')->will($this->returnValue(\ZMQ::SOCKET_PUSH));
     $this->setExpectedException('\\InvalidArgumentException', 'Invalid socket type');
     new ZeroMQClientTransport($this->socket);
 }
 /**
  * Test constructor and getters
  *
  * @dataProvider constructorAndGettersDataProvider
  */
 public function testConstructorAndGetters($method, $key, $expectedValue)
 {
     $this->builderMock->expects($this->once())->method('getData')->will($this->returnValue([$key => $expectedValue]));
     $attributeMetadata = new AttributeMetadata($this->builderMock);
     $this->assertEquals($expectedValue, $attributeMetadata->{$method}());
 }
Exemplo n.º 5
0
 /**
  * @covers Mage_Testlink_Annotation::endTest
  */
 public function testEndTest()
 {
     $this->_testCaseMock->expects($this->never())->method('getAnnotations');
     $this->_connectorMock->expects($this->never())->method('report');
     $this->assertNull($this->_annotationMock->endTest());
 }