Skip to content

Commit

Permalink
Added VMU testing and main model Unit tests. Added further routes spe…
Browse files Browse the repository at this point in the history
…cifically for web panel.
  • Loading branch information
brandonscott committed May 15, 2014
1 parent 10acf8c commit ef15fbf
Show file tree
Hide file tree
Showing 56 changed files with 10,909 additions and 0 deletions.
24 changes: 24 additions & 0 deletions app/tests/PrivilegeTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?php
class PrivilegeTest extends TestCase{

public function testNewAdd()
{
$response = $this->call('POST', 'privileges', array("name" => "TestPrivilege"));
$responseAsJson = json_decode($response->getContent());

$this->assertEquals("TestPrivilege", $responseAsJson->name);

return $responseAsJson->id;
}

/**
* @depends testNewAdd
*/
public function testDelete($id)
{
$response = $this->call("DELETE", "privileges/$id");
$responseAsJson = json_decode($response->getContent());
$this->assertEquals(true, $responseAsJson->success);
}
}
?>
24 changes: 24 additions & 0 deletions app/tests/PulseTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?php
class PulseTest extends TestCase{

public function testNewAdd()
{
$response = $this->call('POST', 'pulses', array("server_id" => 1, "ram_usage" => 500, "cpu_usage" => 500, "disk_usage" => 500, "uptime" => 500, "timestamp" => 500));
$responseAsJson = json_decode($response->getContent());

$this->assertEquals(500, $responseAsJson->cpu_usage);

return $responseAsJson->id;
}

/**
* @depends testNewAdd
*/
public function testDelete($id)
{
$response = $this->call("DELETE", "pulses/$id");
$responseAsJson = json_decode($response->getContent());
$this->assertEquals(true, $responseAsJson->success);
}
}
?>
43 changes: 43 additions & 0 deletions app/tests/ServerGroupTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<?php
class ServerGroupTest extends TestCase{

public function testNewAdd()
{
$response = $this->call('POST', 'servergroups', array('name' => "Test ServerGroup"));
$responseAsJson = json_decode($response->getContent());

$this->assertEquals("Test ServerGroup", $responseAsJson->name);

return $responseAsJson->id;
}

public function testExistingAdd()
{
$response = $this->call('POST', 'servergroups', array('name' => "Test ServerGroup"));
$responseAsJson = json_decode($response->getContent());
$this->assertEquals(false, $responseAsJson->success);
}

/**
* @depends testNewAdd
*/
public function testEdit($id)
{
$response = $this->call("PUT", "servergroups/$id", array('name' => 'Test ServerGroupEdit'));
$responseAsJson = json_decode($response->getContent());
$this->assertEquals("Test ServerGroupEdit", $responseAsJson->name);
}

/**
* @depends testNewAdd
*/
public function testDelete($id)
{
$response = $this->call("DELETE", "servergroups/$id");
$responseAsJson = json_decode($response->getContent());
$this->assertEquals(true, $responseAsJson->success);
}


}
?>
24 changes: 24 additions & 0 deletions app/tests/ServerTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?php
class ServerTest extends TestCase{

public function testNewAdd()
{
$response = $this->call('POST', 'servers', array('servergroup_id' => 0, 'name' => "Test Server", 'available_disk' => 500, 'available_ram' => 500, 'cpu_speed' => 500, 'os_name' => "Test OS", 'os_version'=> "Test Version", "guid" => "NEWGUID"));
$responseAsJson = json_decode($response->getContent());

$this->assertEquals("Test Server", $responseAsJson->name);

return $responseAsJson->id;
}

/**
* @depends testNewAdd
*/
public function testDelete($id)
{
$response = $this->call("DELETE", "servers/$id");
$responseAsJson = json_decode($response->getContent());
$this->assertEquals(true, $responseAsJson->success);
}
}
?>
24 changes: 24 additions & 0 deletions app/tests/SubscriptionTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?php
class SubscriptionTest extends TestCase{

public function testNewAdd()
{
$response = $this->call('POST', 'subscriptions', array('servergroup_id' => 33, 'user_id' => 1, 'phonecall' => 1, 'text' => 1, 'push' => 1));
$responseAsJson = json_decode($response->getContent());

$this->assertEquals(33, $responseAsJson->servergroup_id);

return $responseAsJson->id;
}

/**
* @depends testNewAdd
*/
public function testDelete($id)
{
$response = $this->call("DELETE", "subscriptions/$id");
$responseAsJson = json_decode($response->getContent());
$this->assertEquals(true, $responseAsJson->success);
}
}
?>
41 changes: 41 additions & 0 deletions app/tests/UserTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<?php
class UserTest extends TestCase{

public function testNewAdd()
{
$response = $this->call('POST', 'users', array('privilege_id' => 3, 'password' => 'Test', 'email' => "[email protected]", 'first_name' => 'Test' , 'last_name' => 'Test', 'mobile_number' => '+447935928168'));
$responseAsJson = json_decode($response->getContent());

$this->assertEquals(3, $responseAsJson->privilege_id);

return $responseAsJson->id;
}

public function testExistingAdd()
{
$response = $this->call('POST', 'users', array('privilege_id' => 3, 'password' => 'Test', 'email' => "[email protected]", 'first_name' => 'Test' , 'last_name' => 'Test', 'mobile_number' => '+447935928168'));
$responseAsJson = json_decode($response->getContent());
$this->assertEquals(false, $responseAsJson->success);
}

/**
* @depends testNewAdd
*/
public function testEdit($id)
{
$response = $this->call('PUT', "users/$id", array('email' => "[email protected]", 'first_name' => 'Test' , 'last_name' => 'Test', 'mobile_number' => '+447935928168'));
$responseAsJson = json_decode($response->getContent());
$this->assertEquals("[email protected]", $responseAsJson->email);
}

/**
* @depends testNewAdd
*/
public function testDelete($id)
{
$response = $this->call("DELETE", "users/$id");
$responseAsJson = json_decode($response->getContent());
$this->assertEquals(true, $responseAsJson->success);
}
}
?>
6 changes: 6 additions & 0 deletions vpu/.htaccess
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteBase /vpu
RewriteRule ^$ app/public/ [L]
RewriteRule (.*) app/public/$1 [L]
</IfModule>
130 changes: 130 additions & 0 deletions vpu/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
# Changelog

