public function setUp()
 {
     parent::setUp();
     $this->xxx = eZContentLanguage::addLanguage('xxx-XX', 'XXXX');
     ezpINIHelper::setINISetting('site.ini', 'RegionalSettings', 'SiteLanguageList', array('xxx-XX', 'eng-GB'));
     eZContentLanguage::clearPrioritizedLanguages();
 }
 /**
  * Test setup
  *
  * Load an instance of file.ini
  * Assigns DB parameters for cluster
  **/
 public function setUp()
 {
     parent::setUp();
     // We need to clear the existing handler if it was loaded before the INI
     // settings changes
     eZClusterFileHandler::resetHandler();
     unset($GLOBALS['eZClusterInfo']);
     // Load database parameters for cluster
     // The same DSN than the relational database is used
     $dsn = ezpTestRunner::dsn()->parts;
     switch ($dsn['phptype']) {
         case 'mysql':
         case 'mysqli':
             $backend = 'eZDBFileHandlerMysqliBackend';
             break;
         case 'postgresql':
             $backend = 'eZDBFileHandlerPostgresqlBackend';
             break;
         default:
             $this->markTestSkipped("Unsupported database type '{$dsn['phptype']}'");
     }
     ezpINIHelper::setINISetting('file.ini', 'ClusteringSettings', 'FileHandler', 'eZDBFileHandler');
     ezpINIHelper::setINISetting('file.ini', 'ClusteringSettings', 'DBHost', $dsn['host']);
     ezpINIHelper::setINISetting('file.ini', 'ClusteringSettings', 'DBPort', $dsn['port']);
     ezpINIHelper::setINISetting('file.ini', 'ClusteringSettings', 'DBSocket', $dsn['socket']);
     ezpINIHelper::setINISetting('file.ini', 'ClusteringSettings', 'DBName', $dsn['database']);
     ezpINIHelper::setINISetting('file.ini', 'ClusteringSettings', 'DBUser', $dsn['user']);
     ezpINIHelper::setINISetting('file.ini', 'ClusteringSettings', 'DBPassword', $dsn['password']);
     ezpINIHelper::setINISetting('file.ini', 'ClusteringSettings', 'DBBackend', $backend);
     // ezpTestDatabaseHelper::insertSqlData( $this->sharedFixture, $this->sqlFiles );
     $this->db = $this->sharedFixture;
 }
 /**
  * Test scenario for issue #13492: Links are lost after removing version
  *
  * Test Outline
  * ------------
  * 1. Create a Folder in English containing a link (in the short_description attribute).
  * 2. Translate Folder into Norwegian containing another link (not the same link as above.)
  * 3. Remove Folder version 1. (Version 2 is created when translating).
  *
  * @result: short_description in version 2 will have an empty link.
  * @expected: short_description should contain same link as in version 1.
  * @link http://issues.ez.no/13492
  */
 public function testLinksAcrossTranslations()
 {
     ezpINIHelper::setINISetting('site.ini', 'RegionalSettings', 'ContentObjectLocale', 'eng-GB');
     $xmlDataEng = '<link href="/some-where-random">a link</link>';
     $xmlDataNor = '<link href="/et-tilfeldig-sted">en link</link>';
     // Step 1: Create folder
     $folder = new ezpObject("folder", 2);
     $folder->name = "Folder Eng";
     $folder->short_description = $xmlDataEng;
     $folder->publish();
     $version1Xml = $folder->short_description->attribute('output')->attribute('output_text');
     // Step 2: Translate folder
     $trData = array("name" => "Folder Nor", "short_description" => $xmlDataNor);
     $folder->addTranslation("nor-NO", $trData);
     // addTranslation() publishes too.
     // Step 3: Remove version 1
     $version1 = eZContentObjectVersion::fetchVersion(1, $folder->id);
     $version1->removeThis();
     // Grab current versions data and make sure it's fresh.
     $folder->refresh();
     $version2Xml = $folder->short_description->attribute('output')->attribute('output_text');
     $folder->remove();
     ezpINIHelper::restoreINISettings();
     self::assertEquals($version1Xml, $version2Xml);
 }
Ejemplo n.º 4
0
 public function setUp()
 {
     parent::setUp();
     ezpEvent::resetInstance();
     ezpINIHelper::setINISetting('site.ini', 'Event', 'Listeners', array('test/notify@ezpEventTest::helperNotify', 'test/filter@ezpEventTest::helperFilterNotNull'));
     $this->event = ezpEvent::getInstance();
 }
