How to use bar method of mock class

Best Atoum code snippet using mock.bar

ExpectationTest.php

Source:ExpectationTest.php Github

copy

Full Screen

...69 $this->assertEquals(1, $this->mock->foo());70 }71 public function testSetsPublicPropertyWhenRequested()72 {73 $this->mock->bar = null;74 $this->mock->shouldReceive('foo')->andSet('bar', 'baz');75 $this->assertNull($this->mock->bar);76 $this->mock->foo();77 $this->assertEquals('baz', $this->mock->bar);78 }79 public function testSetsPublicPropertyWhenRequestedUsingAlias()80 {81 $this->mock->bar = null;82 $this->mock->shouldReceive('foo')->set('bar', 'baz');83 $this->assertNull($this->mock->bar);84 $this->mock->foo();85 $this->assertEquals('baz', $this->mock->bar);86 }87 public function testSetsPublicPropertiesWhenRequested()88 {89 $this->mock->bar = null;90 $this->mock->shouldReceive('foo')->andSet('bar', 'baz', 'bazz', 'bazzz');91 $this->assertNull($this->mock->bar);92 $this->mock->foo();93 $this->assertEquals('baz', $this->mock->bar);94 $this->mock->foo();95 $this->assertEquals('bazz', $this->mock->bar);96 $this->mock->foo();97 $this->assertEquals('bazzz', $this->mock->bar);98 }99 public function testSetsPublicPropertiesWhenRequestedUsingAlias()100 {101 $this->mock->bar = null;102 $this->mock->shouldReceive('foo')->set('bar', 'baz', 'bazz', 'bazzz');103 $this->assertAttributeEmpty('bar', $this->mock);104 $this->mock->foo();105 $this->assertEquals('baz', $this->mock->bar);106 $this->mock->foo();107 $this->assertEquals('bazz', $this->mock->bar);108 $this->mock->foo();109 $this->assertEquals('bazzz', $this->mock->bar);110 }111 112 public function testSetsPublicPropertiesWhenRequestedMoreTimesThanSetValues()113 {114 $this->mock->bar = null;115 $this->mock->shouldReceive('foo')->andSet('bar', 'baz', 'bazz');116 $this->assertNull($this->mock->bar);117 $this->mock->foo();118 $this->assertEquals('baz', $this->mock->bar);119 $this->mock->foo();120 $this->assertEquals('bazz', $this->mock->bar);121 $this->mock->foo();122 $this->assertEquals('bazz', $this->mock->bar);123 }124 public function testSetsPublicPropertiesWhenRequestedMoreTimesThanSetValuesUsingAlias()125 {126 $this->mock->bar = null;127 $this->mock->shouldReceive('foo')->andSet('bar', 'baz', 'bazz');128 $this->assertNull($this->mock->bar);129 $this->mock->foo();130 $this->assertEquals('baz', $this->mock->bar);131 $this->mock->foo();132 $this->assertEquals('bazz', $this->mock->bar);133 $this->mock->foo();134 $this->assertEquals('bazz', $this->mock->bar);135 }136 public function testSetsPublicPropertiesWhenRequestedMoreTimesThanSetValuesWithDirectSet()137 {138 $this->mock->bar = null;139 $this->mock->shouldReceive('foo')->andSet('bar', 'baz', 'bazz');140 $this->assertNull($this->mock->bar);141 $this->mock->foo();142 $this->assertEquals('baz', $this->mock->bar);143 $this->mock->foo();144 $this->assertEquals('bazz', $this->mock->bar);145 $this->mock->bar = null;146 $this->mock->foo();147 $this->assertNull($this->mock->bar);148 }149 public function testSetsPublicPropertiesWhenRequestedMoreTimesThanSetValuesWithDirectSetUsingAlias()150 {151 $this->mock->bar = null;152 $this->mock->shouldReceive('foo')->set('bar', 'baz', 'bazz');153 $this->assertNull($this->mock->bar);154 $this->mock->foo();155 $this->assertEquals('baz', $this->mock->bar);156 $this->mock->foo();157 $this->assertEquals('bazz', $this->mock->bar);158 $this->mock->bar = null;159 $this->mock->foo();160 $this->assertNull($this->mock->bar);161 }162 public function testReturnsSameValueForAllIfNoArgsExpectationAndSomeGiven()163 {164 $this->mock->shouldReceive('foo')->andReturn(1);165 $this->assertEquals(1, $this->mock->foo('foo'));166 }167 public function testReturnsValueFromSequenceSequentially()168 {169 $this->mock->shouldReceive('foo')->andReturn(1, 2, 3);170 $this->mock->foo('foo');171 $this->assertEquals(2, $this->mock->foo('foo'));172 }173 public function testReturnsValueFromSequenceSequentiallyAndRepeatedlyReturnsFinalValueOnExtraCalls()174 {175 $this->mock->shouldReceive('foo')->andReturn(1, 2, 3);176 $this->mock->foo('foo');177 $this->mock->foo('foo');178 $this->assertEquals(3, $this->mock->foo('foo'));179 $this->assertEquals(3, $this->mock->foo('foo'));180 }181 public function testReturnsValueFromSequenceSequentiallyAndRepeatedlyReturnsFinalValueOnExtraCallsWithManyAndReturnCalls()182 {183 $this->mock->shouldReceive('foo')->andReturn(1)->andReturn(2, 3);184 $this->mock->foo('foo');185 $this->mock->foo('foo');186 $this->assertEquals(3, $this->mock->foo('foo'));187 $this->assertEquals(3, $this->mock->foo('foo'));188 }189 public function testReturnsValueOfClosure()190 {191 $this->mock->shouldReceive('foo')->with(5)->andReturnUsing(function ($v) {return $v+1;});192 $this->assertEquals(6, $this->mock->foo(5));193 }194 public function testReturnsUndefined()195 {196 $this->mock->shouldReceive('foo')->andReturnUndefined();197 $this->assertTrue($this->mock->foo() instanceof \Mockery\Undefined);198 }199 public function testReturnsValuesSetAsArray()200 {201 $this->mock->shouldReceive('foo')->andReturnValues(array(1, 2, 3));202 $this->assertEquals(1, $this->mock->foo());203 $this->assertEquals(2, $this->mock->foo());204 $this->assertEquals(3, $this->mock->foo());205 }206 /**207 * @expectedException OutOfBoundsException208 */209 public function testThrowsException()210 {211 $this->mock->shouldReceive('foo')->andThrow(new OutOfBoundsException);212 $this->mock->foo();213 }214 /**215 * @expectedException OutOfBoundsException216 */217 public function testThrowsExceptionBasedOnArgs()218 {219 $this->mock->shouldReceive('foo')->andThrow('OutOfBoundsException');220 $this->mock->foo();221 }222 public function testThrowsExceptionBasedOnArgsWithMessage()223 {224 $this->mock->shouldReceive('foo')->andThrow('OutOfBoundsException', 'foo');225 try {226 $this->mock->foo();227 } catch (OutOfBoundsException $e) {228 $this->assertEquals('foo', $e->getMessage());229 }230 }231 /**232 * @expectedException OutOfBoundsException233 */234 public function testThrowsExceptionSequentially()235 {236 $this->mock->shouldReceive('foo')->andThrow(new Exception)->andThrow(new OutOfBoundsException);237 try {238 $this->mock->foo();239 } catch (Exception $e) {240 }241 $this->mock->foo();242 }243 public function testAndThrowExceptions()244 {245 $this->mock->shouldReceive('foo')->andThrowExceptions(array(246 new OutOfBoundsException,247 new InvalidArgumentException,248 ));249 try {250 $this->mock->foo();251 throw new Exception("Expected OutOfBoundsException, non thrown");252 } catch (\Exception $e) {253 $this->assertInstanceOf("OutOfBoundsException", $e, "Wrong or no exception thrown: {$e->getMessage()}");254 }255 try {256 $this->mock->foo();257 throw new Exception("Expected InvalidArgumentException, non thrown");258 } catch (\Exception $e) {259 $this->assertInstanceOf("InvalidArgumentException", $e, "Wrong or no exception thrown: {$e->getMessage()}");260 }261 }262 /**263 * @expectedException Mockery\Exception264 * @expectedExceptionMessage You must pass an array of exception objects to andThrowExceptions265 */266 public function testAndThrowExceptionsCatchNonExceptionArgument()267 {268 $this->mock269 ->shouldReceive('foo')270 ->andThrowExceptions(array('NotAnException'));271 }272 public function testMultipleExpectationsWithReturns()273 {274 $this->mock->shouldReceive('foo')->with(1)->andReturn(10);275 $this->mock->shouldReceive('bar')->with(2)->andReturn(20);276 $this->assertEquals(10, $this->mock->foo(1));277 $this->assertEquals(20, $this->mock->bar(2));278 }279 public function testExpectsNoArguments()280 {281 $this->mock->shouldReceive('foo')->withNoArgs();282 $this->mock->foo();283 }284 /**285 * @expectedException \Mockery\Exception286 */287 public function testExpectsNoArgumentsThrowsExceptionIfAnyPassed()288 {289 $this->mock->shouldReceive('foo')->withNoArgs();290 $this->mock->foo(1);291 }292 public function testExpectsArgumentsArray()293 {294 $this->mock->shouldReceive('foo')->withArgs(array(1, 2));295 $this->mock->foo(1, 2);296 }297 /**298 * @expectedException \Mockery\Exception299 */300 public function testExpectsArgumentsArrayThrowsExceptionIfPassedEmptyArray()301 {302 $this->mock->shouldReceive('foo')->withArgs(array());303 $this->mock->foo(1, 2);304 }305 /**306 * @expectedException \Mockery\Exception307 */308 public function testExpectsArgumentsArrayThrowsExceptionIfNoArgumentsPassed()309 {310 $this->mock->shouldReceive('foo')->with();311 $this->mock->foo(1);312 }313 /**314 * @expectedException \Mockery\Exception315 */316 public function testExpectsArgumentsArrayThrowsExceptionIfPassedWrongArguments()317 {318 $this->mock->shouldReceive('foo')->withArgs(array(1, 2));319 $this->mock->foo(3, 4);320 }321 /**322 * @expectedException \Mockery\Exception323 * @expectedExceptionMessageRegExp /foo\(NULL\)/324 */325 public function testExpectsStringArgumentExceptionMessageDifferentiatesBetweenNullAndEmptyString()326 {327 $this->mock->shouldReceive('foo')->withArgs(array('a string'));328 $this->mock->foo(null);329 }330 public function testExpectsAnyArguments()331 {332 $this->mock->shouldReceive('foo')->withAnyArgs();333 $this->mock->foo();334 $this->mock->foo(1);335 $this->mock->foo(1, 'k', new stdClass);336 }337 public function testExpectsArgumentMatchingRegularExpression()338 {339 $this->mock->shouldReceive('foo')->with('/bar/i');340 $this->mock->foo('xxBARxx');341 }342 public function testExpectsArgumentMatchingObjectType()343 {344 $this->mock->shouldReceive('foo')->with('\stdClass');345 $this->mock->foo(new stdClass);346 }347 /**348 * @expectedException \Mockery\Exception349 */350 public function testThrowsExceptionOnNoArgumentMatch()351 {352 $this->mock->shouldReceive('foo')->with(1);353 $this->mock->foo(2);354 }355 public function testNeverCalled()356 {357 $this->mock->shouldReceive('foo')->never();358 $this->container->mockery_verify();359 }360 public function testShouldNotReceive()361 {362 $this->mock->shouldNotReceive('foo');363 $this->container->mockery_verify();364 }365 /**366 * @expectedException \Mockery\Exception\InvalidCountException367 */368 public function testShouldNotReceiveThrowsExceptionIfMethodCalled()369 {370 $this->mock->shouldNotReceive('foo');371 $this->mock->foo();372 $this->container->mockery_verify();373 }374 /**375 * @expectedException \Mockery\Exception\InvalidCountException376 */377 public function testShouldNotReceiveWithArgumentThrowsExceptionIfMethodCalled()378 {379 $this->mock->shouldNotReceive('foo')->with(2);380 $this->mock->foo(2);381 $this->container->mockery_verify();382 }383 /**384 * @expectedException \Mockery\CountValidator\Exception385 */386 public function testNeverCalledThrowsExceptionOnCall()387 {388 $this->mock->shouldReceive('foo')->never();389 $this->mock->foo();390 $this->container->mockery_verify();391 }392 public function testCalledOnce()393 {394 $this->mock->shouldReceive('foo')->once();395 $this->mock->foo();396 $this->container->mockery_verify();397 }398 /**399 * @expectedException \Mockery\CountValidator\Exception400 */401 public function testCalledOnceThrowsExceptionIfNotCalled()402 {403 $this->mock->shouldReceive('foo')->once();404 $this->container->mockery_verify();405 }406 /**407 * @expectedException \Mockery\CountValidator\Exception408 */409 public function testCalledOnceThrowsExceptionIfCalledTwice()410 {411 $this->mock->shouldReceive('foo')->once();412 $this->mock->foo();413 $this->mock->foo();414 $this->container->mockery_verify();415 }416 public function testCalledTwice()417 {418 $this->mock->shouldReceive('foo')->twice();419 $this->mock->foo();420 $this->mock->foo();421 $this->container->mockery_verify();422 }423 /**424 * @expectedException \Mockery\CountValidator\Exception425 */426 public function testCalledTwiceThrowsExceptionIfNotCalled()427 {428 $this->mock->shouldReceive('foo')->twice();429 $this->container->mockery_verify();430 }431 /**432 * @expectedException \Mockery\CountValidator\Exception433 */434 public function testCalledOnceThrowsExceptionIfCalledThreeTimes()435 {436 $this->mock->shouldReceive('foo')->twice();437 $this->mock->foo();438 $this->mock->foo();439 $this->mock->foo();440 $this->container->mockery_verify();441 }442 public function testCalledZeroOrMoreTimesAtZeroCalls()443 {444 $this->mock->shouldReceive('foo')->zeroOrMoreTimes();445 $this->container->mockery_verify();446 }447 public function testCalledZeroOrMoreTimesAtThreeCalls()448 {449 $this->mock->shouldReceive('foo')->zeroOrMoreTimes();450 $this->mock->foo();451 $this->mock->foo();452 $this->mock->foo();453 $this->container->mockery_verify();454 }455 public function testTimesCountCalls()456 {457 $this->mock->shouldReceive('foo')->times(4);458 $this->mock->foo();459 $this->mock->foo();460 $this->mock->foo();461 $this->mock->foo();462 $this->container->mockery_verify();463 }464 /**465 * @expectedException \Mockery\CountValidator\Exception466 */467 public function testTimesCountCallThrowsExceptionOnTooFewCalls()468 {469 $this->mock->shouldReceive('foo')->times(2);470 $this->mock->foo();471 $this->container->mockery_verify();472 }473 /**474 * @expectedException \Mockery\CountValidator\Exception475 */476 public function testTimesCountCallThrowsExceptionOnTooManyCalls()477 {478 $this->mock->shouldReceive('foo')->times(2);479 $this->mock->foo();480 $this->mock->foo();481 $this->mock->foo();482 $this->container->mockery_verify();483 }484 public function testCalledAtLeastOnceAtExactlyOneCall()485 {486 $this->mock->shouldReceive('foo')->atLeast()->once();487 $this->mock->foo();488 $this->container->mockery_verify();489 }490 public function testCalledAtLeastOnceAtExactlyThreeCalls()491 {492 $this->mock->shouldReceive('foo')->atLeast()->times(3);493 $this->mock->foo();494 $this->mock->foo();495 $this->mock->foo();496 $this->container->mockery_verify();497 }498 /**499 * @expectedException \Mockery\CountValidator\Exception500 */501 public function testCalledAtLeastThrowsExceptionOnTooFewCalls()502 {503 $this->mock->shouldReceive('foo')->atLeast()->twice();504 $this->mock->foo();505 $this->container->mockery_verify();506 }507 public function testCalledAtMostOnceAtExactlyOneCall()508 {509 $this->mock->shouldReceive('foo')->atMost()->once();510 $this->mock->foo();511 $this->container->mockery_verify();512 }513 public function testCalledAtMostAtExactlyThreeCalls()514 {515 $this->mock->shouldReceive('foo')->atMost()->times(3);516 $this->mock->foo();517 $this->mock->foo();518 $this->mock->foo();519 $this->container->mockery_verify();520 }521 /**522 * @expectedException \Mockery\CountValidator\Exception523 */524 public function testCalledAtLeastThrowsExceptionOnTooManyCalls()525 {526 $this->mock->shouldReceive('foo')->atMost()->twice();527 $this->mock->foo();528 $this->mock->foo();529 $this->mock->foo();530 $this->container->mockery_verify();531 }532 /**533 * @expectedException \Mockery\CountValidator\Exception534 */535 public function testExactCountersOverrideAnyPriorSetNonExactCounters()536 {537 $this->mock->shouldReceive('foo')->atLeast()->once()->once();538 $this->mock->foo();539 $this->mock->foo();540 $this->container->mockery_verify();541 }542 public function testComboOfLeastAndMostCallsWithOneCall()543 {544 $this->mock->shouldReceive('foo')->atleast()->once()->atMost()->twice();545 $this->mock->foo();546 $this->container->mockery_verify();547 }548 public function testComboOfLeastAndMostCallsWithTwoCalls()549 {550 $this->mock->shouldReceive('foo')->atleast()->once()->atMost()->twice();551 $this->mock->foo();552 $this->mock->foo();553 $this->container->mockery_verify();554 }555 /**556 * @expectedException \Mockery\CountValidator\Exception557 */558 public function testComboOfLeastAndMostCallsThrowsExceptionAtTooFewCalls()559 {560 $this->mock->shouldReceive('foo')->atleast()->once()->atMost()->twice();561 $this->container->mockery_verify();562 }563 /**564 * @expectedException \Mockery\CountValidator\Exception565 */566 public function testComboOfLeastAndMostCallsThrowsExceptionAtTooManyCalls()567 {568 $this->mock->shouldReceive('foo')->atleast()->once()->atMost()->twice();569 $this->mock->foo();570 $this->mock->foo();571 $this->mock->foo();572 $this->container->mockery_verify();573 }574 public function testCallCountingOnlyAppliesToMatchedExpectations()575 {576 $this->mock->shouldReceive('foo')->with(1)->once();577 $this->mock->shouldReceive('foo')->with(2)->twice();578 $this->mock->shouldReceive('foo')->with(3);579 $this->mock->foo(1);580 $this->mock->foo(2);581 $this->mock->foo(2);582 $this->mock->foo(3);583 $this->container->mockery_verify();584 }585 /**586 * @expectedException \Mockery\CountValidator\Exception587 */588 public function testCallCountingThrowsExceptionOnAnyMismatch()589 {590 $this->mock->shouldReceive('foo')->with(1)->once();591 $this->mock->shouldReceive('foo')->with(2)->twice();592 $this->mock->shouldReceive('foo')->with(3);593 $this->mock->shouldReceive('bar');594 $this->mock->foo(1);595 $this->mock->foo(2);596 $this->mock->foo(3);597 $this->mock->bar();598 $this->container->mockery_verify();599 }600 public function testOrderedCallsWithoutError()601 {602 $this->mock->shouldReceive('foo')->ordered();603 $this->mock->shouldReceive('bar')->ordered();604 $this->mock->foo();605 $this->mock->bar();606 $this->container->mockery_verify();607 }608 /**609 * @expectedException \Mockery\Exception610 */611 public function testOrderedCallsWithOutOfOrderError()612 {613 $this->mock->shouldReceive('foo')->ordered();614 $this->mock->shouldReceive('bar')->ordered();615 $this->mock->bar();616 $this->mock->foo();617 $this->container->mockery_verify();618 }619 public function testDifferentArgumentsAndOrderingsPassWithoutException()620 {621 $this->mock->shouldReceive('foo')->with(1)->ordered();622 $this->mock->shouldReceive('foo')->with(2)->ordered();623 $this->mock->foo(1);624 $this->mock->foo(2);625 $this->container->mockery_verify();626 }627 /**628 * @expectedException \Mockery\Exception629 */630 public function testDifferentArgumentsAndOrderingsThrowExceptionWhenInWrongOrder()631 {632 $this->mock->shouldReceive('foo')->with(1)->ordered();633 $this->mock->shouldReceive('foo')->with(2)->ordered();634 $this->mock->foo(2);635 $this->mock->foo(1);636 $this->container->mockery_verify();637 }638 public function testUnorderedCallsIgnoredForOrdering()639 {640 $this->mock->shouldReceive('foo')->with(1)->ordered();641 $this->mock->shouldReceive('foo')->with(2);642 $this->mock->shouldReceive('foo')->with(3)->ordered();643 $this->mock->foo(2);644 $this->mock->foo(1);645 $this->mock->foo(2);646 $this->mock->foo(3);647 $this->mock->foo(2);648 $this->container->mockery_verify();649 }650 public function testOrderingOfDefaultGrouping()651 {652 $this->mock->shouldReceive('foo')->ordered();653 $this->mock->shouldReceive('bar')->ordered();654 $this->mock->foo();655 $this->mock->bar();656 $this->container->mockery_verify();657 }658 /**659 * @expectedException \Mockery\Exception660 */661 public function testOrderingOfDefaultGroupingThrowsExceptionOnWrongOrder()662 {663 $this->mock->shouldReceive('foo')->ordered();664 $this->mock->shouldReceive('bar')->ordered();665 $this->mock->bar();666 $this->mock->foo();667 $this->container->mockery_verify();668 }669 public function testOrderingUsingNumberedGroups()670 {671 $this->mock->shouldReceive('start')->ordered(1);672 $this->mock->shouldReceive('foo')->ordered(2);673 $this->mock->shouldReceive('bar')->ordered(2);674 $this->mock->shouldReceive('final')->ordered();675 $this->mock->start();676 $this->mock->bar();677 $this->mock->foo();678 $this->mock->bar();679 $this->mock->final();680 $this->container->mockery_verify();681 }682 public function testOrderingUsingNamedGroups()683 {684 $this->mock->shouldReceive('start')->ordered('start');685 $this->mock->shouldReceive('foo')->ordered('foobar');686 $this->mock->shouldReceive('bar')->ordered('foobar');687 $this->mock->shouldReceive('final')->ordered();688 $this->mock->start();689 $this->mock->bar();690 $this->mock->foo();691 $this->mock->bar();692 $this->mock->final();693 $this->container->mockery_verify();694 }695 /**696 * @group 2A697 */698 public function testGroupedUngroupedOrderingDoNotOverlap()699 {700 $s = $this->mock->shouldReceive('start')->ordered();701 $m = $this->mock->shouldReceive('mid')->ordered('foobar');702 $e = $this->mock->shouldReceive('end')->ordered();703 $this->assertTrue($s->getOrderNumber() < $m->getOrderNumber());704 $this->assertTrue($m->getOrderNumber() < $e->getOrderNumber());705 }706 /**707 * @expectedException \Mockery\Exception708 */709 public function testGroupedOrderingThrowsExceptionWhenCallsDisordered()710 {711 $this->mock->shouldReceive('foo')->ordered('first');712 $this->mock->shouldReceive('bar')->ordered('second');713 $this->mock->bar();714 $this->mock->foo();715 $this->container->mockery_verify();716 }717 public function testExpectationMatchingWithNoArgsOrderings()718 {719 $this->mock->shouldReceive('foo')->withNoArgs()->once()->ordered();720 $this->mock->shouldReceive('bar')->withNoArgs()->once()->ordered();721 $this->mock->shouldReceive('foo')->withNoArgs()->once()->ordered();722 $this->mock->foo();723 $this->mock->bar();724 $this->mock->foo();725 $this->container->mockery_verify();726 }727 public function testExpectationMatchingWithAnyArgsOrderings()728 {729 $this->mock->shouldReceive('foo')->withAnyArgs()->once()->ordered();730 $this->mock->shouldReceive('bar')->withAnyArgs()->once()->ordered();731 $this->mock->shouldReceive('foo')->withAnyArgs()->once()->ordered();732 $this->mock->foo();733 $this->mock->bar();734 $this->mock->foo();735 $this->container->mockery_verify();736 }737 public function testEnsuresOrderingIsNotCrossMockByDefault()738 {739 $this->mock->shouldReceive('foo')->ordered();740 $mock2 = $this->container->mock('bar');741 $mock2->shouldReceive('bar')->ordered();742 $mock2->bar();743 $this->mock->foo();744 }745 /**746 * @expectedException \Mockery\Exception747 */748 public function testEnsuresOrderingIsCrossMockWhenGloballyFlagSet()749 {750 $this->mock->shouldReceive('foo')->globally()->ordered();751 $mock2 = $this->container->mock('bar');752 $mock2->shouldReceive('bar')->globally()->ordered();753 $mock2->bar();754 $this->mock->foo();755 }756 public function testExpectationCastToStringFormatting()757 {758 $exp = $this->mock->shouldReceive('foo')->with(1, 'bar', new stdClass, array('Spam' => 'Ham', 'Bar' => 'Baz'));759 $this->assertEquals('[foo(1, "bar", object(stdClass), array(\'Spam\'=>\'Ham\',\'Bar\'=>\'Baz\',))]', (string) $exp);760 }761 public function testLongExpectationCastToStringFormatting()762 {763 $exp = $this->mock->shouldReceive('foo')->with(array('Spam' => 'Ham', 'Bar' => 'Baz', 'Bar', 'Baz', 'Bar', 'Baz', 'Bar', 'Baz', 'Bar', 'Baz', 'Bar', 'Baz', 'Bar', 'Baz', 'Bar', 'Baz', 'Bar', 'Baz', 'Bar', 'Baz', 'Bar', 'Baz', 'Bar', 'Baz', 'Bar', 'Baz', 'Bar', 'Baz', 'Bar', 'Baz', 'Bar', 'Baz', 'Bar', 'Baz', 'Bar', 'Baz', 'Bar', 'Baz', 'Bar', 'Baz', 'Bar', 'Baz', 'Bar', 'Baz', 'Bar', 'Baz', 'Bar', 'Baz', 'Baz', 'Bar', 'Baz', 'Bar', 'Baz', 'Bar', 'Baz', 'Bar', 'Baz', 'Bar', 'Baz', 'Baz', 'Bar', 'Baz', 'Bar', 'Baz', 'Bar', 'Baz', 'Bar', 'Baz', 'Bar', 'Baz', 'Baz', 'Bar', 'Baz', 'Bar', 'Baz', 'Bar', 'Baz', 'Bar', 'Baz', 'Bar', 'Baz', 'Baz', 'Bar', 'Baz', 'Bar', 'Baz', 'Bar', 'Baz', 'Bar', 'Baz', 'Bar', 'Baz', 'Baz', 'Bar', 'Baz', 'Bar', 'Baz', 'Bar', 'Baz', 'Bar', 'Baz', 'Bar', 'Baz', 'Baz', 'Bar', 'Baz', 'Bar', 'Baz', 'Bar', 'Baz', 'Bar', 'Baz', 'Bar', 'Baz', 'Baz', 'Bar', 'Baz', 'Bar', 'Baz', 'Bar', 'Baz', 'Bar', 'Baz', 'Bar', 'Baz', 'Baz', 'Bar', 'Baz', 'Bar', 'Baz', 'Bar', 'Baz', 'Bar', 'Baz', 'Bar', 'Baz', 'Baz', 'Bar', 'Baz', 'Bar', 'Baz', 'Bar', 'Baz', 'Bar', 'Baz', 'Bar', 'Baz', 'End'));764 $this->assertEquals("[foo(array('Spam'=>'Ham','Bar'=>'Baz',0=>'Bar',1=>'Baz',2=>'Bar',3=>'Baz',4=>'Bar',5=>'Baz',6=>'Bar',7=>'Baz',8=>'Bar',9=>'Baz',10=>'Bar',11=>'Baz',12=>'Bar',13=>'Baz',14=>'Bar',15=>'Baz',16=>'Bar',17=>'Baz',18=>'Bar',19=>'Baz',20=>'Bar',21=>'Baz',22=>'Bar',23=>'Baz',24=>'Bar',25=>'Baz',26=>'Bar',27=>'Baz',28=>'Bar',29=>'Baz',30=>'Bar',31=>'Baz',32=>'Bar',33=>'Baz',34=>'Bar',35=>'Baz',36=>'Bar',37=>'Baz',38=>'Bar',39=>'Baz',40=>'Bar',41=>'Baz',42=>'Bar',43=>'Baz',44=>'Bar',45=>'Baz',46=>'Baz',47=>'Bar',48=>'Baz',49=>'Bar',50=>'Baz',51=>'Bar',52=>'Baz',53=>'Bar',54=>'Baz',55=>'Bar',56=>'Baz',57=>'Baz',58=>'Bar',59=>'Baz',60=>'Bar',61=>'Baz',62=>'Bar',63=>'Baz',64=>'Bar',65=>'Baz',66=>'Bar',67=>'Baz',68=>'Baz',69=>'Bar',70=>'Baz',71=>'Bar',72=>'Baz',73=>'Bar',74=>'Baz',75=>'Bar',76=>'Baz',77=>'Bar',78=>'Baz',79=>'Baz',80=>'Bar',81=>'Baz',82=>'Bar',83=>'Baz',84=>'Bar',85=>'Baz',86=>'Bar',87=>'Baz',88=>'Bar',89=>'Baz',90=>'Baz',91=>'Bar',92=>'Baz',93=>'Bar',94=>'Baz',95=>'Bar',96=>'Baz',97=>'Ba...))]", (string) $exp);765 }766 public function testMultipleExpectationCastToStringFormatting()767 {768 $exp = $this->mock->shouldReceive('foo', 'bar')->with(1);769 $this->assertEquals('[foo(1), bar(1)]', (string) $exp);770 }771 public function testGroupedOrderingWithLimitsAllowsMultipleReturnValues()772 {773 $this->mock->shouldReceive('foo')->with(2)->once()->andReturn('first');774 $this->mock->shouldReceive('foo')->with(2)->twice()->andReturn('second/third');775 $this->mock->shouldReceive('foo')->with(2)->andReturn('infinity');776 $this->assertEquals('first', $this->mock->foo(2));777 $this->assertEquals('second/third', $this->mock->foo(2));778 $this->assertEquals('second/third', $this->mock->foo(2));779 $this->assertEquals('infinity', $this->mock->foo(2));780 $this->assertEquals('infinity', $this->mock->foo(2));781 $this->assertEquals('infinity', $this->mock->foo(2));782 $this->container->mockery_verify();783 }784 public function testExpectationsCanBeMarkedAsDefaults()785 {786 $this->mock->shouldReceive('foo')->andReturn('bar')->byDefault();787 $this->assertEquals('bar', $this->mock->foo());788 $this->container->mockery_verify();789 }790 public function testDefaultExpectationsValidatedInCorrectOrder()791 {792 $this->mock->shouldReceive('foo')->with(1)->once()->andReturn('first')->byDefault();793 $this->mock->shouldReceive('foo')->with(2)->once()->andReturn('second')->byDefault();794 $this->assertEquals('first', $this->mock->foo(1));795 $this->assertEquals('second', $this->mock->foo(2));796 $this->container->mockery_verify();797 }798 public function testDefaultExpectationsAreReplacedByLaterConcreteExpectations()799 {800 $this->mock->shouldReceive('foo')->andReturn('bar')->once()->byDefault();801 $this->mock->shouldReceive('foo')->andReturn('bar')->twice();802 $this->mock->foo();803 $this->mock->foo();804 $this->container->mockery_verify();805 }806 public function testDefaultExpectationsCanBeChangedByLaterExpectations()807 {808 $this->mock->shouldReceive('foo')->with(1)->andReturn('bar')->once()->byDefault();809 $this->mock->shouldReceive('foo')->with(2)->andReturn('baz')->once();810 try {811 $this->mock->foo(1);812 $this->fail('Expected exception not thrown');813 } catch (\Mockery\Exception $e) {814 }815 $this->mock->foo(2);816 $this->container->mockery_verify();817 }818 /**819 * @expectedException \Mockery\Exception820 */821 public function testDefaultExpectationsCanBeOrdered()822 {823 $this->mock->shouldReceive('foo')->ordered()->byDefault();824 $this->mock->shouldReceive('bar')->ordered()->byDefault();825 $this->mock->bar();826 $this->mock->foo();827 $this->container->mockery_verify();828 }829 public function testDefaultExpectationsCanBeOrderedAndReplaced()830 {831 $this->mock->shouldReceive('foo')->ordered()->byDefault();832 $this->mock->shouldReceive('bar')->ordered()->byDefault();833 $this->mock->shouldReceive('bar')->ordered();834 $this->mock->shouldReceive('foo')->ordered();835 $this->mock->bar();836 $this->mock->foo();837 $this->container->mockery_verify();838 }839 public function testByDefaultOperatesFromMockConstruction()840 {841 $container = new \Mockery\Container(\Mockery::getDefaultGenerator(), \Mockery::getDefaultLoader());842 $mock = $container->mock('f', array('foo'=>'rfoo', 'bar'=>'rbar', 'baz'=>'rbaz'))->byDefault();843 $mock->shouldReceive('foo')->andReturn('foobar');844 $this->assertEquals('foobar', $mock->foo());845 $this->assertEquals('rbar', $mock->bar());846 $this->assertEquals('rbaz', $mock->baz());847 $mock->mockery_verify();848 }849 public function testByDefaultOnAMockDoesSquatWithoutExpectations()850 {851 $container = new \Mockery\Container(\Mockery::getDefaultGenerator(), \Mockery::getDefaultLoader());852 $mock = $container->mock('f')->byDefault();853 }854 public function testDefaultExpectationsCanBeOverridden()855 {856 $this->mock->shouldReceive('foo')->with('test')->andReturn('bar')->byDefault();857 $this->mock->shouldReceive('foo')->with('test')->andReturn('newbar')->byDefault();858 $this->mock->foo('test');859 $this->assertEquals('newbar', $this->mock->foo('test'));860 }861 /**862 * @expectedException \Mockery\Exception863 */864 public function testByDefaultPreventedFromSettingDefaultWhenDefaultingExpectationWasReplaced()865 {866 $exp = $this->mock->shouldReceive('foo')->andReturn(1);867 $this->mock->shouldReceive('foo')->andReturn(2);868 $exp->byDefault();869 }870 /**871 * Argument Constraint Tests872 */873 public function testAnyConstraintMatchesAnyArg()874 {875 $this->mock->shouldReceive('foo')->with(1, Mockery::any())->twice();876 $this->mock->foo(1, 2);877 $this->mock->foo(1, 'str');878 $this->container->mockery_verify();879 }880 public function testAnyConstraintNonMatchingCase()881 {882 $this->mock->shouldReceive('foo')->times(3);883 $this->mock->shouldReceive('foo')->with(1, Mockery::any())->never();884 $this->mock->foo();885 $this->mock->foo(1);886 $this->mock->foo(1, 2, 3);887 $this->container->mockery_verify();888 }889 public function testArrayConstraintMatchesArgument()890 {891 $this->mock->shouldReceive('foo')->with(Mockery::type('array'))->once();892 $this->mock->foo(array());893 $this->container->mockery_verify();894 }895 public function testArrayConstraintNonMatchingCase()896 {897 $this->mock->shouldReceive('foo')->times(3);898 $this->mock->shouldReceive('foo')->with(1, Mockery::type('array'))->never();899 $this->mock->foo();900 $this->mock->foo(1);901 $this->mock->foo(1, 2, 3);902 $this->container->mockery_verify();903 }904 /**905 * @expectedException \Mockery\Exception906 */907 public function testArrayConstraintThrowsExceptionWhenConstraintUnmatched()908 {909 $this->mock->shouldReceive('foo')->with(Mockery::type('array'))->once();910 $this->mock->foo(1);911 $this->container->mockery_verify();912 }913 public function testBoolConstraintMatchesArgument()914 {915 $this->mock->shouldReceive('foo')->with(Mockery::type('bool'))->once();916 $this->mock->foo(true);917 $this->container->mockery_verify();918 }919 public function testBoolConstraintNonMatchingCase()920 {921 $this->mock->shouldReceive('foo')->times(3);922 $this->mock->shouldReceive('foo')->with(1, Mockery::type('bool'))->never();923 $this->mock->foo();924 $this->mock->foo(1);925 $this->mock->foo(1, 2, 3);926 $this->container->mockery_verify();927 }928 /**929 * @expectedException \Mockery\Exception930 */931 public function testBoolConstraintThrowsExceptionWhenConstraintUnmatched()932 {933 $this->mock->shouldReceive('foo')->with(Mockery::type('bool'))->once();934 $this->mock->foo(1);935 $this->container->mockery_verify();936 }937 public function testCallableConstraintMatchesArgument()938 {939 $this->mock->shouldReceive('foo')->with(Mockery::type('callable'))->once();940 $this->mock->foo(function () {return 'f';});941 $this->container->mockery_verify();942 }943 public function testCallableConstraintNonMatchingCase()944 {945 $this->mock->shouldReceive('foo')->times(3);946 $this->mock->shouldReceive('foo')->with(1, Mockery::type('callable'))->never();947 $this->mock->foo();948 $this->mock->foo(1);949 $this->mock->foo(1, 2, 3);950 $this->container->mockery_verify();951 }952 /**953 * @expectedException \Mockery\Exception954 */955 public function testCallableConstraintThrowsExceptionWhenConstraintUnmatched()956 {957 $this->mock->shouldReceive('foo')->with(Mockery::type('callable'))->once();958 $this->mock->foo(1);959 $this->container->mockery_verify();960 }961 public function testDoubleConstraintMatchesArgument()962 {963 $this->mock->shouldReceive('foo')->with(Mockery::type('double'))->once();964 $this->mock->foo(2.25);965 $this->container->mockery_verify();966 }967 public function testDoubleConstraintNonMatchingCase()968 {969 $this->mock->shouldReceive('foo')->times(3);970 $this->mock->shouldReceive('foo')->with(1, Mockery::type('double'))->never();971 $this->mock->foo();972 $this->mock->foo(1);973 $this->mock->foo(1, 2, 3);974 $this->container->mockery_verify();975 }976 /**977 * @expectedException \Mockery\Exception978 */979 public function testDoubleConstraintThrowsExceptionWhenConstraintUnmatched()980 {981 $this->mock->shouldReceive('foo')->with(Mockery::type('double'))->once();982 $this->mock->foo(1);983 $this->container->mockery_verify();984 }985 public function testFloatConstraintMatchesArgument()986 {987 $this->mock->shouldReceive('foo')->with(Mockery::type('float'))->once();988 $this->mock->foo(2.25);989 $this->container->mockery_verify();990 }991 public function testFloatConstraintNonMatchingCase()992 {993 $this->mock->shouldReceive('foo')->times(3);994 $this->mock->shouldReceive('foo')->with(1, Mockery::type('float'))->never();995 $this->mock->foo();996 $this->mock->foo(1);997 $this->mock->foo(1, 2, 3);998 $this->container->mockery_verify();999 }1000 /**1001 * @expectedException \Mockery\Exception1002 */1003 public function testFloatConstraintThrowsExceptionWhenConstraintUnmatched()1004 {1005 $this->mock->shouldReceive('foo')->with(Mockery::type('float'))->once();1006 $this->mock->foo(1);1007 $this->container->mockery_verify();1008 }1009 public function testIntConstraintMatchesArgument()1010 {1011 $this->mock->shouldReceive('foo')->with(Mockery::type('int'))->once();1012 $this->mock->foo(2);1013 $this->container->mockery_verify();1014 }1015 public function testIntConstraintNonMatchingCase()1016 {1017 $this->mock->shouldReceive('foo')->times(3);1018 $this->mock->shouldReceive('foo')->with(1, Mockery::type('int'))->never();1019 $this->mock->foo();1020 $this->mock->foo(1);1021 $this->mock->foo(1, 2, 3);1022 $this->container->mockery_verify();1023 }1024 /**1025 * @expectedException \Mockery\Exception1026 */1027 public function testIntConstraintThrowsExceptionWhenConstraintUnmatched()1028 {1029 $this->mock->shouldReceive('foo')->with(Mockery::type('int'))->once();1030 $this->mock->foo('f');1031 $this->container->mockery_verify();1032 }1033 public function testLongConstraintMatchesArgument()1034 {1035 $this->mock->shouldReceive('foo')->with(Mockery::type('long'))->once();1036 $this->mock->foo(2);1037 $this->container->mockery_verify();1038 }1039 public function testLongConstraintNonMatchingCase()1040 {1041 $this->mock->shouldReceive('foo')->times(3);1042 $this->mock->shouldReceive('foo')->with(1, Mockery::type('long'))->never();1043 $this->mock->foo();1044 $this->mock->foo(1);1045 $this->mock->foo(1, 2, 3);1046 $this->container->mockery_verify();1047 }1048 /**1049 * @expectedException \Mockery\Exception1050 */1051 public function testLongConstraintThrowsExceptionWhenConstraintUnmatched()1052 {1053 $this->mock->shouldReceive('foo')->with(Mockery::type('long'))->once();1054 $this->mock->foo('f');1055 $this->container->mockery_verify();1056 }1057 public function testNullConstraintMatchesArgument()1058 {1059 $this->mock->shouldReceive('foo')->with(Mockery::type('null'))->once();1060 $this->mock->foo(null);1061 $this->container->mockery_verify();1062 }1063 public function testNullConstraintNonMatchingCase()1064 {1065 $this->mock->shouldReceive('foo')->times(3);1066 $this->mock->shouldReceive('foo')->with(1, Mockery::type('null'))->never();1067 $this->mock->foo();1068 $this->mock->foo(1);1069 $this->mock->foo(1, 2, 3);1070 $this->container->mockery_verify();1071 }1072 /**1073 * @expectedException \Mockery\Exception1074 */1075 public function testNullConstraintThrowsExceptionWhenConstraintUnmatched()1076 {1077 $this->mock->shouldReceive('foo')->with(Mockery::type('null'))->once();1078 $this->mock->foo('f');1079 $this->container->mockery_verify();1080 }1081 public function testNumericConstraintMatchesArgument()1082 {1083 $this->mock->shouldReceive('foo')->with(Mockery::type('numeric'))->once();1084 $this->mock->foo('2');1085 $this->container->mockery_verify();1086 }1087 public function testNumericConstraintNonMatchingCase()1088 {1089 $this->mock->shouldReceive('foo')->times(3);1090 $this->mock->shouldReceive('foo')->with(1, Mockery::type('numeric'))->never();1091 $this->mock->foo();1092 $this->mock->foo(1);1093 $this->mock->foo(1, 2, 3);1094 $this->container->mockery_verify();1095 }1096 /**1097 * @expectedException \Mockery\Exception1098 */1099 public function testNumericConstraintThrowsExceptionWhenConstraintUnmatched()1100 {1101 $this->mock->shouldReceive('foo')->with(Mockery::type('numeric'))->once();1102 $this->mock->foo('f');1103 $this->container->mockery_verify();1104 }1105 public function testObjectConstraintMatchesArgument()1106 {1107 $this->mock->shouldReceive('foo')->with(Mockery::type('object'))->once();1108 $this->mock->foo(new stdClass);1109 $this->container->mockery_verify();1110 }1111 public function testObjectConstraintNonMatchingCase()1112 {1113 $this->mock->shouldReceive('foo')->times(3);1114 $this->mock->shouldReceive('foo')->with(1, Mockery::type('object`'))->never();1115 $this->mock->foo();1116 $this->mock->foo(1);1117 $this->mock->foo(1, 2, 3);1118 $this->container->mockery_verify();1119 }1120 /**1121 * @expectedException \Mockery\Exception1122 */1123 public function testObjectConstraintThrowsExceptionWhenConstraintUnmatched()1124 {1125 $this->mock->shouldReceive('foo')->with(Mockery::type('object'))->once();1126 $this->mock->foo('f');1127 $this->container->mockery_verify();1128 }1129 public function testRealConstraintMatchesArgument()1130 {1131 $this->mock->shouldReceive('foo')->with(Mockery::type('real'))->once();1132 $this->mock->foo(2.25);1133 $this->container->mockery_verify();1134 }1135 public function testRealConstraintNonMatchingCase()1136 {1137 $this->mock->shouldReceive('foo')->times(3);1138 $this->mock->shouldReceive('foo')->with(1, Mockery::type('real'))->never();1139 $this->mock->foo();1140 $this->mock->foo(1);1141 $this->mock->foo(1, 2, 3);1142 $this->container->mockery_verify();1143 }1144 /**1145 * @expectedException \Mockery\Exception1146 */1147 public function testRealConstraintThrowsExceptionWhenConstraintUnmatched()1148 {1149 $this->mock->shouldReceive('foo')->with(Mockery::type('real'))->once();1150 $this->mock->foo('f');1151 $this->container->mockery_verify();1152 }1153 public function testResourceConstraintMatchesArgument()1154 {1155 $this->mock->shouldReceive('foo')->with(Mockery::type('resource'))->once();1156 $r = fopen(dirname(__FILE__) . '/_files/file.txt', 'r');1157 $this->mock->foo($r);1158 $this->container->mockery_verify();1159 }1160 public function testResourceConstraintNonMatchingCase()1161 {1162 $this->mock->shouldReceive('foo')->times(3);1163 $this->mock->shouldReceive('foo')->with(1, Mockery::type('resource'))->never();1164 $this->mock->foo();1165 $this->mock->foo(1);1166 $this->mock->foo(1, 2, 3);1167 $this->container->mockery_verify();1168 }1169 /**1170 * @expectedException \Mockery\Exception1171 */1172 public function testResourceConstraintThrowsExceptionWhenConstraintUnmatched()1173 {1174 $this->mock->shouldReceive('foo')->with(Mockery::type('resource'))->once();1175 $this->mock->foo('f');1176 $this->container->mockery_verify();1177 }1178 public function testScalarConstraintMatchesArgument()1179 {1180 $this->mock->shouldReceive('foo')->with(Mockery::type('scalar'))->once();1181 $this->mock->foo(2);1182 $this->container->mockery_verify();1183 }1184 public function testScalarConstraintNonMatchingCase()1185 {1186 $this->mock->shouldReceive('foo')->times(3);1187 $this->mock->shouldReceive('foo')->with(1, Mockery::type('scalar'))->never();1188 $this->mock->foo();1189 $this->mock->foo(1);1190 $this->mock->foo(1, 2, 3);1191 $this->container->mockery_verify();1192 }1193 /**1194 * @expectedException \Mockery\Exception1195 */1196 public function testScalarConstraintThrowsExceptionWhenConstraintUnmatched()1197 {1198 $this->mock->shouldReceive('foo')->with(Mockery::type('scalar'))->once();1199 $this->mock->foo(array());1200 $this->container->mockery_verify();1201 }1202 public function testStringConstraintMatchesArgument()1203 {1204 $this->mock->shouldReceive('foo')->with(Mockery::type('string'))->once();1205 $this->mock->foo('2');1206 $this->container->mockery_verify();1207 }1208 public function testStringConstraintNonMatchingCase()1209 {1210 $this->mock->shouldReceive('foo')->times(3);1211 $this->mock->shouldReceive('foo')->with(1, Mockery::type('string'))->never();1212 $this->mock->foo();1213 $this->mock->foo(1);1214 $this->mock->foo(1, 2, 3);1215 $this->container->mockery_verify();1216 }1217 /**1218 * @expectedException \Mockery\Exception1219 */1220 public function testStringConstraintThrowsExceptionWhenConstraintUnmatched()1221 {1222 $this->mock->shouldReceive('foo')->with(Mockery::type('string'))->once();1223 $this->mock->foo(1);1224 $this->container->mockery_verify();1225 }1226 public function testClassConstraintMatchesArgument()1227 {1228 $this->mock->shouldReceive('foo')->with(Mockery::type('stdClass'))->once();1229 $this->mock->foo(new stdClass);1230 $this->container->mockery_verify();1231 }1232 public function testClassConstraintNonMatchingCase()1233 {1234 $this->mock->shouldReceive('foo')->times(3);1235 $this->mock->shouldReceive('foo')->with(1, Mockery::type('stdClass'))->never();1236 $this->mock->foo();1237 $this->mock->foo(1);1238 $this->mock->foo(1, 2, 3);1239 $this->container->mockery_verify();1240 }1241 /**1242 * @expectedException \Mockery\Exception1243 */1244 public function testClassConstraintThrowsExceptionWhenConstraintUnmatched()1245 {1246 $this->mock->shouldReceive('foo')->with(Mockery::type('stdClass'))->once();1247 $this->mock->foo(new Exception);1248 $this->container->mockery_verify();1249 }1250 public function testDucktypeConstraintMatchesArgument()1251 {1252 $this->mock->shouldReceive('foo')->with(Mockery::ducktype('quack', 'swim'))->once();1253 $this->mock->foo(new Mockery_Duck);1254 $this->container->mockery_verify();1255 }1256 public function testDucktypeConstraintNonMatchingCase()1257 {1258 $this->mock->shouldReceive('foo')->times(3);1259 $this->mock->shouldReceive('foo')->with(1, Mockery::ducktype('quack', 'swim'))->never();1260 $this->mock->foo();1261 $this->mock->foo(1);1262 $this->mock->foo(1, 2, 3);1263 $this->container->mockery_verify();1264 }1265 /**1266 * @expectedException \Mockery\Exception1267 */1268 public function testDucktypeConstraintThrowsExceptionWhenConstraintUnmatched()1269 {1270 $this->mock->shouldReceive('foo')->with(Mockery::ducktype('quack', 'swim'))->once();1271 $this->mock->foo(new Mockery_Duck_Nonswimmer);1272 $this->container->mockery_verify();1273 }1274 public function testArrayContentConstraintMatchesArgument()1275 {1276 $this->mock->shouldReceive('foo')->with(Mockery::subset(array('a'=>1, 'b'=>2)))->once();1277 $this->mock->foo(array('a'=>1, 'b'=>2, 'c'=>3));1278 $this->container->mockery_verify();1279 }1280 public function testArrayContentConstraintNonMatchingCase()1281 {1282 $this->mock->shouldReceive('foo')->times(3);1283 $this->mock->shouldReceive('foo')->with(1, Mockery::subset(array('a'=>1, 'b'=>2)))->never();1284 $this->mock->foo();1285 $this->mock->foo(1);1286 $this->mock->foo(1, 2, 3);1287 $this->container->mockery_verify();1288 }1289 /**1290 * @expectedException \Mockery\Exception1291 */1292 public function testArrayContentConstraintThrowsExceptionWhenConstraintUnmatched()1293 {1294 $this->mock->shouldReceive('foo')->with(Mockery::subset(array('a'=>1, 'b'=>2)))->once();1295 $this->mock->foo(array('a'=>1, 'c'=>3));1296 $this->container->mockery_verify();1297 }1298 public function testContainsConstraintMatchesArgument()1299 {1300 $this->mock->shouldReceive('foo')->with(Mockery::contains(1, 2))->once();1301 $this->mock->foo(array('a'=>1, 'b'=>2, 'c'=>3));1302 $this->container->mockery_verify();1303 }1304 public function testContainsConstraintNonMatchingCase()1305 {1306 $this->mock->shouldReceive('foo')->times(3);1307 $this->mock->shouldReceive('foo')->with(1, Mockery::contains(1, 2))->never();1308 $this->mock->foo();1309 $this->mock->foo(1);1310 $this->mock->foo(1, 2, 3);1311 $this->container->mockery_verify();1312 }1313 /**1314 * @expectedException \Mockery\Exception1315 */1316 public function testContainsConstraintThrowsExceptionWhenConstraintUnmatched()1317 {1318 $this->mock->shouldReceive('foo')->with(Mockery::contains(1, 2))->once();1319 $this->mock->foo(array('a'=>1, 'c'=>3));1320 $this->container->mockery_verify();1321 }1322 public function testHasKeyConstraintMatchesArgument()1323 {1324 $this->mock->shouldReceive('foo')->with(Mockery::hasKey('c'))->once();1325 $this->mock->foo(array('a'=>1, 'b'=>2, 'c'=>3));1326 $this->container->mockery_verify();1327 }1328 public function testHasKeyConstraintNonMatchingCase()1329 {1330 $this->mock->shouldReceive('foo')->times(3);1331 $this->mock->shouldReceive('foo')->with(1, Mockery::hasKey('a'))->never();1332 $this->mock->foo();1333 $this->mock->foo(1);1334 $this->mock->foo(1, array('a'=>1), 3);1335 $this->container->mockery_verify();1336 }1337 /**1338 * @expectedException \Mockery\Exception1339 */1340 public function testHasKeyConstraintThrowsExceptionWhenConstraintUnmatched()1341 {1342 $this->mock->shouldReceive('foo')->with(Mockery::hasKey('c'))->once();1343 $this->mock->foo(array('a'=>1, 'b'=>3));1344 $this->container->mockery_verify();1345 }1346 public function testHasValueConstraintMatchesArgument()1347 {1348 $this->mock->shouldReceive('foo')->with(Mockery::hasValue(1))->once();1349 $this->mock->foo(array('a'=>1, 'b'=>2, 'c'=>3));1350 $this->container->mockery_verify();1351 }1352 public function testHasValueConstraintNonMatchingCase()1353 {1354 $this->mock->shouldReceive('foo')->times(3);1355 $this->mock->shouldReceive('foo')->with(1, Mockery::hasValue(1))->never();1356 $this->mock->foo();1357 $this->mock->foo(1);1358 $this->mock->foo(1, array('a'=>1), 3);1359 $this->container->mockery_verify();1360 }1361 /**1362 * @expectedException \Mockery\Exception1363 */1364 public function testHasValueConstraintThrowsExceptionWhenConstraintUnmatched()1365 {1366 $this->mock->shouldReceive('foo')->with(Mockery::hasValue(2))->once();1367 $this->mock->foo(array('a'=>1, 'b'=>3));1368 $this->container->mockery_verify();1369 }1370 public function testOnConstraintMatchesArgument_ClosureEvaluatesToTrue()1371 {1372 $function = function ($arg) {return $arg % 2 == 0;};1373 $this->mock->shouldReceive('foo')->with(Mockery::on($function))->once();1374 $this->mock->foo(4);1375 $this->container->mockery_verify();1376 }1377 /**1378 * @expectedException \Mockery\Exception1379 */1380 public function testOnConstraintThrowsExceptionWhenConstraintUnmatched_ClosureEvaluatesToFalse()1381 {1382 $function = function ($arg) {return $arg % 2 == 0;};1383 $this->mock->shouldReceive('foo')->with(Mockery::on($function))->once();1384 $this->mock->foo(5);1385 $this->container->mockery_verify();1386 }1387 public function testMustBeConstraintMatchesArgument()1388 {1389 $this->mock->shouldReceive('foo')->with(Mockery::mustBe(2))->once();1390 $this->mock->foo(2);1391 $this->container->mockery_verify();1392 }1393 public function testMustBeConstraintNonMatchingCase()1394 {1395 $this->mock->shouldReceive('foo')->times(3);1396 $this->mock->shouldReceive('foo')->with(1, Mockery::mustBe(2))->never();1397 $this->mock->foo();1398 $this->mock->foo(1);1399 $this->mock->foo(1, 2, 3);1400 $this->container->mockery_verify();1401 }1402 /**1403 * @expectedException \Mockery\Exception1404 */1405 public function testMustBeConstraintThrowsExceptionWhenConstraintUnmatched()1406 {1407 $this->mock->shouldReceive('foo')->with(Mockery::mustBe(2))->once();1408 $this->mock->foo('2');1409 $this->container->mockery_verify();1410 }1411 public function testMustBeConstraintMatchesObjectArgumentWithEqualsComparisonNotIdentical()1412 {1413 $a = new stdClass;1414 $a->foo = 1;1415 $b = new stdClass;1416 $b->foo = 1;1417 $this->mock->shouldReceive('foo')->with(Mockery::mustBe($a))->once();1418 $this->mock->foo($b);1419 $this->container->mockery_verify();1420 }1421 public function testMustBeConstraintNonMatchingCaseWithObject()1422 {1423 $a = new stdClass;1424 $a->foo = 1;1425 $this->mock->shouldReceive('foo')->times(3);1426 $this->mock->shouldReceive('foo')->with(1, Mockery::mustBe($a))->never();1427 $this->mock->foo();1428 $this->mock->foo(1);1429 $this->mock->foo(1, $a, 3);1430 $this->container->mockery_verify();1431 }1432 /**1433 * @expectedException \Mockery\Exception1434 */1435 public function testMustBeConstraintThrowsExceptionWhenConstraintUnmatchedWithObject()1436 {1437 $a = new stdClass;1438 $a->foo = 1;1439 $b = new stdClass;1440 $b->foo = 2;1441 $this->mock->shouldReceive('foo')->with(Mockery::mustBe($a))->once();1442 $this->mock->foo($b);1443 $this->container->mockery_verify();1444 }1445 public function testMatchPrecedenceBasedOnExpectedCallsFavouringExplicitMatch()1446 {1447 $this->mock->shouldReceive('foo')->with(1)->once();1448 $this->mock->shouldReceive('foo')->with(Mockery::any())->never();1449 $this->mock->foo(1);1450 $this->container->mockery_verify();1451 }1452 public function testMatchPrecedenceBasedOnExpectedCallsFavouringAnyMatch()1453 {1454 $this->mock->shouldReceive('foo')->with(Mockery::any())->once();1455 $this->mock->shouldReceive('foo')->with(1)->never();1456 $this->mock->foo(1);1457 $this->container->mockery_verify();1458 }1459 public function testReturnNullIfIgnoreMissingMethodsSet()1460 {1461 $this->mock->shouldIgnoreMissing();1462 $this->assertNull($this->mock->g(1, 2));1463 }1464 public function testReturnUndefinedIfIgnoreMissingMethodsSet()1465 {1466 $this->mock->shouldIgnoreMissing()->asUndefined();1467 $this->assertTrue($this->mock->g(1, 2) instanceof \Mockery\Undefined);1468 }1469 public function testReturnAsUndefinedAllowsForInfiniteSelfReturningChain()1470 {1471 $this->mock->shouldIgnoreMissing()->asUndefined();1472 $this->assertTrue($this->mock->g(1, 2)->a()->b()->c() instanceof \Mockery\Undefined);1473 }1474 public function testShouldIgnoreMissingFluentInterface()1475 {1476 $this->assertTrue($this->mock->shouldIgnoreMissing() instanceof \Mockery\MockInterface);1477 }1478 public function testShouldIgnoreMissingAsUndefinedFluentInterface()1479 {1480 $this->assertTrue($this->mock->shouldIgnoreMissing()->asUndefined() instanceof \Mockery\MockInterface);1481 }1482 public function testShouldIgnoreMissingAsDefinedProxiesToUndefinedAllowingToString()1483 {1484 $this->mock->shouldIgnoreMissing()->asUndefined();1485 $string = "Method call: {$this->mock->g()}";1486 $string = "Mock: {$this->mock}";1487 }1488 public function testShouldIgnoreMissingDefaultReturnValue()1489 {1490 $this->mock->shouldIgnoreMissing(1);1491 $this->assertEquals(1, $this->mock->a());1492 }1493 /** @issue #253 */1494 public function testShouldIgnoreMissingDefaultSelfAndReturnsSelf()1495 {1496 $this->mock->shouldIgnoreMissing($this->container->self());1497 $this->assertSame($this->mock, $this->mock->a()->b());1498 }1499 public function testToStringMagicMethodCanBeMocked()1500 {1501 $this->mock->shouldReceive("__toString")->andReturn('dave');1502 $this->assertEquals("{$this->mock}", "dave");1503 }1504 public function testOptionalMockRetrieval()1505 {1506 $m = $this->container->mock('f')->shouldReceive('foo')->with(1)->andReturn(3)->mock();1507 $this->assertTrue($m instanceof \Mockery\MockInterface);1508 }1509 public function testNotConstraintMatchesArgument()1510 {1511 $this->mock->shouldReceive('foo')->with(Mockery::not(1))->once();1512 $this->mock->foo(2);1513 $this->container->mockery_verify();1514 }1515 public function testNotConstraintNonMatchingCase()1516 {1517 $this->mock->shouldReceive('foo')->times(3);1518 $this->mock->shouldReceive('foo')->with(1, Mockery::not(2))->never();1519 $this->mock->foo();1520 $this->mock->foo(1);1521 $this->mock->foo(1, 2, 3);1522 $this->container->mockery_verify();1523 }1524 /**1525 * @expectedException \Mockery\Exception1526 */1527 public function testNotConstraintThrowsExceptionWhenConstraintUnmatched()1528 {1529 $this->mock->shouldReceive('foo')->with(Mockery::not(2))->once();1530 $this->mock->foo(2);1531 $this->container->mockery_verify();1532 }1533 public function testAnyOfConstraintMatchesArgument()1534 {1535 $this->mock->shouldReceive('foo')->with(Mockery::anyOf(1, 2))->twice();1536 $this->mock->foo(2);1537 $this->mock->foo(1);1538 $this->container->mockery_verify();1539 }1540 public function testAnyOfConstraintNonMatchingCase()1541 {1542 $this->mock->shouldReceive('foo')->times(3);1543 $this->mock->shouldReceive('foo')->with(1, Mockery::anyOf(1, 2))->never();1544 $this->mock->foo();1545 $this->mock->foo(1);1546 $this->mock->foo(1, 2, 3);1547 $this->container->mockery_verify();1548 }1549 /**1550 * @expectedException \Mockery\Exception1551 */1552 public function testAnyOfConstraintThrowsExceptionWhenConstraintUnmatched()1553 {1554 $this->mock->shouldReceive('foo')->with(Mockery::anyOf(1, 2))->once();1555 $this->mock->foo(3);1556 $this->container->mockery_verify();1557 }1558 public function testNotAnyOfConstraintMatchesArgument()1559 {1560 $this->mock->shouldReceive('foo')->with(Mockery::notAnyOf(1, 2))->once();1561 $this->mock->foo(3);1562 $this->container->mockery_verify();1563 }1564 public function testNotAnyOfConstraintNonMatchingCase()1565 {1566 $this->mock->shouldReceive('foo')->times(3);1567 $this->mock->shouldReceive('foo')->with(1, Mockery::notAnyOf(1, 2))->never();1568 $this->mock->foo();1569 $this->mock->foo(1);1570 $this->mock->foo(1, 4, 3);1571 $this->container->mockery_verify();1572 }1573 /**1574 * @expectedException \Mockery\Exception1575 */1576 public function testNotAnyOfConstraintThrowsExceptionWhenConstraintUnmatched()1577 {1578 $this->mock->shouldReceive('foo')->with(Mockery::notAnyOf(1, 2))->once();1579 $this->mock->foo(2);1580 $this->container->mockery_verify();1581 }1582 /**1583 * @expectedException \Mockery\Exception1584 */1585 public function testGlobalConfigMayForbidMockingNonExistentMethodsOnClasses()1586 {1587 \Mockery::getConfiguration()->allowMockingNonExistentMethods(false);1588 $mock = $this->container->mock('stdClass');1589 $mock->shouldReceive('foo');1590 }1591 /**1592 * @expectedException \Mockery\Exception1593 * @expectedExceptionMessage Mockery's configuration currently forbids mocking1594 */1595 public function testGlobalConfigMayForbidMockingNonExistentMethodsOnAutoDeclaredClasses()1596 {1597 \Mockery::getConfiguration()->allowMockingNonExistentMethods(false);1598 $mock = $this->container->mock('SomeMadeUpClass');1599 $mock->shouldReceive('foo');1600 }1601 /**1602 * @expectedException \Mockery\Exception1603 */1604 public function testGlobalConfigMayForbidMockingNonExistentMethodsOnObjects()1605 {1606 \Mockery::getConfiguration()->allowMockingNonExistentMethods(false);1607 $mock = $this->container->mock(new stdClass);1608 $mock->shouldReceive('foo');1609 }1610 public function testAnExampleWithSomeExpectationAmends()1611 {1612 $service = $this->container->mock('MyService');1613 $service->shouldReceive('login')->with('user', 'pass')->once()->andReturn(true);1614 $service->shouldReceive('hasBookmarksTagged')->with('php')->once()->andReturn(false);1615 $service->shouldReceive('addBookmark')->with('/^http:/', \Mockery::type('string'))->times(3)->andReturn(true);1616 $service->shouldReceive('hasBookmarksTagged')->with('php')->once()->andReturn(true);1617 $this->assertTrue($service->login('user', 'pass'));1618 $this->assertFalse($service->hasBookmarksTagged('php'));1619 $this->assertTrue($service->addBookmark('http://example.com/1', 'some_tag1'));1620 $this->assertTrue($service->addBookmark('http://example.com/2', 'some_tag2'));1621 $this->assertTrue($service->addBookmark('http://example.com/3', 'some_tag3'));1622 $this->assertTrue($service->hasBookmarksTagged('php'));1623 $this->container->mockery_verify();1624 }1625 public function testAnExampleWithSomeExpectationAmendsOnCallCounts()1626 {1627 $service = $this->container->mock('MyService');1628 $service->shouldReceive('login')->with('user', 'pass')->once()->andReturn(true);1629 $service->shouldReceive('hasBookmarksTagged')->with('php')->once()->andReturn(false);1630 $service->shouldReceive('addBookmark')->with('/^http:/', \Mockery::type('string'))->times(3)->andReturn(true);1631 $service->shouldReceive('hasBookmarksTagged')->with('php')->twice()->andReturn(true);1632 $this->assertTrue($service->login('user', 'pass'));1633 $this->assertFalse($service->hasBookmarksTagged('php'));1634 $this->assertTrue($service->addBookmark('http://example.com/1', 'some_tag1'));1635 $this->assertTrue($service->addBookmark('http://example.com/2', 'some_tag2'));1636 $this->assertTrue($service->addBookmark('http://example.com/3', 'some_tag3'));1637 $this->assertTrue($service->hasBookmarksTagged('php'));1638 $this->assertTrue($service->hasBookmarksTagged('php'));1639 $this->container->mockery_verify();1640 }1641 public function testAnExampleWithSomeExpectationAmendsOnCallCounts_PHPUnitTest()1642 {1643 $service = $this->getMock('MyService2');1644 $service->expects($this->once())->method('login')->with('user', 'pass')->will($this->returnValue(true));1645 $service->expects($this->exactly(3))->method('hasBookmarksTagged')->with('php')1646 ->will($this->onConsecutiveCalls(false, true, true));1647 $service->expects($this->exactly(3))->method('addBookmark')1648 ->with($this->matchesRegularExpression('/^http:/'), $this->isType('string'))1649 ->will($this->returnValue(true));1650 $this->assertTrue($service->login('user', 'pass'));1651 $this->assertFalse($service->hasBookmarksTagged('php'));1652 $this->assertTrue($service->addBookmark('http://example.com/1', 'some_tag1'));1653 $this->assertTrue($service->addBookmark('http://example.com/2', 'some_tag2'));1654 $this->assertTrue($service->addBookmark('http://example.com/3', 'some_tag3'));1655 $this->assertTrue($service->hasBookmarksTagged('php'));1656 $this->assertTrue($service->hasBookmarksTagged('php'));1657 }1658 public function testMockedMethodsCallableFromWithinOriginalClass()1659 {1660 $mock = $this->container->mock('MockeryTest_InterMethod1[doThird]');1661 $mock->shouldReceive('doThird')->andReturn(true);1662 $this->assertTrue($mock->doFirst());1663 }1664 /**1665 * @group issue #201666 */1667 public function testMockingDemeterChainsPassesMockeryExpectationToCompositeExpectation()1668 {1669 $mock = $this->container->mock('Mockery_Demeterowski');1670 $mock->shouldReceive('foo->bar->baz')->andReturn('Spam!');1671 $demeter = new Mockery_UseDemeter($mock);1672 $this->assertSame('Spam!', $demeter->doit());1673 }1674 /**1675 * @group issue #20 - with args in demeter chain1676 */1677 public function testMockingDemeterChainsPassesMockeryExpectationToCompositeExpectationWithArgs()1678 {1679 $mock = $this->container->mock('Mockery_Demeterowski');1680 $mock->shouldReceive('foo->bar->baz')->andReturn('Spam!');1681 $demeter = new Mockery_UseDemeter($mock);1682 $this->assertSame('Spam!', $demeter->doitWithArgs());1683 }1684 public function testPassthruEnsuresRealMethodCalledForReturnValues()1685 {1686 $mock = $this->container->mock('MockeryTest_SubjectCall1');1687 $mock->shouldReceive('foo')->once()->passthru();1688 $this->assertEquals('bar', $mock->foo());1689 $this->container->mockery_verify();1690 }1691 public function testShouldIgnoreMissingExpectationBasedOnArgs()1692 {1693 $mock = $this->container->mock("MyService2")->shouldIgnoreMissing();1694 $mock->shouldReceive("hasBookmarksTagged")->with("dave")->once();1695 $mock->hasBookmarksTagged("dave");1696 $mock->hasBookmarksTagged("padraic");1697 $this->container->mockery_verify();1698 }1699 public function testShouldDeferMissingExpectationBasedOnArgs()1700 {1701 $mock = $this->container->mock("MockeryTest_SubjectCall1")->shouldDeferMissing();1702 $this->assertEquals('bar', $mock->foo());1703 $this->assertEquals('bar', $mock->foo("baz"));1704 $this->assertEquals('bar', $mock->foo("qux"));1705 $mock->shouldReceive("foo")->with("baz")->twice()->andReturn('123');1706 $this->assertEquals('bar', $mock->foo());1707 $this->assertEquals('123', $mock->foo("baz"));1708 $this->assertEquals('bar', $mock->foo("qux"));1709 $mock->shouldReceive("foo")->withNoArgs()->once()->andReturn('456');1710 $this->assertEquals('456', $mock->foo());1711 $this->assertEquals('123', $mock->foo("baz"));1712 $this->assertEquals('bar', $mock->foo("qux"));1713 $this->container->mockery_verify();1714 }1715 public function testCanReturnSelf()1716 {1717 $this->mock->shouldReceive("foo")->andReturnSelf();1718 $this->assertSame($this->mock, $this->mock->foo());1719 }1720 public function testExpectationCanBeOverridden()1721 {1722 $this->mock->shouldReceive('foo')->once()->andReturn('green');1723 $this->mock->shouldReceive('foo')->andReturn('blue');1724 $this->assertEquals($this->mock->foo(), 'green');1725 $this->assertEquals($this->mock->foo(), 'blue');1726 }1727}1728class MockeryTest_SubjectCall11729{1730 public function foo()1731 {1732 return 'bar';1733 }1734}1735class MockeryTest_InterMethod11736{1737 public function doFirst()1738 {1739 return $this->doSecond();1740 }1741 private function doSecond()1742 {1743 return $this->doThird();1744 }1745 public function doThird()1746 {1747 return false;1748 }1749}1750class MyService21751{1752 public function login($user, $pass)1753 {1754 }1755 public function hasBookmarksTagged($tag)1756 {1757 }1758 public function addBookmark($uri, $tag)1759 {1760 }1761}1762class Mockery_Duck1763{1764 public function quack()1765 {1766 }1767 public function swim()1768 {1769 }1770}1771class Mockery_Duck_Nonswimmer1772{1773 public function quack()1774 {1775 }1776}1777class Mockery_Demeterowski1778{1779 public function foo()1780 {1781 return $this;1782 }1783 public function bar()1784 {1785 return $this;1786 }1787 public function baz()1788 {1789 return 'Ham!';1790 }1791}1792class Mockery_UseDemeter1793{1794 public function __construct($demeter)1795 {1796 $this->demeter = $demeter;1797 }1798 public function doit()1799 {1800 return $this->demeter->foo()->bar()->baz();1801 }1802 public function doitWithArgs()1803 {1804 return $this->demeter->foo("foo")->bar("bar")->baz("baz");1805 }1806}1807class MockeryTest_Foo1808{1809 public function foo()1810 {1811 }1812}...

