<commit_before><?php
/**
 * Copyright 2016 Centreon
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

namespace Centreon\Test\Behat;

class DowntimeConfigurationListingPage implements ListingPage
{
    protected $context;

    /**
     *  Navigate to the downtime configuration listing page.
     *
     *  @param $context  Centreon context.
     *  @param $visit    True to visit the downtime configuration
     *                   listing page.
     */
    public function __construct($context, $visit = true)
    {
        // Visit page.
        $this->context = $context;
        if ($visit) {
            $this->context->visit('main.php?p=21001');
        }

        // Check that page is valid for this class.
        $mythis = $this;
        $this->context->spin(
            function ($context) use ($mythis) {
                return $mythis->isPageValid();
            },
            5,
            'Current page does not match class ' . __CLASS__
        );
    }

    /**
     *  Check that current page matches this class.
     *
     *  @return True if the current page matches this class.
     */
    public function isPageValid()
    {
        return $this->context->assertFind('css', 'input[name="search_author"]');
    }

    /**
     *  Get downtime listing.
     *
     *  @return An array of downtimes.
     */
    public function getEntries()
    {
        $entries = array();
        $elements = $this->context->getSession()->getPage()->findAll('css', '.list_one,.list_two');
        foreach ($elements as $element) {
            // Fetch entry.
            $entry = array();
            $entry['host'] = $this->context->assertFindIn(
                $element,
                'css',
                'td:nth-child(2)'
            )->getText();
            $entry['service'] = $this->context->assertFindIn(
                $element,
                'css',
                'td:nth-child(3)'
            )->getText();
            $entry['start'] = \DateTime::createFromFormat(
                'Y/m/d H:i',
                $this->context->assertFindIn(
                    $element,
                    'css',
                    'td:nth-child(4)'
                )->getText()
            )->getTimestamp();
            $entry['end'] = \DateTime::createFromFormat(
                'Y/m/d H:i',
                $this->context->assertFindIn(
                    $element,
                    'css',
                    'td:nth-child(5)'
                )->getText()
            )->getTimestamp();
            $entry['author'] = $this->context->assertFindIn(
                $element,
                'css',
                'td:nth-child(7)'
            )->getText();
            $entry['comment'] = $this->context->assertFindIn(
                $element,
                'css',
                'td:nth-child(8)'
            )->getText();
            $entry['started'] = $this->context->assertFindIn(
                $element,
                'css',
                'td:nth-child(9)'
            )->getText();
            $entry['started'] = ($entry['started'] == 'Yes') ? true : false;

            // Store entry in result set.
            $entries[] = $entry;
        }
        return $entries;
    }

    /**
     *  Get a specific downtime.
     *
     *  @param $entry  Downtime entry number in the listing.
     *
     *  @return An array with the downtime properties.
     */
    public function getEntry($entry)
    {
        $downtimes = $this->getEntries();
        if (!array_key_exists($entry, $downtimes)) {
            throw new \Exception('Downtime entry ' . $entry . ' does not exist');
        }
        return $downtimes[$entry];
    }

    /**
     *  Throw an exception. Downtimes are not inspectable.
     *
     *  @param $entry  Downtime entry number in the listing.
     */
    public function inspect($entry)
    {
        throw new \Exception('Downtimes are not inspectable');
    }

    /**
     *  Select an entry.
     *
     *  @param $entry   Downtime entry number in the listing.
     *  @param $select  True to select entry, false to unselect.
     */
    public function selectEntry($entry, $select = true)
    {
        $elements = $this->context->getSession()->getPage()->findAll('css', '.list_one,.list_two');
        if (!array_key_exists($entry, $elements)) {
            throw new \Exception('Downtime entry ' . $entry . ' does not exist');
        }
        $checkbox = $this->context->assertFindIn($elements[$entry], 'css', 'input[type="checkbox"]');
        if ($select) {
            $checkbox->check();
        } else {
            $checkbox->uncheck();
        }
    }

    /**
     *  Cancel selected downtimes.
     */
    public function cancel()
    {
        $this->context->setConfirmBox(true);
        $this->context->assertFind('css', 'input[name="submit2"]')->click();
    }
}
<commit_msg>* add display cycle downtime on downtimeConfigurationListingPage<commit_after><?php
/**
 * Copyright 2016 Centreon
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

namespace Centreon\Test\Behat;

class DowntimeConfigurationListingPage implements ListingPage
{
    protected $context;

    /**
     *  Navigate to the downtime configuration listing page.
     *
     * @param $context  Centreon context.
     * @param $visit    True to visit the downtime configuration
     *                   listing page.
     */
    public function __construct($context, $visit = true)
    {
        // Visit page.
        $this->context = $context;
        if ($visit) {
            $this->context->visit('main.php?p=21001');
        }

        // Check that page is valid for this class.
        $mythis = $this;
        $this->context->spin(
            function ($context) use ($mythis) {
                return $mythis->isPageValid();
            },
            5,
            'Current page does not match class ' . __CLASS__
        );
    }


    /**
     *  Check that current page matches this class.
     *
     * @return True if the current page matches this class.
     */
    public function isPageValid()
    {
        return $this->context->assertFind('css', 'input[name="search_author"]');
    }

    /**
     *  Get downtime listing.
     *
     * @return An array of downtimes.
     */
    public function getEntries()
    {
        $entries = array();
        $elements = $this->context->getSession()->getPage()->findAll('css', '.list_one,.list_two');
        foreach ($elements as $element) {
            // Fetch entry.
            $entry = array();
            $entry['host'] = $this->context->assertFindIn(
                $element,
                'css',
                'td:nth-child(2)'
            )->getText();
            $entry['service'] = $this->context->assertFindIn(
                $element,
                'css',
                'td:nth-child(3)'
            )->getText();
            $entry['start'] = \DateTime::createFromFormat(
                'Y/m/d H:i',
                $this->context->assertFindIn(
                    $element,
                    'css',
                    'td:nth-child(4)'
                )->getText()
            )->getTimestamp();
            $entry['end'] = \DateTime::createFromFormat(
                'Y/m/d H:i',
                $this->context->assertFindIn(
                    $element,
                    'css',
                    'td:nth-child(5)'
                )->getText()
            )->getTimestamp();
            $entry['author'] = $this->context->assertFindIn(
                $element,
                'css',
                'td:nth-child(7)'
            )->getText();
            $entry['comment'] = $this->context->assertFindIn(
                $element,
                'css',
                'td:nth-child(8)'
            )->getText();
            $entry['started'] = $this->context->assertFindIn(
                $element,
                'css',
                'td:nth-child(9)'
            )->getText();
            $entry['started'] = ($entry['started'] == 'Yes') ? true : false;

            // Store entry in result set.
            $entries[] = $entry;
        }
        return $entries;
    }

    /**
     *  Get a specific downtime.
     *
     * @param $entry  Downtime entry number in the listing.
     *
     * @return An array with the downtime properties.
     */
    public function getEntry($entry)
    {
        $downtimes = $this->getEntries();
        if (!array_key_exists($entry, $downtimes)) {
            throw new \Exception('Downtime entry ' . $entry . ' does not exist');
        }
        return $downtimes[$entry];
    }

    /**
     *  display downtime cycle.
     *
     */
    public function displayDowntimeCycle()
    {
        $this->context->assertFind('css', 'input[name="view_downtime_cycle"]')->check();
        $this->context->assertFindButton('SearchB')->click();
    }

    /**
     *  Throw an exception. Downtimes are not inspectable.
     *
     * @param $entry  Downtime entry number in the listing.
     */
    public function inspect($entry)
    {
        throw new \Exception('Downtimes are not inspectable');
    }

    /**
     *  Select an entry.
     *
     * @param $entry   Downtime entry number in the listing.
     * @param $select  True to select entry, false to unselect.
     */
    public function selectEntry($entry, $select = true)
    {
        $elements = $this->context->getSession()->getPage()->findAll('css', '.list_one,.list_two');
        if (!array_key_exists($entry, $elements)) {
            throw new \Exception('Downtime entry ' . $entry . ' does not exist');
        }
        $checkbox = $this->context->assertFindIn($elements[$entry], 'css', 'input[type="checkbox"]');
        if ($select) {
            $checkbox->check();
        } else {
            $checkbox->uncheck();
        }
    }

    /**
     *  Cancel selected downtimes.
     */
    public function cancel()
    {
        $this->context->setConfirmBox(true);
        $this->context->assertFind('css', 'input[name="submit2"]')->click();
    }
}

{'fraction_non_alphanumeric': 0.1371909807117631, 'fraction_numerical': 0.003984424522321833, 'mean_word_length': 1.7108492881688757, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 107, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7478950', 'n_tokens_mistral': 3107, 'n_tokens_neox': 2950, 'n_words': 767}