Ejemplo n.º 5
0
    /**
     * Test for the sort feature of country list
     */
    public function testFetchTranslatedNamesSort()
    {
        $translatedCountriesList = array(
            'FR' => 'France',
            'GB' => 'Royaume-uni',
            'DE' => 'Allemagne',
            'NO' => 'Norvège' );

        ezpINIHelper::setINISetting( array( 'fre-FR.ini', 'share/locale' ), 'CountryNames', 'Countries', $translatedCountriesList );
        ezpINIHelper::setINISetting( 'site.ini', 'RegionalSettings', 'Locale', 'fre-FR' );

        $countries = eZCountryType::fetchCountryList();
        $this->assertInternalType( 'array', $countries, "eZCountryType::fetchCountryList() didn't return an array" );

        $countryListIsSorted = true;
        foreach( $countries as $country )
        {
            if ( !isset( $previousCountry ) )
            {
                $previousCountry = $country;
                continue;
            }

            if ( strcoll( $previousCountry['Name'], $country['Name'] ) > 0 )
            {
                $countryListIsSorted = false;
                break;
            }
        }

        ezpINIHelper::restoreINISettings();
        $this->assertTrue( $countryListIsSorted, "Country list isn't sorted" );
    }
Ejemplo n.º 6
0
 /**
  * Test for {@link eZSolrBase::sendHTTPRequest()} with a request that will time out
  * An exception must be thrown in that case
  * @link http://issues.ez.no/17862
  * @group issue17862
  * @expectedException ezfSolrException
  */
 public function testSendHTTPRequestException()
 {
     ezpINIHelper::setINISetting('solr.ini', 'SolrBase', 'SearchServerURI', $this->nonReachableSolr);
     $solrBase = new eZSolrBase();
     $postString = $solrBase->buildPostString($this->postParams);
     $solrBase->sendHTTPRequest($solrBase->SearchServerURI . $this->testURI, $postString);
 }
 /**
  * Test for regression #13497:
  * attribute operator throws a PHP fatal error on a node without parent in a displayable language
  *
  * Situation:
  *  - siteaccess with one language (fre-FR) and ShowUntranslatedObjects disabled
  *  - parent content node in another language (eng-GB) with always available disabled
  *  - content node in the siteaccess' language (fre-FR)
  *  - fetch this fre-FR node from anywhere, and call attribute() on it
  *
  * Result:
  *  - Fatal error: Call to a member function attribute() on a non-object in
  *    kernel/classes/ezcontentobjecttreenode.php on line 4225
  *
  * Explanation: the error actually comes from the can_remove_location attribute
  */
 public function testIssue13497()
 {
     $bkpLanguages = eZContentLanguage::prioritizedLanguageCodes();
     // Create a folder in english only
     $folder = new ezpObject("folder", 2, 14, 1, 'eng-GB');
     $folder->setAlwaysAvailableLanguageID(false);
     $folder->name = "Parent for " . __FUNCTION__;
     $folder->publish();
     $locale = eZLocale::instance('fre-FR');
     $translation = eZContentLanguage::addLanguage($locale->localeCode(), $locale->internationalLanguageName());
     // Create an article in french only, as a subitem of the previously created folder
     $article = new ezpObject("article", $folder->attribute('main_node_id'), 14, 1, 'fre-FR');
     $article->title = "Object for " . __FUNCTION__;
     $article->short_description = "Description of test for " . __FUNCTION__;
     $article->publish();
     $articleNodeID = $article->attribute('main_node_id');
     // INi changes: set language to french only, untranslatedobjects disabled
     ezpINIHelper::setINISetting('site.ini', 'RegionalSettings', 'ContentObjectLocale', 'fre-FR');
     // ezpINIHelper::setINISetting( 'site.ini', 'RegionalSettings', 'SiteLanguageList', array( 'fre-FR' ) );
     eZContentLanguage::setPrioritizedLanguages(array('fre-FR'));
     ezpINIHelper::setINISetting('site.ini', 'RegionalSettings', 'ShowUntranslatedObjects', 'disabled');
     eZContentLanguage::expireCache();
     // This should crash
     eZContentObjectTreeNode::fetch($articleNodeID)->attribute('can_remove_location');
     ezpINIHelper::restoreINISettings();
     // re-expire cache for further tests
     eZContentLanguage::setPrioritizedLanguages($bkpLanguages);
     $article->remove();
     $translation->removeThis();
     eZContentLanguage::expireCache();
     ezpINIHelper::restoreINISettings();
 }
 public static function setUpDatabase()
 {
     $dsn = ezpTestRunner::dsn()->parts;
     switch ($dsn['phptype']) {
         case 'mysql':
         case 'mysqli':
             $backend = 'eZDFSFileHandlerMySQLiBackend';
             break;
         case 'postgresql':
             $backend = 'eZDFSFileHandlerPostgresqlBackend';
             if (!class_exists('eZDFSFileHandlerPostgresqlBackend')) {
                 self::markTestSkipped("Missing extension 'ezpostgresqlcluster', skipping PostgreSQL DFS tests");
             }
             break;
         default:
             self::markTestSkipped("Unsupported database type '{$dsn['phptype']}'");
     }
     // We need to clear the existing handler if it was loaded before the INI
     // settings changes
     eZClusterFileHandler::resetHandler();
     unset($GLOBALS['eZClusterInfo']);
     // Load database parameters for cluster
     // The same DSN than the relational database is used
     ezpINIHelper::setINISetting('file.ini', 'ClusteringSettings', 'FileHandler', 'eZDFSFileHandler');
     ezpINIHelper::setINISetting('file.ini', 'eZDFSClusteringSettings', 'DBHost', $dsn['host']);
     ezpINIHelper::setINISetting('file.ini', 'eZDFSClusteringSettings', 'DBPort', $dsn['port']);
     ezpINIHelper::setINISetting('file.ini', 'eZDFSClusteringSettings', 'DBSocket', $dsn['socket']);
     ezpINIHelper::setINISetting('file.ini', 'eZDFSClusteringSettings', 'DBName', $dsn['database']);
     ezpINIHelper::setINISetting('file.ini', 'eZDFSClusteringSettings', 'DBUser', $dsn['user']);
     ezpINIHelper::setINISetting('file.ini', 'eZDFSClusteringSettings', 'DBPassword', $dsn['password']);
     ezpINIHelper::setINISetting('file.ini', 'eZDFSClusteringSettings', 'MountPointPath', self::getDfsPath());
     ezpINIHelper::setINISetting('file.ini', 'eZDFSClusteringSettings', 'DBBackend', $backend);
 }
 public function setUp()
 {
     parent::setUp();
     $_SERVER['HTTP_USER_AGENT'] = 'Mozilla/5.0 (iPhone; CPU iPhone OS 5_0_1 like Mac OS X) AppleWebKit/534.46 (KHTML, like Gecko) Version/5.1 Mobile/9A405 Safari/7534.48.3';
     $_SERVER['HTTP_ACCEPT'] = 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8';
     // Enable mobile device detection
     ezpINIHelper::setINISetting('site.ini', 'SiteAccessSettings', 'DetectMobileDevice', 'enabled');
     $this->mobileDeviceDetect = $this->getMock('ezpMobileDeviceDetect', null, array($this->getMock('ezpMobileDeviceRegexpFilter', null)));
 }
 /**
  * Test setup
  *
  * Load an instance of file.ini
  */
 public function setUp()
 {
     parent::setUp();
     // We need to clear the existing handler if it was loaded before the INI
     // settings changes
     eZClusterFileHandler::resetHandler();
     // Load database parameters for cluster
     // The same DSN than the relational database is used
     ezpINIHelper::setINISetting('file.ini', 'ClusteringSettings', 'FileHandler', $this->clusterClass);
 }
 /**
  * Tests new filter object instance creation
  *
  */
 public function testGetFilter()
 {
     $mobileDeviceDetectFilter = ezpMobileDeviceDetectFilter::getFilter();
     $this->assertNotNull($mobileDeviceDetectFilter);
     $this->assertInstanceOf('ezpMobileDeviceDetectFilterInterface', $mobileDeviceDetectFilter);
     ezpINIHelper::setINISetting('site.ini', 'SiteAccessSettings', 'MobileDeviceFilterClass', '');
     $mobileDeviceDetectFilter = ezpMobileDeviceDetectFilter::getFilter();
     $this->assertNull($mobileDeviceDetectFilter);
     ezpINIHelper::restoreINISettings();
 }
Ejemplo n.º 12
0
 public function setUp()
 {
     parent::setUp();
     exec(eZINI::instance("image.ini")->variable("ImageMagick", "Executable") . " -version 2>&1", $output, $returnValue);
     if ($returnValue !== 0) {
         $this->markTestSkipped('ImageMagick is not installed');
     }
     $this->imageManager = eZImageManager::instance();
     $this->imageManager->readINISettings();
     ezpINIHelper::setINISetting('image.ini', 'ImageConverterSettings', 'ImageConverters', array('ImageMagick'));
 }
Ejemplo n.º 13
0
 public function setUp()
 {
     parent::setUp();
     eZINI::instance('ezfind.ini')->loadCache(true);
     eZINI::instance('solr.ini')->loadCache(true);
     ezpINIHelper::setINISetting('site.ini', 'SearchSettings', 'AllowEmptySearch', 'enabled');
     ezpINIHelper::setINISetting('site.ini', 'RegionalSettings', 'SiteLanguageList', array('eng-GB'));
     $this->solrSearch = new eZSolr();
     $this->testObj = eZContentObject::fetchByNodeID(2);
     $this->solrSearch->addObject($this->testObj);
     $this->fetchParams = array('SearchOffset' => 0, 'SearchLimit' => 10, 'Facet' => null, 'SortBy' => null, 'Filter' => null, 'SearchContentClassID' => null, 'SearchSectionID' => null, 'SearchSubTreeArray' => null, 'AsObjects' => null, 'SpellCheck' => null, 'IgnoreVisibility' => null, 'Limitation' => null, 'BoostFunctions' => null, 'QueryHandler' => 'ezpublish', 'EnableElevation' => null, 'ForceElevation' => null, 'SearchDate' => null, 'DistributedSearch' => null, 'FieldsToReturn' => null);
 }
