Skip to content
Snippets Groups Projects
Commit 053c43b5 authored by Yas Naoi's avatar Yas Naoi
Browse files

Complied with Drupal coding standard

parent ae38aa08
No related branches found
No related tags found
No related merge requests found
Showing
with 32565 additions and 499 deletions
<?php
/**
* @file
* Contains \Drupal\aws_cloud\Controller\Ec2\ElasticIpListBuilder.
*/
// udpated by yas 2016/05/25
// updated by yas 2016/05/23
// updated by yas 2016/05/21
// updated by yas 2016/05/20
// updated by yas 2016/05/19
// updated by yas 2016/05/18
// created by yas 2016/04/21
namespace Drupal\aws_cloud\Controller\Ec2;
use Drupal\cloud\Controller\CloudContentListBuilder;
use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Url;
/**
* Provides a listing of ElasticIp.
*/
class ElasticIpListBuilder extends CloudContentListBuilder {
/**
* {@inheritdoc}
*/
public function buildHeader() {
$header = array(
// The header gives the table the information it needs in order to make
// the query calls for ordering. TableSort uses the field information
// to know what database column to sort by.
// field should be 'field', not 'specifier' in ConfigEntity
array('data' => t('Name' ), 'specifier' => 'name', 'sort' => 'ASC'),
array('data' => t('Elastic IP' ), 'specifier' => 'elastic_ip' ),
array('data' => t('Allocation ID' ), 'specifier' => 'allocation_id' ),
array('data' => t('Instance' ), 'specifier' => 'instance_id' ),
array('data' => t('Private IP Address'), 'specifier' => 'private_ip_address' ),
array('data' => t('Scope' ), 'specifier' => 'scope' ),
array('data' => t('Public DNS' ), 'specifier' => 'public_dns' ),
);
return $header + parent::buildHeader();
}
/**
* {@inheritdoc}
*/
public function buildRow(EntityInterface $entity) {
$row['name'] = \Drupal::l(
$this->getLabel($entity),
$entity->urlInfo('canonical')
// @FIXME to use image_id()
// ->setRouteParameter('aws_cloud_elastic_ip', $entity->elastic_ip() )
->setRouteParameter('aws_cloud_elastic_ip', $entity->id() )
->setRouteParameter('cloud_context' , $entity->cloud_context())
);
$row['elastic_ip' ] = $entity->elastic_ip();
$row['allocation_id' ] = $entity->allocation_id();
$row['instance_id' ] = $entity->instance_id();
$row['private_ip_address'] = $entity->private_ip_address();
$row['scope' ] = $entity->scope();
$row['public_dns' ] = $entity->public_dns();
return $row + parent::buildRow($entity);
}
}
......@@ -3,109 +3,126 @@
/**
* @file
* Hooks provided by Cloud.
* This is a documentation file
*
* This is a documentation file.
*/
/**
* This hook lets subclouds implement cloud actions.
*
* @param string $op
* The operation to be executed: launch, launch_using params,
* terminate, check_key_sg_data, check_key_data, check_sg_data, get_images_count,
* backup, detach_volume, check_snapshot_completion, check_volume_attached_status, check_instance_terminated
* get_instance_lock_status
* NOTE: for get_instance_lock_status, the params array should contain the instance/vm id against the instance_id key, for all clouds
* The operation to be executed: launch, launch_using params,
* terminate, check_key_sg_data, check_key_data, check_sg_data, get_images_count,
* backup, detach_volume, check_snapshot_completion, check_volume_attached_status, check_instance_terminated
* get_instance_lock_status
* NOTE: for get_instance_lock_status, the params array should contain the instance/vm id against the instance_id key, for all clouds
* @param array $params
* An array contain all the required information. The cloud_context is passed
* as one of the array elements.
* An array contain all the required information. The cloud_context is passed
* as one of the array elements.
*/
function hook_cloud_action($op, $params = array()) {
switch ($op) {
case 'launch':
break;
case 'launch_using_params':
break;
case 'post_launch':
break;
case 'terminate':
break;
case 'check_key_sg_data':
break;
case 'check_key_data':
break;
case 'check_sg_data':
break;
case 'get_images_count':
break;
case 'backup':
break;
case 'detach_volume':
break;
case 'check_snapshot_completion':
break;
case 'check_volume_attached_status':
break;
case 'check_instance_terminated':
break;
case 'get_instance_lock_status':
break;
}
}
switch ($op) {
case 'launch':
break;
case 'launch_using_params':
break;
case 'post_launch':
break;
case 'terminate':
break;
case 'check_key_sg_data':
break;
case 'check_key_data':
break;
case 'check_sg_data':
break;
case 'get_images_count':
break;
case 'backup':
break;
case 'detach_volume':
break;
case 'check_snapshot_completion':
break;
case 'check_volume_attached_status':
break;
case 'check_instance_terminated':
break;
case 'get_instance_lock_status':
break;
}
}
/**
* This hook returns the list of instances presented in an enabled
* sub-cloud.
*
* @param string $cloud_context
* The sub-cloud to return information from
* The sub-cloud to return information from
* @param array $filter
* An array of filters passed from the UI
* An array of filters passed from the UI
*/
function hook_cloud_get_all_instances($cloud_context, $filter = array()) {
//return your instance information from the database
// Return your instance information from the database.
}
/**
* This hook returns data about a particular sub-cloud
* This hook returns data about a particular sub-cloud.
*
* @param string $cloud_context
* The sub-cloud to query and return data
* The sub-cloud to query and return data
* @param array $filter
* An array of filters passed from the UI
* An array of filters passed from the UI
*/
function hook_cloud_get_instance($cloud_context, $filter = array()) {
//return your sub-cloud information
// Return your sub-cloud information.
}
/**
* This hook returns the ssh key for a particular user
* This hook returns the ssh key for a particular user.
*
* @param array $params
* The param array contains the key_name, cloud_context
* The param array contains the key_name, cloud_context
*/
function hook_cloud_get_ssh_key($params) {
//return your ssh key information from the database
// Return your ssh key information from the database.
}
/**
* This hook is called when data about a particular sub-cloud
* needs to be downloaded.
*
* @param string $cloud_context
* The sub-cloud for which the information is to be retrieved
* The sub-cloud for which the information is to be retrieved
*/
function hook_cloud_update_data($cloud_context) {
//download your cloud data here
// Download your cloud data here.
}
/**
* This hook sets some initialization information about a
* This hook sets some initialization information about a
* particular sub-cloud. This hook isn't really utilized
* with the new cloud administration ui. Sub-clouds that
* have not been moved to the new ui still uses this hook
* with the new cloud administration ui. Sub-clouds that
* have not been moved to the new ui still uses this hook.
*
* @param string $cloud_context
* Cloud context is passed if your module implements
* more than one variant of your cloud. For example: the
* OpenStack, Eucalyptus and Amazon EC2 implementations are
* handled by one module. cloud_context is used to distingush
* the different sub-clouds.
* Cloud context is passed if your module implements
* more than one variant of your cloud. For example: the
* OpenStack, Eucalyptus and Amazon EC2 implementations are
* handled by one module. cloud_context is used to distingush
* the different sub-clouds.
*/
function hook_cloud_set_info($cloud_context = '') {
return array(
......@@ -113,13 +130,13 @@ function hook_cloud_set_info($cloud_context = '') {
'cloud_name' => CONTEXT,
'module' => 'xcp',
'base_cloud' => 'xcp',
'instance_types' => array(
'instance_types' => array(
XCP_DEFAULT_INSTANCE_TYPE => XCP_DEFAULT_INSTANCE_TYPE,
),
'cloud_pricing_data' => array(
XCP_DEFAULT_INSTANCE_TYPE => array(
'instance_type' => XCP_DEFAULT_INSTANCE_TYPE,
'description' => t('Default'),
XCP_DEFAULT_INSTANCE_TYPE => array(
'instance_type' => XCP_DEFAULT_INSTANCE_TYPE,
'description' => t('Default'),
'linux_or_unix_cost' => '0.085',
'windows_cost' => '0.089',
),
......@@ -131,38 +148,39 @@ function hook_cloud_set_info($cloud_context = '') {
/**
* This hook is called when a sub-cloud row is saved
* into the table cloud_clouds. This allows sub-cloud modules to
* take the data and store it in different places or
* into the table cloud_clouds. This allows sub-cloud modules to
* take the data and store it in different places or
* do something else with it. The cloud_pricing and cloud_server_template
* modules have implemented this hook
* modules have implemented this hook.
*
* @param string $op
* The op can be 'create' or 'edit'
* The op can be 'create' or 'edit'
* @param object $cloud
*/
function hook_cloud_save($op, $cloud) {
//do something with the data
// Do something with the data.
}
/**
* This hook is called when a sub-cloud row is
* deleted from the table cloud_clouds. The cloud_pricing
* This hook is called when a sub-cloud row is
* deleted from the table cloud_clouds. The cloud_pricing
* and cloud_server_template modules have implemented this hook.
*
* @param unknown_type $cloud_name
*/
function hook_cloud_delete($cloud_name) {
//do something to the sub-cloud
// Do something to the sub-cloud.
}
/**
* Thsi hook is called to return a specific piece
* of information about a sub-cloud. For example, the
* cloud module will need to retrieve the host_uri, or
* cloud module will need to retrieve the host_uri, or
* user/password. the aws_cloud module implements this hook.
*
* @param string $cloud_name
* @param string $key
*/
function hook_cloud_get_info($cloud_name, $key) {
//return any name/value pairs
// Return any name/value pairs.
}
......@@ -2,46 +2,44 @@
/**
* @file
* Defines constants for cloud.module
* Defines constants for cloud.module.
*
*/
/**
* @file
* Provides common functionalites for cloud management.
*/
drupal_set_time_limit(5000);
//project name as a prefix to all project specific tables
define('CLOUD_PREFIX' , 'cloud_' );
define('CLOUD_NONE' , '- none -' );
define('CLOUD_CLOUDS_TABLE' , CLOUD_PREFIX . 'clouds' );
define('CLOUD_TEMP_TABLE' , CLOUD_PREFIX . 'temp_table' );
define('CLOUD_INSTANCE_TYPE_TABLE' , CLOUD_PREFIX . 'instance_types' );
define('CLOUD_PREFIX' , 'cloud_');
define('CLOUD_NONE' , '- none -');
define('CLOUD_CLOUDS_TABLE' , CLOUD_PREFIX . 'clouds');
define('CLOUD_TEMP_TABLE' , CLOUD_PREFIX . 'temp_table');
define('CLOUD_INSTANCE_TYPE_TABLE' , CLOUD_PREFIX . 'instance_types');
define('CLOUD_PAGER_LIMIT' , 50 );
define('CLOUD_PAGER_LIMIT' , 50);
define('CLOUD_SSH_USER_NAME' , 'root' );
define('CLOUD_SSH_USER_NAME' , 'root');
define('CLOUD_RRD_FILE' , 'rrd.php' );
define('CLOUD_REMOTE_SNMP_MANAGER' , 'cloud_snmp_manager.php' );
define('CLOUD_RRD_FILE' , 'rrd.php');
define('CLOUD_REMOTE_SNMP_MANAGER' , 'cloud_snmp_manager.php');
// This Module Name list will be mainly used to check whether the Module is enabled or no.
//for linux
define('CLOUD_PATH_SEPARATOR' , '/' );
define('CLOUD_PHP_PATH' , 'php' );
define('CLOUD_SSH_PATH' , 'ssh' );
define('CLOUD_SCP_PATH' , 'scp' );
define('CLOUD_HOST_ENTRIES_REFRESH_TIME', 5 );
define('CLOUD_INPUTS_PARAMETER_VALUES_TABLE', CLOUD_PREFIX . 'inputs_parameter_values' );
define('CLOUD_INSTANCE_STATUS_BOOTING' , 'booting' );
define('CLOUD_INSTANCE_STATUS_OPERATIONAL', 'operational' );
define('CLOUD_PATH_SEPARATOR' , '/');
define('CLOUD_PHP_PATH' , 'php');
define('CLOUD_SSH_PATH' , 'ssh');
define('CLOUD_SCP_PATH' , 'scp');
define('CLOUD_HOST_ENTRIES_REFRESH_TIME', 5);
define('CLOUD_INPUTS_PARAMETER_VALUES_TABLE', CLOUD_PREFIX . 'inputs_parameter_values');
define('CLOUD_INSTANCE_STATUS_BOOTING' , 'booting');
define('CLOUD_INSTANCE_STATUS_OPERATIONAL', 'operational');
/**
* DIGIT [0-9] only without decimal point. int value only
......
coder.txt 0 → 100644
This diff is collapsed.
<?php
/**
* @file
* Contains Drupal\cloud_alert\CloudAlertInterface.
*/
// updated by yas 2016/05/23
// Updated by yas 2016/05/23.
namespace Drupal\cloud_alert;
use Drupal\Core\Entity\ContentEntityInterface;
use Drupal\Core\Entity\EntityTypeInterface;
use Drupal\user\EntityOwnerInterface;
/**
......
<?php
/**
* @file
* Contains Drupal\cloud_alert\Controller\CloudAlertAccessControlHandler.
*/
// updated by yas 2016/05/23
// Updated by yas 2016/05/23.
namespace Drupal\cloud_alert\Controller;
use Drupal\Core\Entity\EntityAccessControlHandler;
......@@ -20,6 +14,7 @@ use Drupal\Core\Access\AccessResult;
* @see \Drupal\cloud_alert\Entity\CloudAlert.
*/
class CloudAlertAccessControlHandler extends EntityAccessControlHandler {
/**
* {@inheritdoc}
*/
......@@ -45,4 +40,5 @@ class CloudAlertAccessControlHandler extends EntityAccessControlHandler {
protected function checkCreateAccess(AccountInterface $account, array $context, $entity_bundle = NULL) {
return AccessResult::allowedIfHasPermission($account, 'add cloud alert');
}
}
<?php
/**
* @file
* Contains Drupal\cloud_alert\Controller\CloudAlertListController.
*/
// updated by yas 2016/05/24
// Updated by yas 2016/05/24.
namespace Drupal\cloud_alert\Controller;
use Drupal\cloud\Controller\CloudContentListBuilder;
......@@ -19,6 +13,7 @@ use Drupal\Core\Url;
* @ingroup cloud_alert
*/
class CloudAlertListController extends CloudContentListBuilder {
/**
* {@inheritdoc}
*/
......@@ -28,8 +23,8 @@ class CloudAlertListController extends CloudContentListBuilder {
// The header gives the table the information it needs in order to make
// the query calls for ordering. TableSort uses the field information
// to know what database column to sort by.
array('data' => t('Name' ), 'specifier' => 'name', 'sort' => 'ASC'),
array('data' => t('Description' ), 'specifier' => 'description' ),
array('data' => t('Name'), 'specifier' => 'name', 'sort' => 'ASC'),
array('data' => t('Description'), 'specifier' => 'description'),
);
return $header + parent::buildHeader();
......@@ -40,9 +35,9 @@ class CloudAlertListController extends CloudContentListBuilder {
*/
public function buildRow(EntityInterface $entity) {
// for debug
// $row['id'] = $entity->id();
// $row['uuid'] = $entity->uuid();
// For debug
// $row['id'] = $entity->id();
// $row['uuid'] = $entity->uuid();
$row['name'] = \Drupal::l(
$this->getLabel($entity),
new Url(
......@@ -56,4 +51,5 @@ class CloudAlertListController extends CloudContentListBuilder {
return $row + parent::buildRow($entity);
}
}
<?php
/**
* @file
* Contains \Drupal\cloud_alert\Controller\CloudAlertsController.
*/
namespace Drupal\cloud_alert\Controller;
\Drupal::moduleHandler()->loadInclude('cloud', 'inc', 'cloud.constants');
/**
*
*/
class CloudAlertsController {
}
?>
\ No newline at end of file
<?php
/**
* @file
* Contains Drupal\cloud_alert\Entity\CloudAlert.
*/
// updated by yas 2016/05/23
// Updated by yas 2016/05/23.
namespace Drupal\cloud_alert\Entity;
use Drupal\Core\Entity\EntityStorageInterface;
......@@ -178,12 +172,12 @@ class CloudAlert extends ContentEntityBase implements CloudAlertInterface {
'type' => 'string',
'weight' => -5,
))
/*
/*
->setDisplayOptions('form', array(
'type' => 'string_textfield',
'weight' => -6,
))
*/
*/
->setDisplayConfigurable('form', TRUE)
->setDisplayConfigurable('view', TRUE)
->setRequired(TRUE);
......
<?php
/**
* @file
* Contains Drupal\cloud_alert\Entity\CloudAlert.
*/
namespace Drupal\cloud_alert\Entity;
use Drupal\views\EntityViewsData;
......@@ -14,6 +9,7 @@ use Drupal\views\EntityViewsDataInterface;
* Provides the views data for the CloudAlert entity type.
*/
class CloudAlertViewsData extends EntityViewsData implements EntityViewsDataInterface {
/**
* {@inheritdoc}
*/
......
<?php
/**
* @file
* Contains Drupal\cloud_alert\Form\CloudAlertDeleteForm.
*/
namespace Drupal\cloud_alert\Form;
use Drupal\cloud\Form\CloudContentDeleteForm;
......@@ -16,5 +11,5 @@ use Drupal\cloud\Form\CloudContentDeleteForm;
*/
class CloudAlertDeleteForm extends CloudContentDeleteForm {
// delegate parent class - CloudContentDeleteFrom
// Delegate parent class - CloudContentDeleteFrom.
}
<?php
/**
* @file
* Contains Drupal\cloud_alert\Form\CloudAlertEditForm.
*/
// updated by yas 2016/05/24
// Updated by yas 2016/05/24.
namespace Drupal\cloud_alert\Form;
use Drupal\cloud\Form\CloudContentForm;
......@@ -30,7 +24,6 @@ class CloudAlertEditForm extends CloudContentForm {
$entity = $this->entity;
$form['name'] = array(
'#type' => 'textfield',
'#title' => $this->t('Name'),
......@@ -45,7 +38,7 @@ class CloudAlertEditForm extends CloudContentForm {
'#type' => 'textarea',
'#title' => $this->t('Description'),
'#cols' => 60,
'#rows' => 3,
'#rows' => 3,
'#default_value' => $entity->description(),
'#weight' => -5,
'#required' => FALSE,
......@@ -62,4 +55,5 @@ class CloudAlertEditForm extends CloudContentForm {
return $form;
}
}
<?php
/**
* @file
* Contains Drupal\cloud_alert\Form\CloudAlertSettingsForm.
*/
namespace Drupal\cloud_alert\Form;
use Drupal\Core\Form\FormBase;
......@@ -18,6 +13,7 @@ use Drupal\Core\Form\FormStateInterface;
* @ingroup cloud_alert
*/
class CloudAlertSettingsForm extends FormBase {
/**
* Returns a unique string identifying the form.
*
......@@ -40,7 +36,6 @@ class CloudAlertSettingsForm extends FormBase {
// Empty implementation of the abstract submit class.
}
/**
* Define the form used for CloudAlert settings.
*
......
<?php
/**
* @file
* Contains \Drupal\cloud_alert\Tests\CloudAlertTest
*/
namespace Drupal\cloud_alert\Tests;
use Drupal\Component\Utility\Random;
use Drupal\simpletest\WebTestBase;
// updated by yas 2016/05/25
// updated by yas 2016/05/24
// created by yas 2015/06/08
// module_load_include('test', 'aws_cloud');
define('CLOUD_ALERT_REPEAT_COUNT', 3);
/**
* Tests CloudAlert
*
* @group Cloud
*/
class CloudAlertTest extends WebTestBase { /* @FIXME extends AwsCloudTestCase { */
/**
* Modules to enable.
*
* @var array
*/
public static $modules = array('cloud',
'cloud_alert'
);
/**
* The profile to install as a basis for testing.
*
* @var string
*/
protected $profile = 'minimal';
/**
* Set up test.
*/
protected function setUp() {
parent::setUp();
$web_user = $this->drupalCreateUser(array(
'add cloud alert',
'list cloud alert',
'view cloud alert',
'edit cloud alert',
'delete cloud alert',
));
$this->drupalLogin($web_user);
}
/**
* Tests CRUD for cloud_alert information.
*/
public function testCloudAlert() {
// Access to Cloud Alert Menu
// $clouds = $this->getClouds();
// foreach ($clouds as $cloud) {
$cloud_context = 'default_cloud_context';
// List Cloud Alert for AWS
$this->drupalGet("/admin/cloud/design/cloud_alert");
$this->assertResponse(200, t('HTTP 200: List | Cloud Alert'));
$this->assertNoText(t('Notice' ), t('Make sure w/o Notice' ));
$this->assertNoText(t('Warning'), t('Make sure w/o Warnings'));
// Add a new cloud_alert information
$add = $this->createCloudAlertTestData();
for ($i = 0; $i < CLOUD_ALERT_REPEAT_COUNT; $i++) {
$num = $i + 1;
$this->drupalPostForm("/admin/cloud/design/cloud_alert/add",
$add[$i],
t('Save'));
$this->assertResponse(200, t('HTTP 200: Add | A New Cloud Alert Form #@num', array('@num' => $num)));
$this->assertNoText(t('Notice' ), t('Make sure w/o Notice' ));
$this->assertNoText(t('Warning'), t('Make sure w/o Warnings'));
$this->assertText(t('The Cloud Alert entity "@name" has been saved.', array(
'@name' => $add[$i]['name'])),
t('Confirm Message') . ': '
. t('The Cloud Alert entity "@name" has been saved.', array(
'@name' => $add[$i]['name']))
);
$this->assertText($add[$i]['name'],
t('Name: @name ', array(
'@name' => $add[$i]['name'])));
// Make sure listing
$this->drupalGet("/admin/cloud/design/cloud_alert");
$this->assertResponse(200, t('HTTP 200: List | Cloud Alert #@num', array('@num' => $num)));
$this->assertNoText(t('Notice' ), t('Make sure w/o Notice' ));
$this->assertNoText(t('warning'), t('Make sure w/o Warnings'));
for ($j = 0; $j < $i + 1; $j++) {
$this->assertText($add[$j]['name'],
t("Make sure w/ Listing @num: @name", array(
'@num' => $j + 1,
'@name' => $add[$j]['name'])));
}
}
//Edit case
$edit = $this->createCloudAlertTestData();
for ($i = 0; $i < CLOUD_ALERT_REPEAT_COUNT; $i++) { // 3 times
$num = $i + 1;
$this->drupalPostForm("/admin/cloud/design/cloud_alert/$num/edit",
$edit[$i],
t('Save'));
$this->assertResponse(200, t('HTTP 200: Edit | A New Cloud Alert Form #@num', array('@num' => $num)));
$this->assertNoText(t('Notice' ), t('Make sure w/o Notice' ));
$this->assertNoText(t('warning'), t('Make sure w/o Warnings'));
$this->assertText(t('The Cloud Alert entity "@name" has been saved.', array(
'@name' => $edit[$i]['name'])),
t('Confirm Message') . ': '
. t('The Cloud Alert entity "@name" has been saved.', array(
'@name' => $edit[$i]['name']))
);
$this->assertText($edit[$i]['name'], t('Name: @name ', array(
'@name' => $edit[$i]['name'])));
// Make sure listing
$this->drupalGet("/admin/cloud/design/cloud_alert");
$this->assertResponse(200, t('HTTP 200: List | Cloud Alert #@num', array('@num' => $num)));
$this->assertNoText(t('Notice' ), t('Make sure w/o Notice' ));
$this->assertNoText(t('warning'), t('Make sure w/o Warnings'));
for ($j = 0; $j < $i + 1; $j++) {
$this->assertText($edit[$j]['name'],
t("Make sure w/ Listing @num: @name", array(
'@num' => $j + 1,
'@name' => $edit[$j]['name'])));
}
}
// Delete cloud_alert Items
for ($i = 0; $i < CLOUD_ALERT_REPEAT_COUNT; $i++) {
$num = $i + 1;
$this->drupalGet( "/admin/cloud/design/cloud_alert/$num/delete");
$this->drupalPostForm("/admin/cloud/design/cloud_alert/$num/delete",
array(),
t('Delete'));
$this->assertResponse(200, t('HTTP 200: Delete | Cloud Alert #@num', array('@num' => $num)));
$this->assertNoText(t('Notice' ), t('Make sure w/o Notice' ));
$this->assertNoText(t('warning'), t('Make sure w/o Warnings'));
// Make sure listing
$this->drupalGet("/admin/cloud/design/cloud_alert");
$this->assertResponse(200, t('HTTP 200: Delete | Cloud Alert #@num', array('@num' => $num)));
$this->assertNoText(t('Notice' ), t('Make sure w/o Notice' ));
$this->assertNoText(t('warning'), t('Make sure w/o Warnings'));
for ($j = 0; $j < $i + 1; $j++) {
$this->assertNoText($edit[$j]['name'],
t("Make sure w/ Listing @num: @name", array(
'@num' => $j + 1,
'@name' => $edit[$j]['name'])));
}
}
//filtering cloud_alert information item
/*
$filter = array(
'filter' => 't1',
'operation' => 0,
);
$this->drupalPost("/admin/cloud/design/cloud_alert", $filter, t('Apply'));
$this->assertResponse(200, t('HTTP 200: Search Listings | Filter'));
$cloud_alert_id = CLOUD_ALERT_REPEAT_COUNT - 1 ;
$this->assertText('x1', t('Confirm Item:') . ' ' . 'x1.large');
$this->assertNoText(t('Notice' ), t('Make sure w/o Notice' ));
$this->assertNoText(t('warning'), t('Make sure w/o Warnings'));
*/
///////end
// } // End of foreach
}
private function createCloudAlertTestData() {
static $random;
if (!$random) {
$random = new Random();
}
for ($i = 0; $i < CLOUD_ALERT_REPEAT_COUNT; $i++) { // 3 times
$num = $i + 1;
// Input Fields
$data[] = array(
//'cloud_context' => $cloud_context ,
'name' => "Cloud Alert #$num - " . date('Y/m/d - ') . $random->name(16, TRUE),
'description' => "#$num: " . date('Y/m/d H:i:s - D M j G:i:s T Y')
. ' - SimpleTest Cloud Alert Description - '
. $random->string(32, TRUE),
);
}
return $data;
}
}
<?php
namespace Drupal\cloud_alert\Tests;
use Drupal\Component\Utility\Random;
use Drupal\simpletest\WebTestBase;
// Updated by yas 2016/05/25
// updated by yas 2016/05/24
// created by yas 2015/06/08.
// module_load_include('test', 'aws_cloud');.
define('CLOUD_ALERT_REPEAT_COUNT', 3);
/**
* Tests CloudAlert.
*
* @group Cloud
*/
class CloudAlertTest extends WebTestBase {
/* @FIXME extends AwsCloudTestCase { */
/**
* Modules to enable.
*
* @var array
*/
public static $modules = array('cloud',
'cloud_alert',
);
/**
* The profile to install as a basis for testing.
*
* @var string
*/
protected $profile = 'minimal';
/**
* Set up test.
*/
protected function setUp() {
parent::setUp();
$web_user = $this->drupalCreateUser(array(
'add cloud alert',
'list cloud alert',
'view cloud alert',
'edit cloud alert',
'delete cloud alert',
));
$this->drupalLogin($web_user);
}
/**
* Tests CRUD for cloud_alert information.
*/
public function testCloudAlert() {
// Access to Cloud Alert Menu
// $clouds = $this->getClouds();
// foreach ($clouds as $cloud) {.
$cloud_context = 'default_cloud_context';
// List Cloud Alert for AWS.
$this->drupalGet("/admin/cloud/design/cloud_alert");
$this->assertResponse(200, t('HTTP 200: List | Cloud Alert'));
$this->assertNoText(t('Notice'), t('Make sure w/o Notice'));
$this->assertNoText(t('Warning'), t('Make sure w/o Warnings'));
// Add a new cloud_alert information.
$add = $this->createCloudAlertTestData();
for ($i = 0; $i < CLOUD_ALERT_REPEAT_COUNT; $i++) {
$num = $i + 1;
$this->drupalPostForm("/admin/cloud/design/cloud_alert/add",
$add[$i],
t('Save'));
$this->assertResponse(200, t('HTTP 200: Add | A New Cloud Alert Form #@num', array('@num' => $num)));
$this->assertNoText(t('Notice'), t('Make sure w/o Notice'));
$this->assertNoText(t('Warning'), t('Make sure w/o Warnings'));
$this->assertText(t('The Cloud Alert entity "@name" has been saved.', array(
'@name' => $add[$i]['name'],
)),
t('Confirm Message') . ': '
. t('The Cloud Alert entity "@name" has been saved.', array(
'@name' => $add[$i]['name'],
))
);
$this->assertText($add[$i]['name'],
t('Name: @name ', array(
'@name' => $add[$i]['name'],
)));
// Make sure listing.
$this->drupalGet("/admin/cloud/design/cloud_alert");
$this->assertResponse(200, t('HTTP 200: List | Cloud Alert #@num', array('@num' => $num)));
$this->assertNoText(t('Notice'), t('Make sure w/o Notice'));
$this->assertNoText(t('warning'), t('Make sure w/o Warnings'));
for ($j = 0; $j < $i + 1; $j++) {
$this->assertText($add[$j]['name'],
t("Make sure w/ Listing @num: @name", array(
'@num' => $j + 1,
'@name' => $add[$j]['name'],
)));
}
}
// Edit case.
$edit = $this->createCloudAlertTestData();
// 3 times.
for ($i = 0; $i < CLOUD_ALERT_REPEAT_COUNT; $i++) {
$num = $i + 1;
$this->drupalPostForm("/admin/cloud/design/cloud_alert/$num/edit",
$edit[$i],
t('Save'));
$this->assertResponse(200, t('HTTP 200: Edit | A New Cloud Alert Form #@num', array('@num' => $num)));
$this->assertNoText(t('Notice'), t('Make sure w/o Notice'));
$this->assertNoText(t('warning'), t('Make sure w/o Warnings'));
$this->assertText(t('The Cloud Alert entity "@name" has been saved.', array(
'@name' => $edit[$i]['name'],
)),
t('Confirm Message') . ': '
. t('The Cloud Alert entity "@name" has been saved.', array(
'@name' => $edit[$i]['name'],
))
);
$this->assertText($edit[$i]['name'], t('Name: @name ', array(
'@name' => $edit[$i]['name'],
)));
// Make sure listing.
$this->drupalGet("/admin/cloud/design/cloud_alert");
$this->assertResponse(200, t('HTTP 200: List | Cloud Alert #@num', array('@num' => $num)));
$this->assertNoText(t('Notice'), t('Make sure w/o Notice'));
$this->assertNoText(t('warning'), t('Make sure w/o Warnings'));
for ($j = 0; $j < $i + 1; $j++) {
$this->assertText($edit[$j]['name'],
t("Make sure w/ Listing @num: @name", array(
'@num' => $j + 1,
'@name' => $edit[$j]['name'],
)));
}
}
// Delete cloud_alert Items.
for ($i = 0; $i < CLOUD_ALERT_REPEAT_COUNT; $i++) {
$num = $i + 1;
$this->drupalGet("/admin/cloud/design/cloud_alert/$num/delete");
$this->drupalPostForm("/admin/cloud/design/cloud_alert/$num/delete",
array(),
t('Delete'));
$this->assertResponse(200, t('HTTP 200: Delete | Cloud Alert #@num', array('@num' => $num)));
$this->assertNoText(t('Notice'), t('Make sure w/o Notice'));
$this->assertNoText(t('warning'), t('Make sure w/o Warnings'));
// Make sure listing.
$this->drupalGet("/admin/cloud/design/cloud_alert");
$this->assertResponse(200, t('HTTP 200: Delete | Cloud Alert #@num', array('@num' => $num)));
$this->assertNoText(t('Notice'), t('Make sure w/o Notice'));
$this->assertNoText(t('warning'), t('Make sure w/o Warnings'));
for ($j = 0; $j < $i + 1; $j++) {
$this->assertNoText($edit[$j]['name'],
t("Make sure w/ Listing @num: @name", array(
'@num' => $j + 1,
'@name' => $edit[$j]['name'],
)));
}
}
// Filtering cloud_alert information item
/*
$filter = array(
'filter' => 't1',
'operation' => 0,
);
$this->drupalPost("/admin/cloud/design/cloud_alert", $filter, t('Apply'));
$this->assertResponse(200, t('HTTP 200: Search Listings | Filter'));
$cloud_alert_id = CLOUD_ALERT_REPEAT_COUNT - 1 ;
$this->assertText('x1', t('Confirm Item:') . ' ' . 'x1.large');
$this->assertNoText(t('Notice' ), t('Make sure w/o Notice' ));
$this->assertNoText(t('warning'), t('Make sure w/o Warnings'));
*/
// end
// } // End of foreach.
}
/**
*
*/
private function createCloudAlertTestData() {
static $random;
if (!$random) {
$random = new Random();
}
// 3 times.
for ($i = 0; $i < CLOUD_ALERT_REPEAT_COUNT; $i++) {
$num = $i + 1;
// Input Fields.
$data[] = array(
// 'cloud_context' => $cloud_context ,.
'name' => "Cloud Alert #$num - " . date('Y/m/d - ') . $random->name(16, TRUE),
'description' => "#$num: " . date('Y/m/d H:i:s - D M j G:i:s T Y')
. ' - SimpleTest Cloud Alert Description - '
. $random->string(32, TRUE),
);
}
return $data;
}
}
<?php
/**
* @file
* Contains Drupal\cloud_cluster\CloudClusterInterface.
*/
// created by yas 2016/05/25
// Created by yas 2016/05/25.
namespace Drupal\cloud_cluster;
use Drupal\Core\Entity\ContentEntityInterface;
use Drupal\Core\Entity\EntityTypeInterface;
use Drupal\user\EntityOwnerInterface;
/**
......
<?php
/**
* @file
* Contains Drupal\cloud_cluster\Controller\CloudClusterAccessControlHandler.
*/
// created by yas 2016/05/25
// Created by yas 2016/05/25.
namespace Drupal\cloud_cluster\Controller;
use Drupal\Core\Entity\EntityAccessControlHandler;
......@@ -20,6 +14,7 @@ use Drupal\Core\Access\AccessResult;
* @see \Drupal\cloud_cluster\Entity\CloudCluster.
*/
class CloudClusterAccessControlHandler extends EntityAccessControlHandler {
/**
* {@inheritdoc}
*/
......@@ -45,4 +40,5 @@ class CloudClusterAccessControlHandler extends EntityAccessControlHandler {
protected function checkCreateAccess(AccountInterface $account, array $context, $entity_bundle = NULL) {
return AccessResult::allowedIfHasPermission($account, 'add cloud cluster');
}
}
<?php
/**
* @file
* Contains \Drupal\cloud_cluster\Controller\CloudClustersController.
*/
// created by yas 2016/05/25
// Created by yas 2016/05/25.
namespace Drupal\cloud_cluster\Controller;
\Drupal::moduleHandler()->loadInclude('cloud', 'inc', 'cloud.constants');
/**
*
*/
class CloudClustersController {
}
?>
\ No newline at end of file
<?php
/**
* @file
* Contains Drupal\cloud_cluster\Controller\CloudClusterListController.
*/
// created by yas 2016/05/25
// Created by yas 2016/05/25.
namespace Drupal\cloud_cluster\Controller;
use Drupal\cloud\Controller\CloudContentListBuilder;
......@@ -19,6 +13,7 @@ use Drupal\Core\Url;
* @ingroup cloud_cluster
*/
class CloudClusterListController extends CloudContentListBuilder {
/**
* {@inheritdoc}
*/
......@@ -28,8 +23,8 @@ class CloudClusterListController extends CloudContentListBuilder {
// The header gives the table the information it needs in order to make
// the query calls for ordering. TableSort uses the field information
// to know what database column to sort by.
array('data' => t('Name' ), 'specifier' => 'name', 'sort' => 'ASC'),
array('data' => t('Description' ), 'specifier' => 'description' ),
array('data' => t('Name'), 'specifier' => 'name', 'sort' => 'ASC'),
array('data' => t('Description'), 'specifier' => 'description'),
);
return $header + parent::buildHeader();
......@@ -40,9 +35,9 @@ class CloudClusterListController extends CloudContentListBuilder {
*/
public function buildRow(EntityInterface $entity) {
// for debug
// $row['id'] = $entity->id();
// $row['uuid'] = $entity->uuid();
// For debug
// $row['id'] = $entity->id();
// $row['uuid'] = $entity->uuid();
$row['name'] = \Drupal::l(
$this->getLabel($entity),
new Url(
......@@ -56,4 +51,5 @@ class CloudClusterListController extends CloudContentListBuilder {
return $row + parent::buildRow($entity);
}
}
<?php
/**
* @file
* Contains Drupal\cloud_cluster\Entity\CloudCluster.
*/
// created by yas 2016/05/25
// Created by yas 2016/05/25.
namespace Drupal\cloud_cluster\Entity;
use Drupal\Core\Entity\EntityStorageInterface;
......@@ -178,12 +172,12 @@ class CloudCluster extends ContentEntityBase implements CloudClusterInterface {
'type' => 'string',
'weight' => -5,
))
/*
/*
->setDisplayOptions('form', array(
'type' => 'string_textfield',
'weight' => -6,
))
*/
*/
->setDisplayConfigurable('form', TRUE)
->setDisplayConfigurable('view', TRUE)
->setRequired(TRUE);
......
<?php
/**
* @file
* Contains Drupal\cloud_cluster\Entity\CloudCluster.
*/
// created by yas 2016/05/25
// Created by yas 2016/05/25.
namespace Drupal\cloud_cluster\Entity;
use Drupal\views\EntityViewsData;
......@@ -16,6 +10,7 @@ use Drupal\views\EntityViewsDataInterface;
* Provides the views data for the CloudCluster entity type.
*/
class CloudClusterViewsData extends EntityViewsData implements EntityViewsDataInterface {
/**
* {@inheritdoc}
*/
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment