Skip to content
This repository has been archived by the owner on Dec 13, 2022. It is now read-only.

Commit

Permalink
HostDuplicationCheck created (#5377)
Browse files Browse the repository at this point in the history
* HostDuplicationCheck created

* Every tests in one step

* The 'add' were deleted

* Unused line deleted

* Update HostDuplicationCheck.feature
  • Loading branch information
mariegallardo authored and kduret committed Jun 26, 2017
1 parent 556b868 commit d4b9313
Show file tree
Hide file tree
Showing 3 changed files with 83 additions and 0 deletions.
5 changes: 5 additions & 0 deletions behat.yml
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,11 @@ default:
contexts:
- HostConfigurationContext

host_duplication_check:
paths: [ %paths.base%/features/HostDuplicationCheck.feature ]
contexts:
- HostDuplicationCheckContext

contact_group_creation_duplication:
paths: [ %paths.base%/features/ContactGroupCreationDuplication.feature ]
contexts:
Expand Down
12 changes: 12 additions & 0 deletions features/HostDuplicationCheck.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
Feature: HostDuplicationCheck
As a Centreon admin user
I want to duplicate a host
To see if the Properties have changed

Background:
Given I am logged in a Centreon server

Scenario: Duplicate a host and check the properties
Given a host is created
When I duplicate a host
Then the host properties are updated
66 changes: 66 additions & 0 deletions features/bootstrap/HostDuplicationCheckContext.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
<?php

use Centreon\Test\Behat\CentreonContext;
use Centreon\Test\Behat\Configuration\HostConfigurationPage;
use Centreon\Test\Behat\Configuration\HostConfigurationListingPage;
use Centreon\Test\Behat\External\ListingPage;

class HostDuplicationCheckContext extends CentreonContext
{
private $currentPage;

private $initialProperties = (array(
'name' => 'hostName',
'alias' => 'hostAlias',
'address' => 'host@localhost',
'enabled' => 1
));

private $updatedProperties = (array(
'name' => 'hostName_1',
'alias' => 'hostAlias',
'address' => 'host@localhost',
'enabled' => 1
));

/**
* @Given a host is created
*/
public function aHostIsCreated()
{
$this->currentPage = new HostConfigurationPage($this);
$this->currentPage->setProperties($this->initialProperties);
$this->currentPage->save();
}

/**
* @When I duplicate a host
*/
public function whenIDuplicateAHost()
{
$this->currentPage = new HostConfigurationListingPage($this);
$object = $this->currentPage->getEntry($this->initialProperties['name']);
$this->assertFind('css', 'input[type="checkbox"][name="select[' . $object['id'] . ']"]')->check();
$this->setConfirmBox(true);
$this->selectInList('select[name="o1"]', 'Duplicate');
}

/**
* @Then the host properties are updated
*/
public function theHostPropertiesAreUpdated()
{
$this->currentPage = new HostConfigurationListingPage($this);
$this->currentPage = $this->currentPage->inspect($this->updatedProperties['name']);
$object = $this->currentPage->getProperties();
$tableau = array();
foreach ($this->updatedProperties as $key => $value) {
if ($value != $object[$key]) {
$tableau[] = $key;
}
}
if (count($tableau) > 0) {
throw new \Exception("Some properties are not being updated : " . implode(', ', $tableau));
}
}
}

0 comments on commit d4b9313

Please sign in to comment.