Skip to content

Commit

Permalink
[Tests] Improve MaximumSupportedLanguagesTest to detect 32bit db on 6…
Browse files Browse the repository at this point in the history
…4bit PHP/HHVM issue
  • Loading branch information
andrerom committed Dec 17, 2014
1 parent ef3e033 commit 0b000bd
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 1 deletion.
Expand Up @@ -9,6 +9,9 @@

namespace eZ\Publish\API\Repository\Tests;


use eZ\Publish\API\Repository\Tests\SetupFactory\Legacy as LegacySetupFactory;

/**
* Test case for maximum number of languages supported in the LanguageService.
*
Expand Down Expand Up @@ -40,13 +43,35 @@ public function setUp()
$languageCreate = $this->languageService->newLanguageCreateStruct();
$languageCreate->enabled = true;

// SKIP If using sqlite, PHP 5.3 and 64bit, tests will fail as int column seems to be limited to 32bit on 64bit
if ( PHP_VERSION_ID < 50400 && PHP_INT_SIZE === 8 )
{
$setupFactory = $this->getSetupFactory();
if ( $setupFactory instanceof LegacySetupFactory && $setupFactory->getDB() === 'sqlite' )
{
$this->markTestSkipped( "Skip on Sqlite, PHP 5.3 and 64bit, as int column is limited to 32bit on 64bit" );
}
}

// Create as much languages as possible
for ( $i = count( $this->languageService->loadLanguages() ) + 1; $i <= 8 * PHP_INT_SIZE - 2; ++$i )
{
$languageCreate->name = "Language $i";
$languageCreate->languageCode = sprintf( "lan-%02d", $i );

$this->createdLanguages[] = $this->languageService->createLanguage( $languageCreate );
try
{
$this->createdLanguages[] = $this->languageService->createLanguage( $languageCreate );
}
catch ( \Exception $e )
{
if ( PHP_INT_SIZE === 8 && $i === 32 )
{
throw new \Exception( "PHP/HHVM is 64bit, but seems INT column in db only supports 32bit", 0, $e );
}

throw new \Exception( "Unknown issue on iteration $i, PHP_INT_SIZE: " . PHP_INT_SIZE, 0, $e );
}
}
}

Expand Down
10 changes: 10 additions & 0 deletions eZ/Publish/API/Repository/Tests/SetupFactory/Legacy.php
Expand Up @@ -407,4 +407,14 @@ protected function getServiceContainer()

return self::$serviceContainer;
}

/**
* Get the Database name
*
* @return string
*/
public function getDB()
{
return self::$db;
}
}

0 comments on commit 0b000bd

Please sign in to comment.