/** * @dataProvider providerCreateWithValidIdentifier */ public function testCreateWithvalidIdentifier($identifier) { $row = array('identifier' => $identifier); $stateGroup = new eZContentObjectStateGroup($row); $trans = $stateGroup->translationByLocale('eng-GB'); $trans->setAttribute('name', $identifier); $messages = array(); $this->assertTrue($stateGroup->isValid($messages), "Valid state group identifier '{$identifier}' was refused, " . var_export($messages, true)); }
$localeIDToUse = false; // this script inserts English names, so preferably use an English locale $preferredLocales = array('eng-GB', 'eng-US'); foreach ($preferredLocales as $preferredLocale) { if (in_array($preferredLocale, $locales)) { $localeToUse = $preferredLocale; break; } } // when none of the preferred locales are in use, then use the top priority language if ($localeToUse === false) { $prioritizedLanguage = eZContentLanguage::topPriorityLanguage(); $localeToUse = $prioritizedLanguage->attribute('locale'); } $lockGroup = new eZContentObjectStateGroup(array('identifier' => 'ez_lock')); $trans = $lockGroup->translationByLocale($localeToUse); $trans->setAttribute('name', 'Lock'); $trans->setAttribute('description', 'Lock group'); $messages = array(); if ($lockGroup->isValid($messages)) { $cli->output('storing state group ez_lock'); $lockGroup->store(); } else { eZDebug::writeDebug($messages); $db->rollback(); $script->shutdown(2); } $notLockedState = $lockGroup->newState('not_locked'); $trans = $notLockedState->translationByLocale($localeToUse); $trans->setAttribute('name', 'Not locked'); $trans->setAttribute('description', 'Not locked state');