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


PHP PHPUnit_Framework_Assert::assertSame方法代码示例

本文整理汇总了PHP中PHPUnit_Framework_Assert::assertSame方法的典型用法代码示例。如果您正苦于以下问题:PHP PHPUnit_Framework_Assert::assertSame方法的具体用法?PHP PHPUnit_Framework_Assert::assertSame怎么用?PHP PHPUnit_Framework_Assert::assertSame使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PHPUnit_Framework_Assert的用法示例。


在下文中一共展示了PHPUnit_Framework_Assert::assertSame方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: testProcessMessage

 /**
  * Check if the message is requeued or not correctly.
  *
  * @dataProvider processMessageProvider
  */
 public function testProcessMessage($processFlag, $expectedMethod, $expectedRequeue = null)
 {
     $amqpConnection = $this->getMockBuilder('\\PhpAmqpLib\\Connection\\AMQPConnection')->disableOriginalConstructor()->getMock();
     $amqpChannel = $this->getMockBuilder('\\PhpAmqpLib\\Channel\\AMQPChannel')->disableOriginalConstructor()->getMock();
     $consumer = new Consumer($amqpConnection, $amqpChannel);
     $callbackFunction = function () use($processFlag) {
         return $processFlag;
     };
     // Create a callback function with a return value set by the data provider.
     $consumer->setCallback($callbackFunction);
     // Create a default message
     $amqpMessage = new AMQPMessage('foo body');
     $amqpMessage->delivery_info['channel'] = $amqpChannel;
     $amqpMessage->delivery_info['delivery_tag'] = 0;
     $amqpChannel->expects($this->any())->method('basic_reject')->will($this->returnCallback(function ($delivery_tag, $requeue) use($expectedMethod, $expectedRequeue) {
         \PHPUnit_Framework_Assert::assertSame($expectedMethod, 'basic_reject');
         // Check if this function should be called.
         \PHPUnit_Framework_Assert::assertSame($requeue, $expectedRequeue);
         // Check if the message should be requeued.
     }));
     $amqpChannel->expects($this->any())->method('basic_ack')->will($this->returnCallback(function ($delivery_tag) use($expectedMethod) {
         \PHPUnit_Framework_Assert::assertSame($expectedMethod, 'basic_ack');
         // Check if this function should be called.
     }));
     $consumer->processMessage($amqpMessage);
 }
开发者ID:sergiuszm,项目名称:RabbitMqBundle,代码行数:31,代码来源:ConsumerTest.php

示例2: testProcessMessage

 /**
  * Check if the message is requeued or not correctly.
  *
  * @dataProvider processMessageProvider
  */
 public function testProcessMessage($processFlag, $expectedMethod, $expectedRequeue = null)
 {
     $amqpConnection = $this->getMockBuilder('\\PhpAmqpLib\\Connection\\AMQPConnection')->disableOriginalConstructor()->getMock();
     $amqpChannel = $this->getMockBuilder('\\PhpAmqpLib\\Channel\\AMQPChannel')->disableOriginalConstructor()->getMock();
     $consumer = new MultipleConsumer($amqpConnection, $amqpChannel);
     $callback = function ($msg) use(&$lastQueue, $processFlag) {
         return $processFlag;
     };
     $consumer->setQueues(array('test-1' => array('callback' => $callback), 'test-2' => array('callback' => $callback)));
     // Create a default message
     $amqpMessage = new AMQPMessage('foo body');
     $amqpMessage->delivery_info['channel'] = $amqpChannel;
     $amqpMessage->delivery_info['delivery_tag'] = 0;
     $amqpChannel->expects($this->any())->method('basic_reject')->will($this->returnCallback(function ($delivery_tag, $requeue) use($expectedMethod, $expectedRequeue) {
         \PHPUnit_Framework_Assert::assertSame($expectedMethod, 'basic_reject');
         // Check if this function should be called.
         \PHPUnit_Framework_Assert::assertSame($requeue, $expectedRequeue);
         // Check if the message should be requeued.
     }));
     $amqpChannel->expects($this->any())->method('basic_ack')->will($this->returnCallback(function ($delivery_tag) use($expectedMethod) {
         \PHPUnit_Framework_Assert::assertSame($expectedMethod, 'basic_ack');
         // Check if this function should be called.
     }));
     $consumer->processQueueMessage('test-1', $amqpMessage);
     $consumer->processQueueMessage('test-2', $amqpMessage);
 }
