setMandatory() публичный Метод

public setMandatory ( boolean $mandatory )
$mandatory boolean
 public function testConfigSuggestion()
 {
     $message = 'some message';
     $configArray = array('foo' => 'bar');
     $suggestion = new ConfigSuggestion($message, $configArray);
     $this->assertSame($message, $suggestion->getMessage());
     $this->assertSame($configArray, $suggestion->getSuggestion());
     $this->assertFalse($suggestion->isMandatory());
     $newMessage = 'foo bar';
     $suggestion->setMessage($newMessage);
     $this->assertSame($newMessage, $suggestion->getMessage());
     $newConfigArray = array('ez' => 'publish');
     $suggestion->setSuggestion($newConfigArray);
     $this->assertSame($newConfigArray, $suggestion->getSuggestion());
     $suggestion->setMandatory(true);
     $this->assertTrue($suggestion->isMandatory());
 }
    public function testFormat()
    {
        $message = <<<EOT
Database configuration has changed for eZ Content repository.
Please define:
 - An entry in ezpublish.repositories
 - A Doctrine connection (You may check configuration reference for Doctrine "config:dump-reference doctrine" console command.)
 - A reference to configured repository in ezpublish.system.foo.repository
EOT;
        $suggestion = new ConfigSuggestion($message);
        $suggestion->setMandatory(true);
        $suggestionArray = array('doctrine' => array('dbal' => array('connections' => array('default' => array('driver' => 'pdo_mysql', 'host' => 'localhost', 'dbname' => 'my_database', 'user' => 'my_user', 'password' => 'some_password', 'charset' => 'UTF8')))), 'ezpublish' => array('repositories' => array('my_repository' => array('engine' => 'legacy', 'connection' => 'default')), 'system' => array('foo' => array('repository' => 'my_repository'))));
        $suggestion->setSuggestion($suggestionArray);
        $expectedMessage = <<<EOT
Database configuration has changed for eZ Content repository.
Please define:
 - An entry in ezpublish.repositories
 - A Doctrine connection (You may check configuration reference for Doctrine "config:dump-reference doctrine" console command.)
 - A reference to configured repository in ezpublish.system.foo.repository


Example:
========

doctrine:
    dbal:
        connections:
            default:
                driver: pdo_mysql
                host: localhost
                dbname: my_database
                user: my_user
                password: some_password
                charset: UTF8
ezpublish:
    repositories:
        my_repository:
            engine: legacy
            connection: default
    system:
        foo:
            repository: my_repository
EOT;
        $formatter = new YamlSuggestionFormatter();
        $this->assertSame($expectedMessage, trim($formatter->format($suggestion)));
    }
Пример #3
0
    private function addDatabaseConfigSuggestion($sa, array $databaseConfig)
    {
        $suggestion = new ConfigSuggestion(<<<EOT
Database configuration has changed for eZ Content repository.
Please define:
 - An entry in ezpublish.repositories
 - A Doctrine connection (You may check configuration reference for Doctrine "config:dump-reference doctrine" console command.)
 - A reference to configured repository in ezpublish.system.{$sa}.repository
EOT
);
        $suggestion->setMandatory(true);
        $suggestionArray = array('driver' => 'pdo_mysql', 'host' => 'localhost', 'dbname' => 'my_database', 'user' => 'my_user', 'password' => 'some_password', 'charset' => 'UTF8');
        if (!empty($databaseConfig)) {
            $suggestionArray['dbname'] = $databaseConfig['database_name'];
            $suggestionArray['host'] = $databaseConfig['server'];
            $driverMap = array('mysql' => 'pdo_mysql', 'pgsql' => 'pdo_pgsql', 'sqlite' => 'pdo_sqlite');
            if (isset($driverMap[$databaseConfig['type']])) {
                $suggestionArray['driver'] = $driverMap[$databaseConfig['type']];
            } else {
                $suggestionArray['driver'] = $databaseConfig['type'];
            }
            if (isset($databaseConfig['socket'])) {
                $suggestionArray['unix_socket'] = $databaseConfig['socket'];
            }
            $suggestionArray['options'] = $databaseConfig['options'];
            $suggestionArray['user'] = $databaseConfig['user'];
            $suggestionArray['password'] = $databaseConfig['password'];
        }
        $suggestion->setSuggestion(array('doctrine' => array('dbal' => array('connections' => array('default' => $suggestionArray))), 'ezpublish' => array('repositories' => array('my_repository' => array('engine' => 'legacy', 'connection' => 'default')), 'system' => array($sa => array('repository' => 'my_repository')))));
        $this->suggestionCollector->addSuggestion($suggestion);
    }