mirror of
https://github.com/stan220/testcontainers-php.git
synced 2026-09-09 05:29:42 +00:00
- Move most of the stuff for backwards compatibility support into one class
- Added random port logic - Updated wait wtrategies - API alignments to make it similar to other official implementations - ...
This commit is contained in:
@@ -4,39 +4,12 @@ declare(strict_types=1);
|
||||
|
||||
namespace Testcontainers\Container;
|
||||
|
||||
use Testcontainers\Wait\WaitForLog;
|
||||
|
||||
class MySQLContainer extends GenericContainer
|
||||
/**
|
||||
* Left for namespace backward compatibility
|
||||
* @deprecated Use \Testcontainers\Modules\MySQLContainer instead.
|
||||
* TODO: Remove in next major release.
|
||||
*/
|
||||
class MySQLContainer extends \Testcontainers\Modules\MySQLContainer
|
||||
{
|
||||
public function __construct(string $version = 'latest', string $mysqlRootPassword = 'root')
|
||||
{
|
||||
parent::__construct('mysql:' . $version);
|
||||
$this->withExposedPorts(3306);
|
||||
$this->withEnvironment('MYSQL_ROOT_PASSWORD', $mysqlRootPassword);
|
||||
$this->withWait(new WaitForLog('ready for connections'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Use constructor instead
|
||||
* Left for backward compatibility
|
||||
*/
|
||||
public static function make(string $version = 'latest', string $mysqlRootPassword = 'root'): self
|
||||
{
|
||||
return new self($version, $mysqlRootPassword);
|
||||
}
|
||||
|
||||
public function withMySQLUser(string $username, string $password): self
|
||||
{
|
||||
$this->withEnvironment('MYSQL_USER', $username);
|
||||
$this->withEnvironment('MYSQL_PASSWORD', $password);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function withMySQLDatabase(string $database): self
|
||||
{
|
||||
$this->withEnvironment('MYSQL_DATABASE', $database);
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user