Ejemplo n.º 14
0
 /**
  * Test setup
  *
  * Load an instance of file.ini
  **/
 public function setUp()
 {
     $this->markTestSkipped("Tests skipped until eZFS2 becomes more stable");
     parent::setUp();
     // We need to clear the existing handler if it was loaded before the INI
     // settings changes
     if (isset($GLOBALS['eZClusterFileHandler_chosen_handler']) and !$GLOBALS['eZClusterFileHandler_chosen_handler'] instanceof $this->clusterClass) {
         unset($GLOBALS['eZClusterFileHandler_chosen_handler']);
     }
     // Load database parameters for cluster
     // The same DSN than the relational database is used
     ezpINIHelper::setINISetting('file.ini', 'ClusteringSettings', 'FileHandler', $this->clusterClass);
 }
Ejemplo n.º 15
0
 public function setUp()
 {
     parent::setUp();
     ezpINIHelper::setINISetting('site.ini', 'SearchSettings', 'AllowEmptySearch', 'enabled');
     ezpINIHelper::setINISetting('site.ini', 'RegionalSettings', 'SiteLanguageList', array('eng-GB'));
     $this->findINI = eZINI::instance('ezfind.ini');
     $this->findINI->loadCache(true);
     $this->solrSearch = new eZSolr();
     $this->object = new ezpObject('folder', 2);
     $this->object->name = 'foo';
     $this->object->publish();
     $this->object->addNode(43);
     // Add a location under Media node
     $this->solrSearch->addObject($this->object->object);
 }
 /**
  * Unit test for eZContentClass::versionHistoryLimit() with object parameters
  *
  * Replica of testVersionHistoryLimit() but you cannot make calls
  * to the eZ API which relies on a database, as this is not present
  * in the provider methods.
  */
 public function testVersionHistoryLimitWithObjectParameter()
 {
     // different custom limits (article: 13, image: 6) and object as a parameter
     $INISettings = array(array('VersionHistoryClass', array('article' => 13, 'image' => 6)));
     $class = eZContentClass::fetchByIdentifier('image');
     $expectedLimit = 6;
     // change the INI limit settings
     foreach ($INISettings as $settings) {
         list($INIVariable, $INIValue) = $settings;
         ezpINIHelper::setINISetting('content.ini', 'VersionManagement', $INIVariable, $INIValue);
     }
     $limit = eZContentClass::versionHistoryLimit($class);
     self::assertEquals($expectedLimit, $limit);
     ezpINIHelper::restoreINISettings();
 }
Ejemplo n.º 17
0
    /**
     * Test for issue #16328: Wrong hash stored in database on hash update in ezUser.php
     */
    public function testPasswordHashSamePasswordToUser()
    {
        // Get the password_hash
        $db = eZDB::instance();
        $rows = $db->arrayQuery( "SELECT * FROM ezuser where login = '******'" );
        if ( count( $rows ) !== 1 )
        {
            $this->fail( "User {$this->username} is not in database.");
        }
        // Not used in this test
        $passwordHashMD5Password = $rows[0]['password_hash'];

        // Above it was only the setup for the test, the real test begins now
        // Set HashType to md5_user (password_hash in the ezuser table is updated again)
        ezpINIHelper::setINISetting( 'site.ini', 'UserSettings', 'HashType', 'md5_user' );

        // Login the user with email instead of username
        $userClass = eZUserLoginHandler::instance( 'standard' );
        $user = $userClass->loginUser( $this->email, $this->password );

        // Verify that the email and password were accepted
        if ( !( $user instanceof eZUser ) )
        {
            $this->fail( "User {$this->email} is not in database.");
        }

        // Get the password_hash
        $db = eZDB::instance();
        $rows = $db->arrayQuery( "SELECT * FROM ezuser where login = '******'" );
        $passwordHashMD5User = $rows[0]['password_hash'];

        // The value that is expected to be saved in the ezuser table after updating the HashType to md5_user
        // (using the username and not the email address, which caused issue #16328)
        $hashMD5Expected = md5( "{$this->username}\n{$this->password}" );

        // Verify that the 2 password hashes saved above are the same
        $this->assertEquals( $hashMD5Expected, $passwordHashMD5User );

        // Verify that the user can still login with username
        $userClass = eZUserLoginHandler::instance( 'standard' );
        $user = $userClass->loginUser( $this->username, $this->password );

        // Verify that the username and password were accepted
        if ( !( $user instanceof eZUser ) )
        {
            $this->fail( "User {$this->username} is not in database.");
        }
    }