开发者ID:sergiuszm,项目名称:RabbitMqBundle,代码行数:31,代码来源:MultipleConsumerTest.php

示例3: itInstallsASite

 /**
  * @test
  * @dataProvider eventProvider
  */
 public function itInstallsASite($eventName, LifecycleEvent $event)
 {
     $dispatcher = $this->prophesize('Symfony\\Component\\EventDispatcher\\EventDispatcherInterface');
     $drupal = $this->generateDrupal();
     $processRunner = $this->prophesize('eLife\\IsolatedDrupalBehatExtension\\Process\\ProcessRunner');
     $listener = new InstallSiteListener($dispatcher->reveal(), $drupal, '/path/to/drush', $processRunner->reveal());
     $dispatcher->dispatch(InstallingSite::NAME, Argument::type('eLife\\IsolatedDrupalBehatExtension\\Event\\InstallingSite'))->shouldBeCalledTimes(1)->should(new CallbackPrediction(function (array $calls) use($drupal) {
         /** @var Call $call */
         $call = $calls[0];
         /** @var InstallingSite $event */
         $event = $call->getArguments()[1];
         $process = $event->getCommand()->getProcess();
         Assert::assertSame("'/path/to/drush' 'site-install' 'standard' " . "'--sites-subdir=localhost' '--account-name=admin' " . "'--account-pass=password' '--yes'", $process->getCommandLine());
         Assert::assertArrayHasKey('PHP_OPTIONS', $process->getEnv());
         Assert::assertSame('-d sendmail_path=' . `which true`, $process->getEnv()['PHP_OPTIONS']);
         Assert::assertSame($drupal->getPath(), $process->getWorkingDirectory());
     }));
     $processRunner->run(Argument::type('Symfony\\Component\\Process\\Process'))->shouldBeCalledTimes(1);
     $dispatcher->dispatch(SiteInstalled::NAME, Argument::type('eLife\\IsolatedDrupalBehatExtension\\Event\\SiteInstalled'))->shouldBeCalledTimes(1)->should(new CallbackPrediction(function (array $calls) use($drupal) {
         /** @var Call $call */
         $call = $calls[0];
         /** @var SiteInstalled $event */
         $event = $call->getArguments()[1];
         Assert::assertEquals($drupal, $event->getDrupal());
     }));
     $this->getDispatcher($listener)->dispatch($eventName, $event);
 }
开发者ID:elifesciences,项目名称:isolated-drupal-behat-extension,代码行数:31,代码来源:InstallSiteListenerTest.php

示例4: matches

 /**
  * Tests if an object has the required attributes and they have the correct value.
  *
  * Returns true, if and only if the object defines ALL attributes and they have the expected value
  *
  * @param object $other
  *
  * @return bool
  */
 protected function matches($other)
 {
     $this->result = [];
     $success = true;
     $reflection = new \ReflectionClass($other);
     $properties = $reflection->getDefaultProperties();
     foreach ($this->defaultAttributes as $prop => $value) {
         if (is_int($prop)) {
             $prop = $value;
             $value = null;
         }
         if (array_key_exists($prop, $properties)) {
             try {
                 \PHPUnit_Framework_Assert::assertSame($value, $properties[$prop]);
                 $this->result[$prop] = true;
             } catch (\PHPUnit_Framework_ExpectationFailedException $e) {
                 $message = $e->toString();
                 if ($comparisonFailure = $e->getComparisonFailure()) {
                     $message .= sprintf("\n%30sExpected: %s\n%30sActual  : %s\n", '', $comparisonFailure->getExpectedAsString(), '', $comparisonFailure->getActualAsString());
                 }
                 $this->result[$prop] = $message;
                 $success = false;
             }
         } else {
             $this->result[$prop] = 'Attribute is not defined.';
             $success = false;
         }
     }
     return $success;
 }
开发者ID:cross-solution,项目名称:yawik,代码行数:39,代码来源:DefaultAttributesValues.php

