throwException example


  public function testBuildWithException($exception_class$exception_argument) {
    $this->context->expects($this->once())
      ->method('getPathInfo')
      ->willReturn('/example/bar');
    $this->setupStubPathProcessor();

    $this->requestMatcher->expects($this->any())
      ->method('matchRequest')
      ->will($this->throwException(new $exception_class($exception_argument)));

    $breadcrumb = $this->builder->build($this->createMock('Drupal\Core\Routing\RouteMatchInterface'));

    // No path matched, though at least the frontpage is displayed.     $this->assertEquals([0 => new Link('Home', new Url('<front>'))]$breadcrumb->getLinks());
    $this->assertEqualsCanonicalizing(['url.path.is_front', 'url.path.parent']$breadcrumb->getCacheContexts());
    $this->assertEqualsCanonicalizing([]$breadcrumb->getCacheTags());
    $this->assertEquals(Cache::PERMANENT, $breadcrumb->getCacheMaxAge());
  }

  /** * Provides exception types for testBuildWithException. * * @return array * The list of exception test cases. * * @see \Drupal\Tests\system\Unit\Breadcrumbs\PathBasedBreadcrumbBuilderTest::testBuildWithException() */

    public function __construct($options = [])
    {
        if ($options instanceof Zend_Config) {
            $options = $options->toArray();
        }
        if (!is_array($options)) {
            Zend_Cache::throwException('Options passed were not an array'
            . ' or Zend_Config instance.');
        }
        foreach ($options as $name => $value) {
            $this->setOption($name$value);
        }
        $this->_loggerSanity();
    }

    /** * Set options using an instance of type Zend_Config * * @param Zend_Config $config * * @return Zend_Cache_Core */
