/**
  * test generate with a missing template in the chosen template.
  * ensure fallback to default works.
  *
  * @return void
  */
 public function testGenerateWithTemplateFallbacks()
 {
     $this->_loadTestPlugin('TestBakeTheme');
     $this->Task->params['theme'] = 'TestBakeTheme';
     $this->Task->set(['name' => 'Articles', 'table' => 'articles', 'import' => false, 'records' => false, 'schema' => '', 'namespace' => '']);
     $result = $this->Task->generate('tests/fixture');
     $this->assertSameAsFile(__FUNCTION__ . '.ctp', $result);
 }
 /**
  * Test the possible exceptions from proxy authentication.
  *
  * @covers ::proxyAuthenticate
  * @covers ::getServerProxyURL
  * @covers ::parseProxyTicket
  *
  * @dataProvider proxyAuthenticateExceptionDataProvider
  */
 public function testProxyAuthenticateException($is_proxy, $pgt_set, $target_service, $response, $client_exception, $exception_type, $exception_message)
 {
     if ($pgt_set) {
         // 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);
     $casHelper = $this->getMockBuilder('\\Drupal\\cas\\Service\\CasHelper')->disableOriginalConstructor()->getMock();
     $casHelper->expects($this->any())->method('getServerBaseUrl')->will($this->returnValue('https://example.com/cas/'));
     $casHelper->expects($this->any())->method('isProxy')->will($this->returnValue($is_proxy));
     if ($client_exception == 'server') {
         $code = 404;
     } else {
         $code = 200;
     }
     if ($client_exception == 'client') {
         $secondResponse = new Response(404);
     } else {
         $secondResponse = new Response(200, ['Content-type' => 'text/html', 'Set-Cookie' => 'SESSION=' . $cookie_value]);
     }
     $mock = new MockHandler([new Response($code, [], $response), $secondResponse]);
     $handler = HandlerStack::create($mock);
     $httpClient = new Client(['handler' => $handler]);
     $casProxyHelper = new CasProxyHelper($httpClient, $casHelper, $this->session);
     $this->setExpectedException($exception_type, $exception_message);
     $jar = $casProxyHelper->proxyAuthenticate($target_service);
 }
 /**
  * @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));
 }
 /**
  * {@inheritdoc}
  */
 protected function setUp()
 {
     $this->pluginManager = $this->getMock('\\Drupal\\Core\\Entity\\EntityManagerInterface');
     $this->entityManager = $this->getMockBuilder('\\Drupal\\Core\\Entity\\EntityManagerInterface')->disableOriginalConstructor()->getMock();
     $this->contact = $this->getMockBuilder('Drupal\\crm_core_contact\\Entity\\Contact')->disableOriginalConstructor()->getMock();
     $this->contact->expects($this->any())->method('bundle')->will($this->returnValue('dogs'));
     $this->matcher = $this->getMockBuilder('Drupal\\crm_core_match\\Entity\\Matcher')->disableOriginalConstructor()->getMock();
     $this->matcher->expects($this->any())->method('status')->will($this->returnValue(TRUE));
     $this->matcher->set('configuration', array('rules' => array('foo' => array())));
     $storage = $this->getMock('Drupal\\Core\\Entity\\EntityStorageInterface');
     $storage->expects($this->any())->method('load')->with('dogs')->will($this->returnValue($this->matcher));
     $this->entityManager->expects($this->any())->method('getStorage')->will($this->returnValue($storage));
     $this->field = $this->getMock('Drupal\\Core\\Field\\FieldDefinitionInterface');
     $this->matchHandler = $this->getMock('Drupal\\crm_core_match\\Plugin\\crm_core_match\\field\\FieldHandlerInterface');
     $this->matchHandler->expects($this->any())->method('getPropertyNames')->will($this->returnValue(array('value')));
     $this->engine = new DefaultMatchingEngine(array(), 'default', array(), $this->pluginManager, $this->entityManager);
 }
 /**
  * @test
  */
 public function testCacheGet()
 {
     $token = $this->tokenProvider->getAccessTokenByToken('nnch734d00sl2jdk');
     $serializedToken = serialize($token);
     $key = 'tokenProvider/token/key:nnch734d00sl2jdk';
     $this->client->set($key, $serializedToken);
     $cachedToken = $this->tokenProviderCache->cacheGet($key);
     $this->assertEquals($serializedToken, $cachedToken);
 }
 private function setupContainer($requestMethod = 'GET', $securityGranted = true)
 {
     $mockLocationService = $this->getMock('eZ\\Publish\\API\\Repository\\LocationService');
     $mockLocationService->expects($this->any())->method('loadLocation')->with($this->equalTo($this->dummyLocationId))->will($this->returnValue($this->mockLocation));
     $mockRepository = $this->getMock('eZ\\Publish\\API\\Repository\\Repository');
     $mockRepository->expects($this->any())->method('getLocationService')->will($this->returnValue($mockLocationService));
     $this->mockRequest = $this->getMock('Symfony\\Component\\HttpFoundation\\Request');
     $this->mockRequest->expects($this->any())->method('getMethod')->will($this->returnValue($requestMethod));
     $mockContext = $this->getMock('Symfony\\Component\\Security\\Core\\SecurityContextInterface');
     $mockContext->expects($this->once())->method('isGranted')->will($this->returnValue($securityGranted));
     $mockConfigResolver = $this->getMock('eZ\\Publish\\Core\\MVC\\ConfigResolverInterface');
     $mockConfigResolver->expects($this->any())->method('hasParameter')->will($this->returnValueMap(array(array('content.view_cache', null, null, true), array('content.ttl_cache', null, null, true), array('content.default_ttl', null, null, true))));
     $mockConfigResolver->expects($this->any())->method('getParameter')->will($this->returnValueMap(array(array('content.view_cache', null, null, true), array('content.ttl_cache', null, null, true), array('content.default_ttl', null, null, $this->dummyCacheTTL))));
     $mockDispatcher = $this->getMock('Symfony\\Component\\EventDispatcher\\EventDispatcherInterface');
     $this->container = new Container();
     $this->container->set('ezpublish.api.repository', $mockRepository);
     $this->container->set('security.context', $mockContext);
     $this->container->set('request', $this->mockRequest);
     $this->container->set('ezpublish.config.resolver', $mockConfigResolver);
     $this->container->set('event_dispatcher', $mockDispatcher);
     $this->controller->setContainer($this->container);
 }
 /**
  * @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);
 }
 /**
  * @covers ::set
  */
 public function testSet()
 {
     // Exercise set(), check if it returns $this
     $this->assertSame($this->entity, $this->entity->set('id', 0));
 }
 /**
  * @test
  */
 public function testSettingParameters()
 {
     $this->task->set(array('foo' => 'bar'));
     $this->expectOneSerializerCall(array('foo' => 'bar'));
     $this->task->run();
 }