示例5: assertDataPersisted

 /**
  * @inheritdoc
  */
 public function assertDataPersisted($name, array $data)
 {
     $alias = $this->convertNameToAlias($this->singularize($name));
     $class = $this->getEntityManager()->getClassMetadata($alias)->getName();
     $found = [];
     foreach ($data as $row) {
         $criteria = $this->applyMapping($this->getFieldMapping($class), $row);
         $criteria = $this->rowToEntityData($class, $criteria, false);
         $jsonArrayFields = $this->getJsonArrayFields($class, $criteria);
         $criteria = array_diff_key($criteria, $jsonArrayFields);
         $entity = $this->getEntityManager()->getRepository($class)->findOneBy($criteria);
         Assert::assertNotNull($entity, sprintf('The repository should find data of type "%s" with these criteria: %s', $alias, json_encode($criteria)));
         if (!empty($jsonArrayFields)) {
             // refresh json fields as they may have changed beforehand
             $this->getEntityManager()->refresh($entity);
             // json array fields can not be matched by the ORM (depends on driver and requires driver-specific operators),
             // therefore we need to check these separately
             $accessor = PropertyAccess::createPropertyAccessor();
             foreach ($jsonArrayFields as $field => $value) {
                 Assert::assertSame($value, $accessor->getValue($entity, $field));
             }
         }
         $found[] = $entity;
     }
     return $found;
 }
开发者ID:treehouselabs,项目名称:behat-common,代码行数:29,代码来源:DoctrineOrmContext.php

示例6: theResponseCodeShouldBe

 /**
  * @Then /^(?:the )?response code should be (\d+)$/
  */
 public function theResponseCodeShouldBe($code)
 {
     $this->getResponse();
     $expected = intval($code);
     $actual = intval($this->getResponse()->getStatusCode());
     Assertions::assertSame($expected, $actual);
 }
开发者ID:JavierCane,项目名称:mpwar,代码行数:10,代码来源:FeatureContext.php

示例7: testProcessMessage

 /**
  * Check if the message is requeued or not correctly.
  *
  * @dataProvider processMessageProvider
  */
 public function testProcessMessage($processFlag, $expectedMethod, $expectedRequeue = null)
 {
     $amqpConnection = $this->prepareAMQPConnection();
     $amqpChannel = $this->prepareAMQPChannel();
     $consumer = $this->getConsumer($amqpConnection, $amqpChannel);
     $callbackFunction = function () use($processFlag) {
         return $processFlag;
     };
     // Create a callback function with a return value set by the data provider.
     $consumer->setCallback($callbackFunction);
     // Create a default message
     $amqpMessage = new AMQPMessage('foo body');
     $amqpMessage->delivery_info['channel'] = $amqpChannel;
     $amqpMessage->delivery_info['delivery_tag'] = 0;
     $amqpChannel->expects($this->any())->method('basic_reject')->will($this->returnCallback(function ($delivery_tag, $requeue) use($expectedMethod, $expectedRequeue) {
         \PHPUnit_Framework_Assert::assertSame($expectedMethod, 'basic_reject');
         // Check if this function should be called.
         \PHPUnit_Framework_Assert::assertSame($requeue, $expectedRequeue);
         // Check if the message should be requeued.
     }));
     $amqpChannel->expects($this->any())->method('basic_ack')->will($this->returnCallback(function ($delivery_tag) use($expectedMethod) {
         \PHPUnit_Framework_Assert::assertSame($expectedMethod, 'basic_ack');
         // Check if this function should be called.
     }));
     $eventDispatcher = $this->getMockBuilder('Symfony\\Component\\EventDispatcher\\EventDispatcherInterface')->getMock();
     $consumer->setEventDispatcher($eventDispatcher);
     $eventDispatcher->expects($this->atLeastOnce())->method('dispatch')->withConsecutive(array(BeforeProcessingMessageEvent::NAME, new BeforeProcessingMessageEvent($consumer, $amqpMessage)), array(AfterProcessingMessageEvent::NAME, new AfterProcessingMessageEvent($consumer, $amqpMessage)))->willReturn(true);
     $consumer->processMessage($amqpMessage);
 }
开发者ID:danut007ro,项目名称:RabbitMqBundle,代码行数:34,代码来源:ConsumerTest.php