## v2.2

* Add CLI switches to allow config overrides (GH-93)
* Add support for multiple XML files (GH-93)
* Allow for multiple test directories to be specified (GH-93)
* Throw exception if cache permissions are incorrect (GH-96)

## v2.1.1

* Don't allow duplicate files if the parent folder is selected (GH-90)
* Pad snapshot time with zero for better sorting (GH-87)
* Only collect JSON when using XML configuration files (GH-84)
* Show server error if AJAX request fails (GH-83)
* Don't rewrite PHP_SELF (GH-80)
* Use namespace when checking if tests are subclasses of PHPUnit_Framework_TestCase (GH-78)
* Fix WAMP routing issues (GH-53)
* Implement keyboard shortcuts (GH-67)
* Fix output parsing to handle pretty-printed JSON (GH-65)
* Fix display of statistics (GH-63)
* Clarify directory selection key combination (GH-60)
* Check if tests are subclasses of PHPUnit_Framework_TestCase (GH-59)

## v2.1

* Add ability to ignore hidden files (GH-57)
* Add error handler for non-JSON responses from the server (GH-48, GH-58)
* Use strict checking with readdir() (GH-56)
* Handle unbalanced braces properly (GH-54)
* Fix error that occurs when no snapshot is selected on Archives page (GH-50)
* Reduce complexity of Apache installations (GH-45)
* Fix autoloader to only load files required by VPU (GH-46)
* Only return child directories of test_directory (GH-44)

## v2.0

* Overhaul the entire code base
* Give the UI a facelift
* Add ability to run tests using a phpunit.xml configuration file (GH-31)
* Add ability to generate test results from the command line (GH-32)

## v1.5.6

* Replace line breaks with <br>s instead of empty strings (GH-42)
* Fix jqueryFileTree folder selection for Macs (GH-41)
* Fix display of debugging output (GH-39)
* Add ability to set MySQL port (GH-37)

## v1.5.5

* Change require -> require_once to avoid errors (GH-34)
* Don't require files to share the same name as the test classes (GH-33)
* Fix output buffering (GH-23)

## v1.5.4

* Fix include_path issues (GH-26)

## v1.5.3

* Fix SANDBOX_IGNORE settings (GH-21)
* Update history file (GH-20)

## v1.5.2

* Add tooltips to compensate for colorblind usage problem (GH-17)
* Add ability to filter suite results (GH-14)

## v1.5.1

* Update color scheme
* Update snapshot list each time a test is run (GH-10)
* Fix snapshot filenames to be compatible with Windows systems (GH-11)
* Allow debug display of JSON within tests (GH-9)
* Fix POST locations to use relative URIs

## v1.5

* Add ability to generate graphs of test results

## v1.4.1

* Fix Windows path issues
* Add a progress bar to indicate that tests are being processed

## v1.4

* Overhaul the UI
* Fix issues with namespaced tests
* Implement a better check for archived files


## v1.3.2

* Add support for bootstraps
* Clean up the user interface
* Add the ability to view snapshots from the homepage
* Change the snapshot filename format to Y-m-d

## v1.3.1

* Allow for relative paths in TEST_DIRECTORY
* Use a better test loading mechanism

## v1.3

* Add a start page to allow for specific choosing of tests and options
* Add the ability to sort suite results by status and time
* Clean up some configuration settings
* Remove ability to save JSON snapshots

## v1.2

* Add statistic bars to display the suite results visually

## v1.1.1

* Fix to allow for loading a single test directly
* Adjust code to allow for proper execution with 'short_open_tag' off
* Fix to match test files with the word 'Test' at the end of the filename
* Fix to eliminate duplicate tests

## v1.1

* Add suite statistics

## v1.0

* Initial release
33 changes: 33 additions & 0 deletions vpu/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
VisualPHPUnit

Copyright (c) 2011-2012, Nick Sinopoli <[email protected]>.
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:

* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.

* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in
the documentation and/or other materials provided with the
distribution.

* Neither the name of Nick Sinopoli nor the names of his
contributors may be used to endorse or promote products derived
from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
Loading

0 comments on commit ef15fbf

Please sign in to comment.