Ejemplo n.º 18
0
 public function setUp()
 {
     parent::setUp();
     ezpINIHelper::setINISetting('site.ini', 'UserSettings', 'LoginHandler[]', 'textfile');
     ezpINIHelper::setINISetting('textfile.ini', 'TextFileSettings', 'TextFileEnabled', 'true');
     // the textfile.csv file contains a new line at the end, which causes issue #16322
     ezpINIHelper::setINISetting('textfile.ini', 'TextFileSettings', 'FileName', 'textfile.csv');
     ezpINIHelper::setINISetting('textfile.ini', 'TextFileSettings', 'FilePath', dirname(__FILE__) . DIRECTORY_SEPARATOR . 'data');
     ezpINIHelper::setINISetting('textfile.ini', 'TextFileSettings', 'FileFieldSeparator', ',');
     ezpINIHelper::setINISetting('textfile.ini', 'TextFileSettings', 'DefaultUserGroupType', 'id');
     ezpINIHelper::setINISetting('textfile.ini', 'TextFileSettings', 'DefaultUserGroup', '13');
     ezpINIHelper::setINISetting('textfile.ini', 'TextFileSettings', 'LoginAttribute', '1');
     ezpINIHelper::setINISetting('textfile.ini', 'TextFileSettings', 'PasswordAttribute', '3');
     ezpINIHelper::setINISetting('textfile.ini', 'TextFileSettings', 'FirstNameAttribute', '4');
     ezpINIHelper::setINISetting('textfile.ini', 'TextFileSettings', 'LastNameAttribute', '5');
     ezpINIHelper::setINISetting('textfile.ini', 'TextFileSettings', 'EmailAttribute', '2');
 }
 public function setUp()
 {
     parent::setUp();
     ezpINIHelper::setINISetting( "site.ini", "SiteAccessSettings", "MatchOrder", "host_uri" );
     ezpINIHelper::setINISetting(
         "site.ini",
         "SiteAccessSettings",
         "HostUriMatchMapItems",
         array(
             "www.example.com;abcd/foo;abcd_foo",
             "www.example.com;abcdef/foo;abcdef_foo",
             "www.example.com;abc/foo;abc_foo",
             "www.example.com;abcdefg/foo;abcdefg_foo",
             "www.example.com;abcde/foo;abcde_foo",
             "www.example.com;abcd;abcd",
             "www.example.com;abcdef;abcdef",
             "www.example.com;abc;abc",
             "www.example.com;abcdefg;abcdefg",
             "www.example.com;abcde;abcde",
             "www.example.com;admin;admin",
         )
     );
 }
    /**
     * Test scenario for issue #18336: Alignment in table cells is not rendered
     * properly if RenderParagraphInTableCells=disabled
     *
     * With RenderParagraphInTableCells=disabled, check that the align
     * attribute of eZXML paragraph is taken into account while rendering the
     * table cell containing this paragraph.
     *
     * @group issue_18336
     * @link http://issues.ez.no/18336
     * @note Test depends on template output!!
     */
    function testRenderAlignInCellsWithoutParagraph()
    {
        ezpINIHelper::setINISetting( 'ezxml.ini', 'ezxhtml', 'RenderParagraphInTableCells', 'disabled' );
        $xml = '<?xml version="1.0" encoding="utf-8"?>
<section xmlns:image="http://ez.no/namespaces/ezpublish3/image/" xmlns:xhtml="http://ez.no/namespaces/ezpublish3/xhtml/" xmlns:custom="http://ez.no/namespaces/ezpublish3/custom/">
<paragraph><table width="100%" custom:summary="Test alignment" custom:caption=""><tr><td align="right"><paragraph align="left">align=left</paragraph></td></tr></table></paragraph>
</section>';
        $outputHandler = new eZXHTMLXMLOutput( $xml, false );
        $expected = '<table class="renderedtable" cellpadding="2" cellspacing="0" width="100%" summary="Test alignment">
<tr>
<td class=" text-left" valign="top">  align=left
  </td>
</tr>

</table>
';
        $this->assertEquals( $expected, $outputHandler->outputText() );
        ezpINIHelper::restoreINISettings();
    }
 /**
  * Test for EZP-21986
  * Make sure the custom tag underline is transformed into a <u> tag
  *
  * @link https://jira.ez.no/browse/EZP-21986
  */
 public function testCustomUnderlineToU()
 {
     ezpINIHelper::setINISetting('content.ini', 'CustomTagSettings', 'AvailableCustomTags', array('underline'));
     ezpINIHelper::setINISetting('content.ini', 'CustomTagSettings', 'IsInline', array('underline' => 'true'));
     $xmlData = '<?xml version="1.0" encoding="utf-8"?>';
     $xmlData .= '<section xmlns:image="http://ez.no/namespaces/ezpublish3/image/"
         xmlns:xhtml="http://ez.no/namespaces/ezpublish3/xhtml/"
         xmlns:custom="http://ez.no/namespaces/ezpublish3/custom/">
         <paragraph>If I could <custom name="underline">sleep</custom> forever</paragraph>
     </section>';
     $folder = new ezpObject('folder', 2);
     $folder->name = 'The Dandy Warhols - Sleep';
     $folder->short_description = '';
     $oeHandler = new eZOEXMLInput($xmlData, false, $folder->short_description);
     $xhtml = $oeHandler->attribute('input_xml');
     self::assertEquals('&lt;p&gt;If I could &lt;u class=&quot;ezoeItemCustomTag underline&quot; type=&quot;custom&quot;&gt;sleep&lt;/u&gt; forever&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;', $xhtml);
     ezpINIHelper::restoreINISettings();
 }
 /**
  * Regression test for issue {@see #23753 http://issues.ez.no/23753}
  *
  * In a multi language environment, an untranslated node fetched with default language will return the
  * full URL alias in the language of the node.
  */
 public function testIssue23753()
 {
     $bkpLanguages = eZContentLanguage::prioritizedLanguageCodes();
     $strNameEngGB = __FUNCTION__ . " eng-GB";
     $strNameFreFR = __FUNCTION__ . " fre-FR";
     // add a secondary language
     $locale = eZLocale::instance('fre-FR');
     $translation = eZContentLanguage::addLanguage($locale->localeCode(), $locale->internationalLanguageName());
     // set the prioritize language list to contain english
     eZContentLanguage::setPrioritizedLanguages(array('fre-FR', 'eng-GB'));
     // Create an object with data in fre-FR and eng-GB
     $folder = new ezpObject('folder', 2, 14, 1, 'eng-GB');
     $folder->publish();
     // Workaround as setting folder->name directly doesn't produce the expected result
     $folder->addTranslation('eng-GB', array('name' => $strNameEngGB));
     $folder->addTranslation('fre-FR', array('name' => $strNameFreFR));
     $article = new ezpObject('article', $folder->main_node_id, 14, 1, 'eng-GB');
     $article->publish();
     // Workaround as setting article->name directly doesn't produce the expected result
     $article->addTranslation('eng-GB', array('title' => $strNameEngGB));
     $nodeId = $article->main_node_id;
     // fetch the node with no default parameters. Should return the french URL Alias when applicable
     $node = eZContentObjectTreeNode::fetch($nodeId);
     self::assertEquals('testIssue23753-fre-FR/testIssue23753-eng-GB', $node->attribute('url_alias'));
     // fetch the node in english. Should return the full english URL Alias
     $node = eZContentObjectTreeNode::fetch($nodeId, 'eng-GB');
     self::assertEquals('testIssue23753-eng-GB/testIssue23753-eng-GB', $node->attribute('url_alias'));
     // Test that PathPrefix is correctly removed from UrlAlias
     ezpINIHelper::setINISetting('site.ini', 'SiteAccessSettings', 'PathPrefix', 'testIssue23753-fre-FR');
     $node = eZContentObjectTreeNode::fetch($nodeId);
     self::assertEquals('testIssue23753-eng-GB', $node->attribute('url_alias'));
     $folder->remove();
     $translation->removeThis();
     ezpINIHelper::restoreINISettings();
     eZContentLanguage::setPrioritizedLanguages($bkpLanguages);
 }