示例8: iRunTheCommand

 /**
  * @When I run the tenanted command :command
  * @When I run the tenanted command :command with options :options
  * @param $command
  * @param $options
  */
 public function iRunTheCommand($command, $options = null)
 {
     $this->actualCommand = $command;
     $tenantedCommand = 'bin/tenant ' . $options . ' ' . PHP_BINARY . ' test/Vivait/TenantBundle/app/console --no-ansi ' . $command;
     $this->process = new Process($tenantedCommand);
     $this->process->run();
     PHPUnit_Framework_Assert::assertSame(0, $this->process->getExitCode(), 'Non zero return code received from command');
 }
开发者ID:kieljohn,项目名称:TenantBundle,代码行数:14,代码来源:CommandContext.php

示例9: testMinify

 /**
  * @covers Minifine\Minifier\Css\MatthiasMullie::__construct
  * @covers Minifine\Minifier\Css\MatthiasMullie::minify
  */
 public function testMinify()
 {
     $mock = $this->getMock('MatthiasMullie\\Minify\\CSS');
     $mock->expects($this->once())->method('add')->will($this->returnCallback(function ($data) {
         \PHPUnit_Framework_Assert::assertSame('passeddata', $data);
     }));
     $mock->expects($this->once())->method('minify')->willReturn('minified');
     $this->assertSame('minified', (new MatthiasMullie($mock))->minify('passeddata'));
 }
开发者ID:peehaa,项目名称:minifine,代码行数:13,代码来源:MatthiasMullieTest.php

示例10: seeInData

 public function seeInData($key, $value = null)
 {
     $data = json_decode($this->lastRequest['body'], true);
     if ($value === null) {
         $this->assertNotEmpty($data[$key]);
     } else {
         \PHPUnit_Framework_Assert::assertSame($value, $data[$key]);
     }
 }
开发者ID:ttsuru,项目名称:mdl_webpay,代码行数:9,代码来源:AcceptanceHelper.php

示例11: it_detects_proper_values_and_constants

 /**
  * @test
  */
 public function it_detects_proper_values_and_constants()
 {
     $enum = new FakeEnum();
     \PHPUnit_Framework_Assert::assertContains('SOME_KEY', $enum->keys());
     \PHPUnit_Framework_Assert::assertArrayHasKey('SOME_KEY', $enum->values());
     \PHPUnit_Framework_Assert::assertArrayNotHasKey('some-value', $enum->values());
     \PHPUnit_Framework_Assert::assertContains('some-value', $enum->values());
     \PHPUnit_Framework_Assert::assertSame('SOME_KEY', $enum->getConstantForValue('some-value'));
     \PHPUnit_Framework_Assert::assertTrue($enum->has('some-value'));
     \PHPUnit_Framework_Assert::assertFalse($enum->has('SOME-VALUE'));
 }
开发者ID:videodock,项目名称:enum,代码行数:14,代码来源:EnumTest.php

示例12: execute

 protected function execute(Middleware $middleware, $command, $expectedNextCommand, $executeResult = null)
 {
     $nextWasCalled = false;
     $middleware->execute($command, function ($nextCommand) use($expectedNextCommand, &$nextWasCalled, $executeResult) {
         \PHPUnit_Framework_Assert::assertSame($expectedNextCommand, $nextCommand);
         $nextWasCalled = true;
         return $executeResult;
     });
     if (!$nextWasCalled) {
         throw new \LogicException('Middleware should have called the next callable.');
     }
 }
开发者ID:boekkooi,项目名称:tactician-amqp,代码行数:12,代码来源:MiddlewareTestCase.php

示例13: anonymousCallback

 /** @test */
 public function anonymousCallback()
 {
     $context = $this->getMock('Superruzafa\\Rules\\Context');
     $flag = 0;
     $callback = function (Context $ctx) use(&$flag, $context) {
         $flag = 1;
         \PHPUnit_Framework_Assert::assertSame($ctx, $context);
         return 2;
     };
     $action = new RunCallback($callback);
     $this->assertEquals(2, $action->perform($context));
     $this->assertEquals(1, $flag);
 }
