dsgdg54ef4365 2017-10-11 20:41 采纳率: 0%
浏览 115
已采纳

哪个相同或相同到phpunit常量?

I was ask myself Why doesn't exist a method called sameThat inside PHPUNIT constants, the next piece code i want test.

    $user = $this->em->getRepository('AppBundle:User')->findBy(1,1);

Finally this is my test:

    $this->userRepository->expects($this->at(0))
               ->method('findBy')
               ->with(
                    $this->callback(function($arg) use ($test) {
                        $part = 'In the first call to findBy method, the first parameter: ';
                            $test->assertThat($arg, $this->logicalAnd(
                                $this->equalTo(1),
                                $this->isType('integer')
                                ), $part .'it was found issues'
                            );//assertThat
                            return true;
                        }),                         
                    )
                ->willReturn($this->user);

the above example, As you can see, there is two PHPUNIT constants equalTo and isType, both I used it, because equalTo compairs with ==, no ===, so, I change findBy("1",1) instead, the test doesn't fail, so, I added isType constant to be sure, so, the test fail now.

There is an assert called assertSame(), why is there not one equal for PHPUNIT's constants ? for example sameThat or sameTo.

  • 写回答

1条回答 默认 最新

  • douqie1852 2017-10-16 14:44
    关注

    Assuming that you mean "constraint" when you write "constant" then you are looking for identicalTo(). That is the constraint used by assertSame().

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度
  • ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测
  • ¥15 ETLCloud 处理json多层级问题
  • ¥15 matlab中使用gurobi时报错
  • ¥15 这个主板怎么能扩出一两个sata口
  • ¥15 不是,这到底错哪儿了😭
  • ¥15 2020长安杯与连接网探
  • ¥15 关于#matlab#的问题:在模糊控制器中选出线路信息,在simulink中根据线路信息生成速度时间目标曲线(初速度为20m/s,15秒后减为0的速度时间图像)我想问线路信息是什么