-
-
Notifications
You must be signed in to change notification settings - Fork 67
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Install] provided behat install feature, to test Install module, fix #…
- Loading branch information
Showing
3 changed files
with
169 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
@install | ||
Feature: Yawik installation | ||
In order to start using Yawik | ||
As an administrator | ||
I should able to install yawik application | ||
|
||
|
||
Background: | ||
Given I don't have "install@example.com" user | ||
And I have install module activated | ||
|
||
Scenario: Successfully install yawik | ||
Given I go to the install page | ||
Then I should see "Prerequisites" | ||
When I fill database connection with an active connection | ||
And I fill in "Initial user name" with "install@example.com" | ||
And I fill in "Password" with "test" | ||
And I fill in "Email address for system messages" with "install@example.com" | ||
And I press "Install" | ||
And I wait for the ajax response | ||
Then I should see "\"install@example.com\" was created successfully" | ||
And I should see "The base configuration file was successfully created" | ||
And I should see "Start using YAWIK" | ||
|
||
Scenario: Install yawik with empty configuration | ||
Given I go to the install page | ||
And I press "Install" | ||
And I wait for the ajax response | ||
Then I should see "Value is required" | ||
|
||
Scenario: Install yawik with invalid database connection | ||
Given I go to the install page | ||
And I fill in "db_conn" with "invalid" | ||
And I press "Install" | ||
And I wait for the ajax response | ||
Then I should see "Invalid connection string" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<?php | ||
|
||
/** | ||
* YAWIK | ||
* | ||
* @filesource | ||
* @license MIT | ||
* @copyright 2013 - 2017 Cross Solution <http://cross-solution.de> | ||
* @author Anthonius Munthi <me@itstoni.com> | ||
* @since 0.30 | ||
*/ | ||
|
||
return [ | ||
'Install' | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,118 @@ | ||
<?php | ||
|
||
/** | ||
* YAWIK | ||
* | ||
* @filesource | ||
* @license MIT | ||
* @copyright 2013 - 2017 Cross Solution <http://cross-solution.de> | ||
*/ | ||
|
||
namespace Yawik\Behat; | ||
|
||
use Behat\Behat\Context\Context; | ||
use Behat\Behat\Hook\Scope\AfterScenarioScope; | ||
|
||
/** | ||
* Class InstallContext | ||
* | ||
* @package Yawik\Behat | ||
* @author Anthonius Munthi <me@itstoni.com> | ||
*/ | ||
class InstallContext implements Context | ||
{ | ||
use CommonContextTrait; | ||
|
||
static private $configFile; | ||
|
||
static private $yawikGlobalConfig; | ||
|
||
static private $yawikBackupConfig; | ||
|
||
public function __construct() | ||
{ | ||
static::$configFile = getcwd() . '/config/autoload/install.module.php'; | ||
static::$yawikGlobalConfig = getcwd() . '/config/autoload/yawik.config.global.php'; | ||
static::$yawikBackupConfig = str_replace('yawik.config.global.php', 'yawik.backup', static::$yawikGlobalConfig); | ||
} | ||
|
||
/** | ||
* @Given I have install module activated | ||
*/ | ||
public function iHaveInstallModuleActivated() | ||
{ | ||
$target = static::$configFile; | ||
if(!file_exists($target)){ | ||
$source = __DIR__.'/../resources/install.module.php'; | ||
copy($source,$target); | ||
chmod($target,0777); | ||
} | ||
|
||
// backup existing file | ||
$yawikBackupConfig = static::$yawikBackupConfig; | ||
$yawikGlobalConfig = static::$yawikGlobalConfig; | ||
|
||
if(is_file($yawikGlobalConfig)){ | ||
rename($yawikGlobalConfig,$yawikBackupConfig); | ||
} | ||
} | ||
|
||
/** | ||
* @Given I go to the install page | ||
*/ | ||
public function iGoToInstallPage() | ||
{ | ||
$url = $this->generateUrl('/'); | ||
$url = str_replace('/en','',$url); | ||
$this->visit($url); | ||
} | ||
|
||
/** | ||
* @AfterSuite | ||
*/ | ||
static public function tearDown() | ||
{ | ||
static::restoreConfig(); | ||
} | ||
|
||
/** | ||
* @AfterScenario | ||
*/ | ||
public function afterScenario() | ||
{ | ||
static::restoreConfig(); | ||
} | ||
|
||
/** | ||
* @BeforeSuite | ||
*/ | ||
static public function setUp() | ||
{ | ||
static::restoreConfig(); | ||
} | ||
|
||
static public function restoreConfig() | ||
{ | ||
if(is_file($file = static::$configFile)){ | ||
unlink($file); | ||
} | ||
|
||
// restore backup | ||
$yawikBackupConfig = static::$yawikBackupConfig; | ||
$yawikGlobalConfig = static::$yawikGlobalConfig; | ||
|
||
if(is_file($yawikBackupConfig)){ | ||
rename($yawikBackupConfig,$yawikGlobalConfig); | ||
} | ||
} | ||
|
||
/** | ||
* @Given I fill database connection with an active connection | ||
*/ | ||
public function iFillActiveConnectionString() | ||
{ | ||
$config = $this->getService('config'); | ||
$connection = $config['doctrine']['connection']['odm_default']['connectionString']; | ||
$this->minkContext->fillField('db_conn',$connection); | ||
} | ||
} |