开发者ID:superruzafa,项目名称:rules,代码行数:14,代码来源:RunCallbackTest.php

示例14: nextShouldExpectAndReturn

 public function nextShouldExpectAndReturn($return, $request, $response)
 {
     $requestExpectation = Argument::that(function ($argument) use($request) {
         Assert::assertSame($request, $argument, 'Request passed to next does not match expectation');
         return true;
     });
     $responseExpectation = Argument::that(function ($argument) use($response) {
         Assert::assertSame($response, $argument, 'Response passed to next does not match expectation');
         return true;
     });
     $next = $this->prophesize(Next::class);
     $next->__invoke($requestExpectation, $responseExpectation)->willReturn($return);
     return $next->reveal();
 }
开发者ID:vrkansagara,项目名称:mwop.net,代码行数:14,代码来源:HttpMessagesTrait.php

示例15: testSendTitledRequest

 public function testSendTitledRequest()
 {
     $guzzleClient = $this->getGuzzleClientMock('{
         "title": "This Ain\'t Game of Thrones XXX",
         "year": "2014",
         "rated": "N/A",
         "released": "14 Apr 2014",
         "runtime": "N/A",
         "genre": "Adult",
         "director": "Axel Braun",
         "writer": "Axel Braun",
         "actors": "Richie Calhoun, Ryan Driller, Scarlett Fay, Alec Knight",
         "plot": "A XXX parody of the epic 2011 high fantasy TV series Game of Thrones.",
         "language": "English",
         "country": "USA",
         "awards": "1 nomination.",
         "poster": "N/A",
         "metascore": "N/A",
         "imdbRating": "3.5",
         "imdbVotes": "42",
         "imdbID": "tt3665102",
         "type": "movie",
         "response": "True"
     }');
     $client = new Client('API_KEY', $guzzleClient);
     $request = new RequestByTitle(new Title('This Ain\'t Game of Thrones XXX'));
     $response = $client->send($request);
     \PHPUnit_Framework_Assert::assertInstanceOf('ClearCode\\OMDB\\Response\\Response', $response);
     \PHPUnit_Framework_Assert::assertSame($response->getTitle(), 'This Ain\'t Game of Thrones XXX');
     \PHPUnit_Framework_Assert::assertSame($response->getYear(), '2014');
     \PHPUnit_Framework_Assert::assertSame($response->getRated(), 'N/A');
     \PHPUnit_Framework_Assert::assertSame($response->getReleased(), '14 Apr 2014');
     \PHPUnit_Framework_Assert::assertSame($response->getRuntime(), 'N/A');
     \PHPUnit_Framework_Assert::assertSame($response->getGenre(), 'Adult');
     \PHPUnit_Framework_Assert::assertSame($response->getDirector(), 'Axel Braun');
     \PHPUnit_Framework_Assert::assertSame($response->getWriter(), 'Axel Braun');
     \PHPUnit_Framework_Assert::assertSame($response->getActors(), 'Richie Calhoun, Ryan Driller, Scarlett Fay, Alec Knight');
     \PHPUnit_Framework_Assert::assertSame($response->getPlot(), 'A XXX parody of the epic 2011 high fantasy TV series Game of Thrones.');
     \PHPUnit_Framework_Assert::assertSame($response->getLanguage(), 'English');
     \PHPUnit_Framework_Assert::assertSame($response->getCountry(), 'USA');
     \PHPUnit_Framework_Assert::assertSame($response->getAwards(), '1 nomination.');
     \PHPUnit_Framework_Assert::assertSame($response->getPoster(), 'N/A');
     \PHPUnit_Framework_Assert::assertSame($response->getMetascore(), 'N/A');
     \PHPUnit_Framework_Assert::assertSame($response->getImdbRating(), '3.5');
     \PHPUnit_Framework_Assert::assertSame($response->getImdbVotes(), '42');
     \PHPUnit_Framework_Assert::assertSame($response->getImdbID(), 'tt3665102');
     \PHPUnit_Framework_Assert::assertSame($response->getType(), 'movie');
     \PHPUnit_Framework_Assert::assertSame($response->getResponse(), 'True');
 }
开发者ID:partikus,项目名称:omdb-client,代码行数:49,代码来源:ClientTest.php


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