Full Screen

Full Screen

bar

Using AI Code Generation

copy

Full Screen

1$mock->bar();2$mock->bar();3$mock->bar();4$mock->bar();5$mock->bar();6$mock->bar();7$mock->bar();8$mock->bar();9$mock->bar();10$mock->bar();11$mock->bar();12$mock->bar();13$mock->bar();14$mock->bar();15$mock->bar();16$mock->bar();17$mock->bar();18$mock->bar();19$mock->bar();20$mock->bar();21$mock->bar();22$mock->bar();23$mock->bar();

Full Screen

Full Screen

bar

Using AI Code Generation

copy

Full Screen

1$mock->bar();2$mock->foo();3$mock->bar();4You can use the at() method to specify the number of times a method should be called. The following example shows how to use the at() method:5{6 public function testSomething()7 {8 $mock = $this->getMock('Class');9 $mock->expects($this->at(0))10 ->method('bar');11 $mock->expects($this->at(1))12 ->method('foo');13 $mock->expects($this->at(2))14 ->method('bar');15 $mock->bar();16 $mock->foo();17 $mock->bar();18 }19}20OK (6 tests, 0 assertions)21You can use the at() method to specify the order in which methods should be called. The following example shows how to use the at() method to specify the order in which methods should be called:

Full Screen