/** * Tests the createFromRequest method. * * @covers ::createFromRequest */
  public function testCreateFromRequest() {
    $request = Request::create('/test-path');

    $this->router->expects($this->once())
      ->method('matchRequest')
      ->with($request)
      ->will($this->throwException(new ResourceNotFoundException()));

    $this->expectException(ResourceNotFoundException::class);
    Url::createFromRequest($request);
  }

  /** * Tests the isExternal() method. * * @depends testFromUri * @dataProvider providerFromUri * * @covers ::isExternal */

    public function load($id$doNotTestCacheValidity = false)
    {
        if (($id = (string)$id) === '') {
            $id = $this->_detectId();
        } else {
            $id = $this->_decodeId($id);
        }
        if (!$this->_verifyPath($id)) {
            Zend_Cache::throwException('Invalid cache id: does not match expected public_dir path');
        }
        if ($doNotTestCacheValidity) {
            $this->_log("Zend_Cache_Backend_Static::load() : \$doNotTestCacheValidity=true is unsupported by the Static backend");
        }

        $fileName = basename($id);
        if ($fileName === '') {
            $fileName = $this->_options['index_filename'];
        }
        $pathName = $this->_options['public_dir'] . dirname($id);
        $file     = rtrim($pathName, '/') . '/' . $fileName . $this->_options['file_extension'];
        
/** * Set the frontend directives * * @param array $directives Assoc of directives * * @throws Zend_Cache_Exception */
    public function setDirectives($directives)
    {
        if (!is_array($directives)) {
            Zend_Cache::throwException('Directives parameter must be an array');
        }
        foreach ($directives as $name => $value) {
            if (!is_string($name)) {
                Zend_Cache::throwException("Incorrect option name : $name");
            }
            $name = strtolower($name);
            if (array_key_exists($name$this->_directives)) {
                $this->_directives[$name] = $value;
            }
        }

        
$t->send(new RawMessage(''));
        $cursor = $this->assertTransports($t, -1, []);
        $t->send(new RawMessage(''));
        $cursor = $this->assertTransports($t, 0 === $cursor ? 1 : 0, []);
        $t->send(new RawMessage(''));
        $this->assertTransports($t, 0 === $cursor ? 1 : 0, []);
    }

    public function testSendAllDead()
    {
        $t1 = $this->createMock(TransportInterface::class);
        $t1->expects($this->once())->method('send')->will($this->throwException(new TransportException()));
        $t2 = $this->createMock(TransportInterface::class);
        $t2->expects($this->once())->method('send')->will($this->throwException(new TransportException()));
        $t = new RoundRobinTransport([$t1$t2]);
        $p = new \ReflectionProperty($t, 'cursor');
        $p->setValue($t, 0);

        try {
            $t->send(new RawMessage(''));
        } catch (\Exception $e) {
            $this->assertInstanceOf(TransportException::class$e);
            $this->assertStringContainsString('All transports failed.', $e->getMessage());
            
/** * Constructor * * @param array $options associative array of options * @throws Zend_Cache_Exception * @return void */
    public function __construct(array $options = array())
    {
        if (!extension_loaded('apc')) {
            Zend_Cache::throwException('The apc extension must be loaded for using this backend !');
        }
        parent::__construct($options);
    }

    /** * Test if a cache is available for the given id and (if yes) return it (false else) * * WARNING $doNotTestCacheValidity=true is unsupported by the Apc backend * * @param string $id cache id * @param boolean $doNotTestCacheValidity if set to true, the cache validity won't be tested * @return string cached datas (or false) */
/** * Constructor * * @param array $options associative array of options * @throws Zend_Cache_Exception * @return void */
    public function __construct(array $options = array())
    {
        if (!extension_loaded('apcu')) {
            Zend_Cache::throwException('The apcu extension must be loaded for using this backend !');
        }
        parent::__construct($options);
    }

    /** * Test if a cache is available for the given id and (if yes) return it (false else) * * WARNING $doNotTestCacheValidity=true is unsupported by the Apcu backend * * @param string $id cache id * @param boolean $doNotTestCacheValidity if set to true, the cache validity won't be tested * @return string cached datas (or false) */
/** * Constructor * Validate that the Zend Platform is loaded and licensed * * @param array $options Associative array of options * @throws Zend_Cache_Exception * @return void */
    public function __construct(array $options = array())
    {
        if (!function_exists('accelerator_license_info')) {
            Zend_Cache::throwException('The Zend Platform extension must be loaded for using this backend !');
        }
        if (!function_exists('accelerator_get_configuration')) {
            $licenseInfo = accelerator_license_info();
            Zend_Cache::throwException('The Zend Platform extension is not loaded correctly: '.$licenseInfo['failure_reason']);
        }
        $accConf = accelerator_get_configuration();
        if (@!$accConf['output_cache_licensed']) {
            Zend_Cache::throwException('The Zend Platform extension does not have the proper license to use content caching features');
        }
        if (@!$accConf['output_cache_enabled']) {
            Zend_Cache::throwException('The Zend Platform content caching feature must be enabled for using this backend, set the \'zend_accelerator.output_cache_enabled\' directive to On !');
        }


    public function testSetsEnvironmentVariableToFalseIfTriggersCanNotBeCreated(): void
    {
        $this->setEnvVars([BlueGreenDeploymentService::ENV_NAME => '1']);

        $connection = $this->createMock(Connection::class);
        $connection->expects(static::exactly(3))
            ->method('executeQuery')
            ->willReturnOnConsecutiveCalls(
                $this->createMock(Result::class),
                static::throwException(new Exception()),
                $this->createMock(Result::class)
            );

        $service = new BlueGreenDeploymentService();
        $session = new Session(new MockArraySessionStorage());
        $service->setEnvironmentVariable($connection$session);

        static::assertFalse($_ENV[BlueGreenDeploymentService::ENV_NAME]);
        static::assertFalse($_SERVER[BlueGreenDeploymentService::ENV_NAME]);
        static::assertFalse(EnvironmentHelper::getVariable(BlueGreenDeploymentService::ENV_NAME));
        static::assertFalse($session->get(BlueGreenDeploymentService::ENV_NAME));
    }
/** * Constructor * * @param array $options associative array of options * @throws Zend_Cache_Exception * @return void */
    public function __construct(array $options = array())
    {
        if (!extension_loaded('wincache')) {
            Zend_Cache::throwException('The wincache extension must be loaded for using this backend !');
        }
        parent::__construct($options);
    }

    /** * Test if a cache is available for the given id and (if yes) return it (false else) * * WARNING $doNotTestCacheValidity=true is unsupported by the WinCache backend * * @param string $id cache id * @param boolean $doNotTestCacheValidity if set to true, the cache validity won't be tested * @return string cached datas (or false) */

    public function __construct(array $options = array())
    {
        while (list($name$value) = each($options)) {
            $this->setOption($name$value);
        }
        if ($this->_specificOptions['cached_entity'] === null) {
            Zend_Cache::throwException('cached_entity must be set !');
        }
        $this->setCachedEntity($this->_specificOptions['cached_entity']);
        $this->setOption('automatic_serialization', true);
    }

    /** * Set a specific life time * * @param int $specificLifetime * @return void */
    

    protected $_redis = null;

    /** * @param array $options associative array of options * * @throws Zend_Cache_Exception */
    public function __construct(array $options = [])
    {
        if (!extension_loaded('redis')) {
            Zend_Cache::throwException('The redis extension must be loaded for using this backend !');
        }
        parent::__construct($options);
        $this->_redis = new Redis();

        foreach ($this->_options['servers'] as $server) {
            if (!array_key_exists('port', $server)) {
                $server['port'] = self::DEFAULT_PORT;
            }
            if (!array_key_exists('host', $server)) {
                $server['host'] = self::DEFAULT_HOST;
            }
            
$condition_true = $this->createMock('Drupal\Core\Condition\ConditionInterface');
    $condition_true->expects($this->any())
      ->method('execute')
      ->willReturn(TRUE);
    $condition_false = $this->createMock('Drupal\Core\Condition\ConditionInterface');
    $condition_false->expects($this->any())
      ->method('execute')
      ->willReturn(FALSE);
    $condition_exception = $this->createMock('Drupal\Core\Condition\ConditionInterface');
    $condition_exception->expects($this->any())
      ->method('execute')
      ->will($this->throwException(new ContextException()));
    $condition_exception->expects($this->atLeastOnce())
      ->method('isNegated')
      ->willReturn(FALSE);
    $condition_negated = $this->createMock('Drupal\Core\Condition\ConditionInterface');
    $condition_negated->expects($this->any())
      ->method('execute')
      ->will($this->throwException(new ContextException()));
    $condition_negated->expects($this->atLeastOnce())
      ->method('isNegated')
      ->willReturn(TRUE);

    

    public function __construct(array $options = array())
    {
        while (list($name$value) = each($options)) {
            $this->setOption($name$value);
        }
        if (!isset($this->_specificOptions['master_files'])) {
            Zend_Cache::throwException('master_files option must be set');
        }
    }

    /** * Change the master_files option * * @param array $masterFiles the complete paths and name of the master files */
    public function setMasterFiles(array $masterFiles)
    {
        $this->_specificOptions['master_file']  = null; // to keep a compatibility
Home | Imprint | This part of the site doesn't use cookies.