protected function createDirGenTest($baseDir, $dir) { $this->fs->shouldReceive('exists')->once()->with(m::mustBe(Path::join($baseDir, $dir)))->andReturn(false); $this->fs->shouldReceive('makeDirectory')->once()->with(m::mustBe(Path::join($baseDir, $dir)), m::mustBe(0755), m::mustBe(true))->andReturn(true); $generator = $this->generator->generateDirectoryStructure($baseDir, [$dir]); $this->assertInstanceOf(StubGenerator::class, $generator); }
public function __construct() { $this->config = new Conf(); $this->request = new Request(); $this->batchrequest = m::mock("Optimus\\BatchRequest\\BatchRequest"); $this->batchrequest->shouldReceive('request')->with(m::mustBe($this->request->get()))->andReturn(["json" => "data"]); }
/** * @covers Ilios\CoreBundle\Service\Directory::findByCampusId */ public function testFindByCampusIdsOnlyUseUnique() { $ldapManager = m::mock('Ilios\\CoreBundle\\Service\\LdapManager'); $obj = new Directory($ldapManager, 'campusId'); $ldapManager->shouldReceive('search')->with(m::mustBe('(|(campusId=1234)(campusId=1235))'))->andReturn(array(1)); $result = $obj->findByCampusIds([1234, 1235, 1234, 1235]); $this->assertSame($result, [1]); }
public function testRouterIsFired() { $batchRequest = m::mock('Optimus\\BatchRequest\\BatchRequest[prepareResults]', [$this->routerMock, $this->configMock, new \Optimus\BatchRequest\ResultFormatter\OptimusResultFormatter(), new \Optimus\BatchRequest\ResponseFormatter\OptimusResponseFormatter(), $this->dbMock]); $this->dbMock->shouldReceive('beginTransaction')->times(1); $this->routerMock->shouldReceive('batch')->times(1)->with(m::mustBe([['method' => 'GET', 'action' => 'action1', 'key' => 'request']])); $batchRequest->shouldReceive('prepareResults')->times(1); $results = $batchRequest->request([['method' => 'GET', 'action' => 'action1', 'key' => 'request']]); }
/** * Creates fixture for "Form::fill" method testing. * * @param Form $form Form. * @param string $field_name Field name. * @param string $field_value Field value. * * @return void */ protected function createFillFixture(Form $form, $field_name, $field_value) { $node_elements = array($this->createNodeElement()); $typified_element = m::mock(self::TYPIFIED_ELEMENT_CLASS); $form->shouldReceive('getNodeElements')->with($field_name)->once()->andReturn($node_elements); $form->shouldReceive('typify')->with(m::mustBe($node_elements))->once()->andReturn($typified_element); $form->shouldReceive('setValue')->with($typified_element, $field_value)->once()->andReturn($form); }
public function testRemove() { $phpunit = $this; $request = m::mock('jyggen\\Curl\\RequestInterface'); $headerbag = new HeaderBag(array(), $request); $request->shouldReceive('setOption')->times(1)->with(m::mustBe(CURLOPT_HTTPHEADER), m::type('array')); $headerbag->remove('foo'); }
public function testOk() { $context = $this->createContextMock(); $contextResolved = $this->createContextMock(); $result = new \stdClass(); $this->contextResolver->shouldReceive('resolve')->with($context)->once()->andReturn($contextResolved)->ordered(); $this->delegate->shouldReceive('create')->with(\Mockery::mustBe($contextResolved))->once()->andReturn($result)->ordered(); $this->assertSame($result, $this->creator->create($context)); }
public function testStatus() { $body = m::mock(\Psr\Http\Message\StreamInterface::class); $body->shouldReceive('getContents')->once()->andReturn('{"success": "Rolled back"}'); $response = m::mock(\Psr\Http\Message\ResponseInterface::class); $response->shouldReceive('getBody')->once()->andReturn($body); $client = m::mock(\GuzzleHttp\Client::class); $client->shouldReceive('request')->with(m::mustBe('POST'), m::mustBe($this->config['remote_endpoint'] . '?cmd=status'), new PayloadMatcher(['headers', 'form_params']))->once()->andReturn($response); $this->httpServer->setClient($client); $this->httpServer->status(); }
public function testCustomResultAcknowledgementHandler() { $handler = new ResultAcknowledgementHandler(function ($result) { return $result === false; }, $this->handler); $this->message->shouldReceive('isValid')->once()->withNoArgs()->andReturn(true); $this->adapter->shouldReceive('acknowledge')->once()->with(m::mustBe([$this->message])); $handler($this->messages, $this->adapter, function ($msg) { return false; }); }
public function testOk() { $client = $this->createClient(); $userId = '2'; $scope = 'foo'; $scopes = new ScopeCollection([new Scope($scope)]); $context = new Context($client, $userId, $scopes); $inputData = ['user_id' => $userId, 'scope' => $scope]; $returnData = new \stdClass(); $this->scopesObtainer->shouldReceive('getScopes')->with($inputData)->once()->andReturn($scopes); $this->tokenCreator->shouldReceive('create')->with(\Mockery::mustBe($context))->once()->andReturn($returnData); $this->assertSame($returnData, $this->processor->process($client, $inputData)); }
public function testHandleWorkerWithThrownException() { $handler = $this->handler; $this->messageA->shouldReceive('isValid')->once()->withNoArgs()->andReturn(true); $this->messageB->shouldReceive('isValid')->once()->withNoArgs()->andReturn(true); // @see https://github.com/padraic/mockery/issues/331 $this->adapter->shouldReceive('acknowledge')->once()->with(m::mustBe([$this->messageA])); $this->setExpectedException('RuntimeException', 'foo'); $handler($this->messages, $this->adapter, function ($msg) { if ($msg === $this->messageB) { throw new RuntimeException('foo'); } }); }
public function testMakeStack() { /** * @var \Radic\BladeExtensions\Helpers\EmbedStack $stack */ $stack = $this->stack->start(); $this->assertEquals($stack, $this->stack); // little trick to set the include($path) to the file we want in stack::end $stack->setData(['path' => __DIR__ . '/embed_stack_include.php', 'sf' => 'mmo']); $content = <<<EOT @section("one", "oneval") @section("two", "twoval") EOT; $contentCompiled = <<<'EOT' <?php $__env->startSection("one", "oneval"); ?> <?php $__env->startSection("two", "twoval"); ?> EOT; $viewContent = <<<'EOT' 1:@yield('one') 2:@yield('two') EOT; $viewContentCompiled = <<<'EOT' 1:oneval 2:twoval EOT; $stack->setContent($content); $this->bc->shouldReceive('compileString')->with(m::mustBe($content))->andReturn($contentCompiled); $this->vf->shouldReceive('getFinder')->andReturn($finder = m::mock('Illuminate\\View\\ViewFinderInterface')); $absoluteViewPath = realpath(__DIR__ . '/../views/embed.blade.php'); $finder->shouldReceive('find')->andReturn($absoluteViewPath); $this->fs->shouldReceive('get')->with(m::mustBe($absoluteViewPath))->andReturn($viewContent); $this->bc->shouldReceive('compileString')->with(m::mustBe($viewContent))->andReturn($viewContentCompiled); $this->fs->shouldReceive('exists')->andReturn(true); $this->fs->shouldReceive('put')->andReturn(); //->andSet()andReturn(['name', __DIR__ . '/embed_stack_include.php']); $this->fs->shouldReceive('delete')->andReturn(); $this->stack->end(); $output = 'thisispath '; $this->expectOutputString($output); //fwrite(STDERR, print_r($end, TRUE)); }
protected function shouldSearchAccount(AccountOwner $owner, Account $account = null) { $this->accountRepository()->shouldReceive('search')->once()->with(m::mustBe($owner))->andReturn($account); }
/** * Intercept all calls on the subject, and use the call details to create * a new expectation. The actual return value is then returned after being * recorded. * * @param string $method * @param array $args * @return mixed */ public function __call($method, array $args) { $return = call_user_func_array(array($this->_subject, $method), $args); $expectation = $this->_mock->shouldReceive($method)->andReturn($return); if ($this->_strict) { $exactArgs = array(); foreach ($args as $arg) { $exactArgs[] = \Mockery::mustBe($arg); } $expectation->once()->ordered(); call_user_func_array(array($expectation, 'with'), $exactArgs); } else { call_user_func_array(array($expectation, 'with'), $args); } return $return; }
protected function shouldHandleEvent(Message $event) { $this->eventBus()->shouldReceive('handle')->once()->with(m::mustBe($event))->andReturnNull(); }
public function testEmbedsManyDeletingEventReturnsFalse() { $user = User::create(array('name' => 'John Doe')); $user->addresses()->save(new Address(array('city' => 'New York'))); $address = $user->addresses->first(); $address->setEventDispatcher($events = Mockery::mock('Illuminate\\Events\\Dispatcher')); $events->shouldReceive('until')->once()->with('eloquent.deleting: ' . get_class($address), Mockery::mustBe($address))->andReturn(false); $this->assertEquals(0, $user->addresses()->destroy($address)); $this->assertEquals(array('New York'), $user->addresses->lists('city')); $address->unsetEventDispatcher(); }
/** * Test description. * * @return void */ public function testRunWithCoverageWithoutRemoteUrl() { /* @var $test_case BrowserTestCase */ /* @var $session_strategy ISessionStrategy */ list($test_case, $session_strategy) = $this->prepareForRun(array()); $test_case->setName('getTestId'); $code_coverage = m::mock('\\PHP_CodeCoverage'); $code_coverage->shouldReceive('append')->with(m::mustBe(array()), $test_case)->once(); $result = $this->getTestResult($test_case, 1, true); $result->shouldReceive('getCodeCoverage')->once()->andReturn($code_coverage); $test_id = $test_case->getTestId(); $this->assertEmpty($test_id); $browser = $test_case->getBrowser(); $browser->shouldReceive('getBaseUrl')->once()->andReturn('A'); $session = m::mock('\\Behat\\Mink\\Session'); $session->shouldReceive('visit')->with('A')->once(); $session->shouldReceive('setCookie')->with(RemoteCoverageTool::TEST_ID_VARIABLE, null)->once(); $session->shouldReceive('setCookie')->with(RemoteCoverageTool::TEST_ID_VARIABLE, m::not(''))->once(); $session_strategy->shouldReceive('session')->once()->andReturn($session); $test_case->run($result); $this->assertNotEmpty($test_case->getTestId()); }
/** * @expectedException \Mockery\Exception */ public function testMustBeConstraintThrowsExceptionWhenConstraintUnmatchedWithObject() { $a = new stdClass(); $a->foo = 1; $b = new stdClass(); $b->foo = 2; $this->mock->shouldReceive('foo')->with(Mockery::mustBe($a))->once(); $this->mock->foo($b); $this->container->mockery_verify(); }
protected function shouldSearchPlayer(PlayerId $id, Player $player = null) { $this->playerRepository()->shouldReceive('search')->once()->with(m::mustBe($id))->andReturn($player); }