Full Screen

bar

Using AI Code Generation

copy

Full Screen

1$mock->bar();2$mock->baz();3$mock->qux();4$mock->quux();5$mock->corge();6$mock->grault();7$mock->garply();8$mock->waldo();9$mock->fred();10$mock->plugh();11$mock->xyzzy();12$mock->thud();13$mock->foobar();14$mock->foobaz();15$mock->foobaz();16$mock->foobaz();17$mock->foobaz();18$mock->foobaz();19$mock->foobaz();20$mock->foobaz();21$mock->foobaz();

Full Screen

Full Screen

bar

Using AI Code Generation

copy

Full Screen

1$mock = new MockClass();2$mock->bar();3$mock = new MockClass();4$mock->bar();5$mock = new MockClass();6$mock->bar();7unset($mock);8$mock = new MockClass();9$mock->bar();10unset($mock);

Full Screen

Full Screen

bar

Using AI Code Generation

copy

Full Screen

1$mock->bar();2$mock->bar();3$mock = $this->createMock(MockClass::class);4$mock->method('bar')5->willReturn(true);6$mock->bar();7{8 $mock = $this->createMock(MockClass::class);9}10$mock = $this->createMock(MockClass::class);11$mock->method('bar')12->willReturn(true);13$mock->bar();14{15 public function bar()

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful