public function testGet() { $actionInterfaceMock = $this->getMockForAbstractClass('Magento\\Indexer\\Model\\ActionInterface', [], '', false); $this->objectManagerMock->expects($this->once())->method('get')->with('Magento\\Indexer\\Model\\ActionInterface')->will($this->returnValue($actionInterfaceMock)); $this->model->get('Magento\\Indexer\\Model\\ActionInterface'); $this->assertInstanceOf('Magento\\Indexer\\Model\\ActionInterface', $actionInterfaceMock); }
public function testShouldWriteLoadedUrlToLogEvenWithDisabledDebugMode() { $this->setDebugMode(false); // Make debug mode disabled $this->driver->get('http://foo.bar'); $this->expectOutputRegex('/.*\\[WebDriver\\] Loading URL "http:\\/\\/foo.bar"/'); }
public function setUp() { $this->serviceManager = ServiceManagerFactory::getServiceManager(); /* @var $application \Zend\Mvc\Application */ $application = $this->serviceManager->get('Application'); $application->bootstrap(); }
public function testUnwrappingGet() { $unencryptedValue = 'foobar'; $encryptedValue = $this->crypto->encrypt($unencryptedValue); $this->wrappedSession->expects($this->once())->method('get')->with('encrypted_session_data')->willReturnCallback(function () use($encryptedValue) { return $encryptedValue; }); $this->assertSame($unencryptedValue, $this->wrappedSession->get('encrypted_session_data')); }
/** * @test */ public function testCacheSet() { $token = $this->tokenProvider->getAccessTokenByToken('nnch734d00sl2jdk'); $serializedToken = serialize($token); $key = 'tokenProvider/token/key:nnch734d00sl2jdk'; $this->tokenProviderCache->cacheSet($key, $serializedToken); $cachedToken = $this->client->get($key); $this->assertEquals($serializedToken, $cachedToken); }
/** * @param array $composerData * @param array $packages * @param string $repoUrl * * @dataProvider getDataProvider */ public function testGet(array $composerData, array $packages, $repoUrl) { $version = 'mockVersion'; $this->_infoEndpoint->expects($this->exactly(1))->method('_getGitVersion')->will($this->returnValue($version)); $this->_infoEndpoint->expects($this->exactly(1))->method('_loadComposerFile')->will($this->returnValue($composerData)); $this->_infoEndpoint->expects($this->exactly(1))->method('_getRepoUrl')->with($this->equalTo($version))->will($this->returnValue($repoUrl)); $expected = new DataObject(array(), array('repoUrl' => $repoUrl, 'version' => 'mockVersion', 'packages' => $packages)); $actual = $this->_infoEndpoint->get(); $this->assertEquals($expected, $actual); }
/** * @param array $adminGroupsOnTopOption * * @dataProvider getAdminGroupsWithOnTopOption */ public function testGetMenuProviderOnTopOptions(array $adminGroupsOnTopOption) { $this->pool->expects($this->once())->method('getInstance')->with($this->equalTo('sonata_admin_foo_service'))->will($this->returnValue($this->getAdminMock(true, false))); $menu = $this->provider->get('providerFoo', array('name' => 'foo', 'group' => $adminGroupsOnTopOption)); $this->assertInstanceOf('Knp\\Menu\\ItemInterface', $menu); $this->assertCount(0, $menu->getChildren()); }
/** * @covers ::set * @covers ::get */ public function testGet() { $name = 'id'; $value = $this->randomMachineName(); $this->assertSame($this->id, $this->entity->get($name)); $this->assertSame($this->entity, $this->entity->set($name, $value)); $this->assertSame($value, $this->entity->get($name)); }
public function testCreateWithCustomIgnoreSection() { $extra = array('custom-ignore-files' => array('foo-asset/foo' => array('PATTERN'), 'foo-asset/bar' => array())); $this->rootPackage->expects($this->any())->method('getExtra')->will($this->returnValue($extra)); $manager = IgnoreFactory::create($this->composer, $this->package, null, 'custom-ignore-files'); $this->assertTrue($manager->isEnabled()); $this->assertTrue($manager->hasPattern()); $this->validateInstallDir($manager, $this->config->get('vendor-dir') . '/' . $this->package->getName()); }
/** * Asserts a render cache item. * * @param string $cid * The expected cache ID. * @param mixed $data * The expected data for that cache ID. * @param string $bin * The expected cache bin. */ protected function assertRenderCacheItem($cid, $data, $bin = 'render') { $cache_backend = $this->cacheFactory->get($bin); $cached = $cache_backend->get($cid); $this->assertNotFalse($cached, sprintf('Expected cache item "%s" exists.', $cid)); if ($cached !== FALSE) { $this->assertEquals($data, $cached->data, sprintf('Cache item "%s" has the expected data.', $cid)); $this->assertSame(Cache::mergeTags($data['#cache']['tags'], ['rendered']), $cached->tags, "The cache item's cache tags also has the 'rendered' cache tag."); } }
/** * Test proxy authentication to a service. * * @covers ::proxyAuthenticate * @covers ::getServerProxyURL * @covers ::parseProxyTicket * * @dataProvider proxyAuthenticateDataProvider */ public function testProxyAuthenticate($target_service, $cookie_domain, $already_proxied) { // Set up the fake pgt in the session. $this->session->set('cas_pgt', $this->randomMachineName(24)); // Set up properties so the http client callback knows about them. $cookie_value = $this->randomMachineName(24); if ($already_proxied) { // Set up the fake session data. $session_cas_proxy_helper[$target_service][] = array('Name' => 'SESSION', 'Value' => $cookie_value, 'Domain' => $cookie_domain); $this->session->set('cas_proxy_helper', $session_cas_proxy_helper); $httpClient = new Client(); $casHelper = $this->getMockBuilder('\\Drupal\\cas\\Service\\CasHelper')->disableOriginalConstructor()->getMock(); $casProxyHelper = new CasProxyHelper($httpClient, $casHelper, $this->session); $jar = $casProxyHelper->proxyAuthenticate($target_service); $cookie_array = $jar->toArray(); $this->assertEquals('SESSION', $cookie_array[0]['Name']); $this->assertEquals($cookie_value, $cookie_array[0]['Value']); $this->assertEquals($cookie_domain, $cookie_array[0]['Domain']); } else { $proxy_ticket = $this->randomMachineName(24); $xml_response = "<cas:serviceResponse xmlns:cas='http://example.com/cas'>\n <cas:proxySuccess>\n <cas:proxyTicket>PT-{$proxy_ticket}</cas:proxyTicket>\n </cas:proxySuccess>\n </cas:serviceResponse>"; $mock = new MockHandler([new Response(200, [], $xml_response), new Response(200, ['Content-type' => 'text/html', 'Set-Cookie' => 'SESSION=' . $cookie_value])]); $handler = HandlerStack::create($mock); $httpClient = new Client(['handler' => $handler]); $casHelper = $this->getMockBuilder('\\Drupal\\cas\\Service\\CasHelper')->disableOriginalConstructor()->getMock(); $casProxyHelper = new CasProxyHelper($httpClient, $casHelper, $this->session); // The casHelper expects to be called for a few things. $casHelper->expects($this->once())->method('getServerBaseUrl')->will($this->returnValue('https://example.com/cas/')); $casHelper->expects($this->once())->method('isProxy')->will($this->returnValue(TRUE)); $jar = $casProxyHelper->proxyAuthenticate($target_service); $this->assertEquals('SESSION', $this->session->get('cas_proxy_helper')[$target_service][0]['Name']); $this->assertEquals($cookie_value, $this->session->get('cas_proxy_helper')[$target_service][0]['Value']); $this->assertEquals($cookie_domain, $this->session->get('cas_proxy_helper')[$target_service][0]['Domain']); $cookie_array = $jar->toArray(); $this->assertEquals('SESSION', $cookie_array[0]['Name']); $this->assertEquals($cookie_value, $cookie_array[0]['Value']); $this->assertEquals($cookie_domain, $cookie_array[0]['Domain']); } }
public function get($areaCode, $cacheId) { return $this->_mock->get($areaCode, $cacheId); }
/** * @param string $k * @param mixed $v * @dataProvider providerGet * @depends testSet */ public function testGet($k, $v) { $this->mail->set($k, $v); $result = $this->mail->get($k); $this->assertEquals($v, $result); }
/** * @dataProvider strategyProviderInvalidReturnValues * @expectedException \Doctrine\ORM\EntityNotFoundException */ public function testGetMethodThrowsExceptionWhenStrategyReturnsNonEntity($returnValue) { $this->strategyProvider->expects($this->once())->method('get')->will($this->returnValue($returnValue)); $this->assertInstanceOf('Obiz\\Common\\Entity', $this->entityRepository->get(1)); }
/** * @param string $url * @param \GuzzleHttp\Psr7\Response $response * @param array $params * @param array $expectedRequestParams * @param array|int $result * @dataProvider getDataProvider */ public function testGet($url, $response, $params, $expectedRequestParams, $result) { $this->clientMock->expects($this->once())->method('get')->with($url, $expectedRequestParams)->willReturn($response); $this->assertEquals($result, $this->httpMock->get($url, $params)); }
public function testGetMethodWhenDrupalProviderReturnsNonEntity() { $this->concreteDrupalProvider->expects($this->once())->method('nodeToEntity')->will($this->returnValue(false)); $this->assertFalse($this->concreteDrupalProvider->get(1, 'Obiz\\Common\\Entity')); }