librenms/tests/AlertingTest.php
Tony Murray e18f4522d5
Update to Laravel 5.7 (PHP 7.3 support) (#9800)
* Move assets to 5.7 location

* Add 5.7 SVGs

* add cache data dir

* update QUEUE_DRIVER -> QUEUE_CONNECTION

* Update trusted proxy config

* update composer.json

* 5.5 command loading

* @php and @endphp can't be inline

* Laravel 5.6 logging, Nice!

* Update blade directives

* improved redirects

* remove unneeded service providers

* Improved debugbar loading

* no need to emulate renderable exceptions anymore

* merge updated 5.7 files (WIP)

* Enable CSRF

* database_path() call causes issue in init.php

* fix old testcase name

* generic phpunit 7 fixes

* add missed file_get_contents
Keep migrations table content

* fix duplicate key

* Drop old php versions from travis-ci

* remove hhvm

* fix code climate message

* remove use of deprecated function assertInternalType

* Disable CSRF, we'll enable it separately.
All forms need to be updated to work.

* Update document references
2019-02-12 17:45:04 -06:00

71 lines
2.3 KiB
PHP

<?php
/**
* AlertingTest.php
*
* Tests for alerting functionality.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* @package LibreNMS
* @link http://librenms.org
* @copyright 2016 Neil Lathwood
* @author Neil Lathwood <neil@lathwood.co.uk>
*/
namespace LibreNMS\Tests;
use RecursiveDirectoryIterator;
use RecursiveIteratorIterator;
use RecursiveRegexIterator;
use RegexIterator;
class AlertTest extends TestCase
{
public function testJsonAlertCollection()
{
$rules = get_rules_from_json();
$this->assertIsArray($rules);
foreach ($rules as $rule) {
$this->assertIsArray($rule);
}
}
public function testTransports()
{
foreach ($this->getTransportFiles() as $file => $_unused) {
$parts = explode('/', $file);
$transport = ucfirst(str_replace('.php', '', array_pop($parts)));
$class = 'LibreNMS\\Alert\\Transport\\'.$transport;
if (!class_exists($class)) {
$this->assertTrue(false, "The transport $transport does not exist");
} else {
$methods = ['deliverAlert', 'configTemplate', 'contact'.$transport];
foreach ($methods as $method) {
if (!method_exists($class, $method)) {
$this->assertTrue(false, "The transport $transport does not have the method $method");
}
}
}
}
$this->expectNotToPerformAssertions();
}
private function getTransportFiles()
{
$iterator = new RecursiveIteratorIterator(new RecursiveDirectoryIterator('LibreNMS/Alert/Transport'));
return new RegexIterator($iterator, '/^.+\.php$/i', RecursiveRegexIterator::GET_MATCH);
}
}