Ejemplo n.º 23
0
 /**
  * Tests a problem which arose when a combined URL entry,
  * representing several translations are split up, by one translation being
  * changed to to an earlier history entry, of that same entry.
  *
  * Note: __FUNCTION__ will be appended to every name/title attribute in order
  * to ensure they will be unique to this test
  */
 function testURLAliasSplitParentTranslation()
 {
     ezpINIHelper::setINISetting('site.ini', 'RegionalSettings', 'SiteLanguageList', array('eng-GB', 'nor-NO'));
     eZContentLanguage::clearPrioritizedLanguages();
     $db = eZDB::instance();
     // STEP 1: Add test folder
     $folder = new ezpObject("folder", 2);
     $folder->name = __FUNCTION__;
     $folder->publish();
     // STEP 2: Add child below folder
     $child = new ezpObject("folder", $folder->mainNode->node_id);
     $child->name = "Child" . __FUNCTION__;
     $child->publish();
     // Sub-sub children disabled for now, might be used in future, for
     // further assertions.
     // // STEP 2a: Add a sub-sub child
     // $subChild1 = new ezpObject( 'article', $child->mainNode->node_id );
     // $subChild1->title = "SubChild";
     // $subChild1->publish();
     //
     // // STEP 2b: Add a sub-sub child
     // $subChild2 = new ezpObject( 'article', $child->mainNode->node_id );
     // $subChild2->title = "SubChildOther";
     // $subChild2->publish();
     //
     // // STEP 2ba: Adding sub-sub child translation
     // $norSubChild2Trans = array( "title" => "SubChildOtherNor" );
     // $subChild2->addTranslation( "nor-NO", $norSubChild2Trans );
     //
     // // STEP 2c: Add a sub-sub child
     // $subChild3 = new ezpObject( 'article', $child->mainNode->node_id );
     // $subChild3->title = "SubChildThird";
     // $subChild3->publish();
     //
     // // STEP 2ca: Addubg sub-sub child translation
     // $norSubChild3Trans = array( "title" => "SubChildThird" );
     // $subChild3->addTranslation( "nor-NO", $norSubChild3Trans );
     // STEP 3: Add translation to child with the same name
     $translationAttributes = array("name" => "Child" . __FUNCTION__);
     $child->addTranslation("nor-NO", $translationAttributes);
     // STEP 4: Update the translation
     $child->refresh();
     $newVersion = $child->createNewVersion(false, true, 'nor-NO');
     $norDataMap = $child->fetchDataMap($newVersion->attribute('version'), "nor-NO");
     $norDataMap['name']->setAttribute('data_text', 'NorChildChanged' . __FUNCTION__);
     $norDataMap['name']->store();
     ezpObject::publishContentObject($child->object, $newVersion);
     // STEP 5:
     $child->refresh();
     $child->name = "Renamed child" . __FUNCTION__;
     $child->publish();
     // STEP 6:
     $child->refresh();
     $child->name = "Child changed" . __FUNCTION__;
     $child->publish();
     // STEP 7:
     $child->refresh();
     $newVersion = $child->createNewVersion(false, true, 'nor-NO');
     $norDataMap = $child->fetchDataMap($newVersion->attribute('version'), "nor-NO");
     $norDataMap['name']->setAttribute('data_text', 'NorChildChanged again' . __FUNCTION__);
     $norDataMap['name']->store();
     ezpObject::publishContentObject($child->object, $newVersion);
     // STEP 8:
     $child->refresh();
     $newVersion = $child->createNewVersion(false, true, 'nor-NO');
     $norDataMap = $child->fetchDataMap($newVersion->attribute('version'), "nor-NO");
     $norDataMap['name']->setAttribute('data_text', 'Child changed' . __FUNCTION__);
     $norDataMap['name']->store();
     ezpObject::publishContentObject($child->object, $newVersion);
     // STEP 9:
     $child->refresh();
     $newVersion = $child->createNewVersion(false, true, 'nor-NO');
     $norDataMap = $child->fetchDataMap($newVersion->attribute('version'), "nor-NO");
     $norDataMap['name']->setAttribute('data_text', 'NorChildChanged again' . __FUNCTION__);
     $norDataMap['name']->store();
     ezpObject::publishContentObject($child->object, $newVersion);
     $query = self::buildSql(array($child->mainNode->node_id));
     $result = $db->arrayQuery($query);
     $initialTranslationChild = self::urlEntryForName("Child-changed" . __FUNCTION__, $result);
     $translationChild = self::urlEntryForName('NorChildChanged-again' . __FUNCTION__, $result);
     self::assertEquals((int) $initialTranslationChild['id'], (int) $translationChild['id'], "Current translations of the same node need to have the same id.");
     ezpINIHelper::restoreINISettings();
 }
 public function testConvertToAlias_Compat()
 {
     // We set the below ini settings to make sure they are not accidentally
     // overriden in somewhere in the test installation.
     ezpINIHelper::setINISetting('site.ini', 'URLTranslator', 'WordSeparator', 'underscore');
     ezpINIHelper::setINISetting('site.ini', 'URLTranslator', 'TransformationGroup', 'urlalias_compat');
     // ---------------------------------------------------------------- //
     // Not safe characters, all of these should be removed.
     $e1 = " &;/:=?[]()+#/{}\$*',^§±@.!_";
     $e1Result = "_1";
     // Safe characters. No char should be removed.
     $e2 = "abcdefghijklmnopqrstuvwxyz0123456789";
     $e2Result = $e2;
     // Random selection of funky characters. All chars should be removed.
     $e3 = "ウңҏѫあギᄍㄇᠢ⻲㆞ญ฿";
     $e3Result = "_1";
     // Make sure uppercase chars gets converted to lowercase.
     $e4 = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
     $e4Result = "abcdefghijklmnopqrstuvwxyz";
     // Make sure multiple dots are turned into a seperator (-) (dot is
     // allowed exepct beginning/end of url).
     $e5 = "..a...........b..";
     $e5Result = "a_b";
     self::assertEquals($e1Result, eZURLAliasML::convertToAlias($e1));
     self::assertEquals($e2Result, eZURLAliasML::convertToAlias($e2));
     self::assertEquals($e3Result, eZURLAliasML::convertToAlias($e3));
     self::assertEquals($e4Result, eZURLAliasML::convertToAlias($e4));
     self::assertEquals($e5Result, eZURLAliasML::convertToAlias($e5));
     // ---------------------------------------------------------------- //
     ezpINIHelper::restoreINISettings();
 }
    /**
     * Same test as {@link self::testRemovePendingSearchOnDeleteObject()}, with class based delayed indexing
     * @group issue_17932
     */
    public function testRemovePendingSearchWithClassBasedIndexing()
    {
        // Activate delayed indexing for folder content class only
        ezpINIHelper::setINISetting( 'site.ini', 'SearchSettings', 'DelayedIndexing', 'classbased' );
        ezpINIHelper::setINISetting( 'site.ini', 'SearchSettings', 'DelayedIndexingClassList', array( 'folder' ) );

        eZContentOperationCollection::deleteObject( $this->nodeIds );
        $filterConds = array(
            'action'        => 'index_object',
            'param'         => array( array( $this->folder->object->attribute( 'id' ) ) )
        );
        $pendingCount = eZPersistentObject::count( eZPendingActions::definition(), $filterConds );
        self::assertEquals( 0, $pendingCount, 'eZContentOperationCollection::deleteObject() must remove pending action for objects #'.implode( ', ', $this->objectIds ) );
    }
 /**
  * Tests if mobile device detection is enabled but MobileSiteAccessList is not provided
  *
  */
 public function testIsEnabledBadSetting()
 {
     ezpINIHelper::setINISetting('site.ini', 'SiteAccessSettings', 'MobileSiteAccessList', '');
     $this->assertFalse($this->mobileDeviceDetect->isEnabled());
 }
Ejemplo n.º 27
0
 /**
  * Test for issue #16893: Wrong charset encoding in notification email
  */
 public function testRegressionSetContentTypeCharset()
 {
     // Set a custom charset in site.ini which will be tested
     // if it's set properly in the sent mail
     ezpINIHelper::setINISetting('site.ini', 'MailSettings', 'OutputCharset', 'custom-charset');
     $mail = new eZMail();
     $mail->setBody(__FUNCTION__);
     $ezcResult = $mail->Mail->generate();
     preg_match("/Content-Type: text\\/plain; charset=custom-charset/", $ezcResult, $matches);
     $this->assertEquals(1, count($matches));
 }
Ejemplo n.º 28
0
 /**
  * See site.ini [MailSettings] ExcludeHeaders
  */
 public function testExcludeHaders()
 {
     self::markTestSkipped("Tests needs to use other email addresses");
     ezpINIHelper::setINISetting('site.ini', 'MailSettings', 'Transport', 'SMTP');
     ezpINIHelper::setINISetting('site.ini', 'MailSettings', 'ExcludeHeaders', array('bcc'));
     $mail = new eZMail();
     $mail->setReceiver('*****@*****.**', 'John Doe');
     $mail->setSender('*****@*****.**', 'Jane Doe');
     $mail->addBcc('*****@*****.**', 'Jim Doe');
     $mail->setSubject('Testing ExcludeHeaders');
     $mail->setBody('Jim should not get this email.');
     // BCC should be set at this point
     $this->assertTrue(strpos($mail->Mail->generateHeaders(), 'Bcc: Jim Doe <*****@*****.**>') > 0);
     // We don't care if the mail gets sent. What's important is what happens to the headers.
     eZMailTransport::send($mail);
     // BCC should not be set anymore at this point, because of ExcludeHeaders
     $this->assertFalse(strpos($mail->Mail->generateHeaders(), 'Bcc: Jim Doe <*****@*****.**>') > 0);
 }
Ejemplo n.º 29
0
 /**
  * Sets the active extensions
  *
  * @param string $type ActiveExtensions or ActiveAccessExtensions
  * @param array $extensions Extensions to set as active ones
  */
 private static function setExtensions($extensions, $type = 'ActiveExtensions')
 {
     ezpINIHelper::setINISetting('site.ini', 'ExtensionSettings', $type, $extensions);
     self::clearActiveExtensionsCache();
 }
Ejemplo n.º 30
0
 public function setUp()
 {
     ezpINIHelper::setINISetting('site.ini', 'ExtensionSettings', 'ExtensionDirectory', 'tests/tests/kernel/classes/extensions');
     self::clearActiveExtensionsCache();
     parent::setUp();
 }