コード例 #1
0
function attach_info_to_results($results, $type, $license)
{
    $id_array = ['type' => $type, 'license' => $license];
    $attach_id_fun = function ($result) use($id_array) {
        $params = array_merge($result, $id_array);
        $params['hash'] = Integrity::view_params_hash($params['license'], $params['type'], $params['site'], $params['title'], $params['url'], $params['author'], $params['author_url'], $params['preview_url'], $params['full_url']);
        return $params;
    };
    return array_map($attach_id_fun, $results);
}
コード例 #2
0
 /**
  * @return void
  */
 public function testPerformDestinationFail()
 {
     $this->progress->expects($this->once())->method('start')->with(1);
     $this->progress->expects($this->once())->method('advance');
     $this->progress->expects($this->never())->method('finish');
     $this->source->expects($this->once())->method('getDocumentList')->willReturn(['core_config_data']);
     $this->destination->expects($this->once())->method('getDocumentList')->willReturn([]);
     $this->logger->expects($this->once())->method('error')->with('Integrity check failed due to "core_config_data" document does not exist in the destination resource');
     $this->integrity = new Integrity($this->destination, $this->source, $this->logger, $this->progress, $this->recordFactory, $this->readerSettings, $this->handlerManagerFactory);
     $this->assertFalse($this->integrity->perform());
 }
コード例 #3
0
 /**
  * @return void
  */
 public function testPerformFieldFail()
 {
     $this->integrity = new Integrity($this->destination, $this->logger, $this->progress);
     $this->progress->expects($this->once())->method('start')->with(1);
     $this->progress->expects($this->once())->method('advance');
     $this->progress->expects($this->never())->method('finish');
     $this->destination->expects($this->once())->method('getDocumentList')->willReturn(['rating', 'rating_store']);
     $this->structure->expects($this->once())->method('getFields')->willReturn(['field' => []]);
     $this->document->expects($this->once())->method('getStructure')->willReturn($this->structure);
     $this->destination->expects($this->once())->method('getDocument')->with('rating')->willReturn($this->document);
     $this->logger->expects($this->once())->method('error')->with('"is_active" field does not exist in "rating" document of the destination resource');
     $this->assertFalse($this->integrity->perform());
 }
コード例 #4
0
ファイル: IntegrityTest.php プロジェクト: okite11/frames21
 public function testPerformWithMismatchDocumentFieldDataTypes()
 {
     $this->setupFieldsValidation(true);
     $this->documentSource->expects($this->any())->method('getName')->will($this->returnValue('document1'));
     $this->documentDestination->expects($this->any())->method('getName')->will($this->returnValue('document1'));
     $this->source->expects($this->atLeastOnce())->method('getDocumentList')->will($this->returnValue(['document1']));
     $this->destination->expects($this->atLeastOnce())->method('getDocumentList')->will($this->returnValue(['document1']));
     $this->map->expects($this->any())->method('getDocumentMap')->will($this->returnArgument(0));
     $this->map->expects($this->any())->method('isDocumentIgnored')->willReturn(false);
     $this->map->expects($this->any())->method('getFieldMap')->will($this->returnValue('field1'));
     $this->map->expects($this->any())->method('isFieldDataTypeIgnored')->will($this->returnValue(false));
     $this->logger->expects($this->at(0))->method('warning')->with('Mismatch of data types. Source document: document1. Fields: field1');
     $this->logger->expects($this->at(1))->method('warning')->with('Mismatch of data types. Destination document: document1. Fields: field1');
     $this->integrity->perform();
 }
コード例 #5
0
 public function testPerformWithSourceFieldErrors()
 {
     $structure = $this->getMockBuilder('\\Migration\\Resource\\Structure')->disableOriginalConstructor()->setMethods([])->getMock();
     $structure->expects($this->at(0))->method('getFields')->will($this->returnValue(['field1' => []]));
     $structure->expects($this->at(1))->method('getFields')->will($this->returnValue(['field2' => []]));
     $structure->expects($this->at(2))->method('getFields')->will($this->returnValue(['field2' => []]));
     $structure->expects($this->at(3))->method('getFields')->will($this->returnValue(['field1' => []]));
     $document = $this->getMockBuilder('\\Migration\\Resource\\Document')->disableOriginalConstructor()->getMock();
     $document->expects($this->any())->method('getStructure')->willReturn($structure);
     $document->expects($this->any())->method('getName')->willReturn('document');
     $this->source->expects($this->atLeastOnce())->method('getDocumentList')->will($this->returnValue(['document']));
     $this->destination->expects($this->atLeastOnce())->method('getDocumentList')->will($this->returnValue(['document']));
     $this->source->expects($this->any())->method('getDocument')->will($this->returnValue($document));
     $this->destination->expects($this->any())->method('getDocument')->with('document')->will($this->returnValue($document));
     $this->map->expects($this->any())->method('isDocumentIgnored')->willReturn(false);
     $this->map->expects($this->exactly(2))->method('getDocumentMap')->with('document')->will($this->returnArgument(0));
     $this->map->expects($this->at(2))->method('getFieldMap')->with('document', 'field1')->will($this->returnValue('field1'));
     $this->map->expects($this->at(5))->method('getFieldMap')->with('document', 'field2')->will($this->returnValue('field2'));
     $this->logger->expects($this->at(0))->method('error')->with('Source fields not mapped. Document: document. Fields: field1');
     $this->logger->expects($this->at(1))->method('error')->with('Destination fields not mapped. Document: document. Fields: field2');
     $this->integrity->perform();
 }
コード例 #6
0
require_once $srcroot . 'licenses.php';
$check_str = $_REQUEST['check'];
if ($check_str != "") {
    //TODO: Check we have all the params and tell user if not
    $site = urldecode($_REQUEST['site']);
    $type = urldecode($_REQUEST['type']);
    $license = urldecode($_REQUEST['license']);
    $license_locale = '';
    $license_version = '4.0';
    $title = urldecode($_REQUEST['title']);
    $url = urldecode($_REQUEST['url']);
    $author = urldecode($_REQUEST['author']);
    $author_url = urldecode($_REQUEST['author_url']);
    $preview_url = urldecode($_REQUEST['preview_url']);
    $full_url = urldecode($_REQUEST['full_url']);
    $check = Integrity::view_params_hash($license, $type, $site, $title, $url, $author, $author_url, $preview_url, $full_url);
    if ($check_str != $check) {
        die("Params invalid.");
    }
    $smarty->assign('site', $site);
    $smarty->assign('dcmitype', media_dcmitype_for_letter($type));
    $smarty->assign('license_string', license_string($license, $license_version, $license_locale));
    $smarty->assign('license_url', license_url_for_num($license, $license_version));
    $smarty->assign('license_icon', license_icon_for_num($license, $license_version));
    $smarty->assign('title', $title);
    $smarty->assign('url', $url);
    $smarty->assign('author', $author);
    $smarty->assign('author_url', $author_url);
    $smarty->assign('image', $full_url);
}
$smarty->assign('headerfile', 'welcome-header.tpl');
コード例 #7
0
ファイル: ui.php プロジェクト: alpacaaa/simpledb-backup
<?php

require_once 'class.integrity.php';
require_once 'class.config.php';
$integrity = new Integrity(Config::get('DT-server', 'archive-dir', 'done'));
$dirs = $integrity->discover();
$integrity->setDays(Config::get('DT-server', 'days', 5));
$resolve = $_GET['resolve'];
if ($resolve) {
    $integrity->resolve($resolve);
}
$log = $_GET['log'];
if ($log) {
    die($integrity->getLog($log));
}
$css = array('ok' => 'clean-ok', 'error' => 'clean-error', 'success' => 'success', 'failure' => 'failure');
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
	"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" dir="ltr">
<head>
	<meta http-equiv="content-type" content="text/html; charset=utf-8" />
	<link rel="stylesheet" href="ui/ui.css" />
	<link rel="stylesheet" href="ui/tipsy.css" />
	<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
	<script type="text/javascript" src="ui/tipsy.js"></script>
	<script type="text/javascript" src="ui/log-loader.js"></script>
	<title>Backup Status</title>
</head>
<body>
コード例 #8
0
ファイル: Archive.php プロジェクト: mined-gatech/hubzero-cms
 /**
  * Update SKU info
  *
  * @param      int 		$sku SKU
  * @param      array 	$fields New info
  * @return     throws exception
  */
 public function updateSku($sku, $fields)
 {
     $checkIntegrity = true;
     //print_r($fields); die;
     if (isset($fields['sPrice'])) {
         $sku->setPrice($fields['sPrice']);
     }
     if (isset($fields['sAllowMultiple'])) {
         $sku->setAllowMultiple($fields['sAllowMultiple']);
     }
     if (isset($fields['sTrackInventory'])) {
         $sku->setTrackInventory($fields['sTrackInventory']);
     }
     if (isset($fields['sInventory']) && $fields['sInventory']) {
         $sku->setInventoryLevel($fields['sInventory']);
     }
     if (isset($fields['sSku'])) {
         $sku->setName($fields['sSku']);
     }
     if (isset($fields['state'])) {
         $sku->setActiveStatus($fields['state']);
         if (!$fields['state']) {
             $checkIntegrity = false;
         }
     }
     if (isset($fields['options'])) {
         $sku->setOptions($fields['options']);
     }
     // Meta
     if (isset($fields['meta'])) {
         foreach ($fields['meta'] as $metaKey => $metaVal) {
             $sku->addMeta($metaKey, $metaVal);
         }
     }
     // Before saving SKU, check the for possible conflicts (integrity check) except when the SKU gets unpublished
     if ($checkIntegrity) {
         require_once dirname(__DIR__) . DS . 'helpers' . DS . 'Integrity.php';
         $integrityCheck = \Integrity::skuIntegrityCheck($sku);
         if ($integrityCheck->status != 'ok') {
             $errorMessage = "Integrity check error:";
             foreach ($integrityCheck->errors as $error) {
                 $errorMessage .= '<br>' . $error;
             }
             throw new \Exception($errorMessage);
         }
     }
     $sku->save();
     return $sku;
 }
コード例 #9
0
if (!session_mayEdit($dbConnection)) {
    header('LOCATION: index.php');
}
?>
<!DOCTYPE HTML>
<html>
  <?php 
$title = 'Checks for database integrity';
$jsFiles = array('extern/jquery.dataTables.js');
require_once 'head.php';
?>
  <body>
    <?php 
require_once 'topmenu.php';
require_once 'query/Integrity.php';
$data = Integrity::checkIntegrity();
$mkTable = function ($arr) {
    $head = '<tr><th>Table:</th><th>Data:</th><th>Reason:</th></tr>';
    $ret = "<table class='display table table-bordered'><thead>{$head}</thead>";
    foreach ($arr as $tName => $tData) {
        foreach ($tData as $entry) {
            $data = $entry['json'];
            $reason = $entry['reason'];
            $ret .= "<tr><td>{$tName}</td><td>{$data}</td><td>{$reason}</td></tr>";
        }
    }
    $ret .= "<tfoot>{$head}</tfoot></table>";
    return $ret;
};
echo "<h2>Unexpected Data:</h2>";
echo $mkTable($data['notValues']);
コード例 #10
0
 /**
  * @return void
  */
 public function testPerform()
 {
     $integrity = new Integrity($this->progress, $this->source, $this->destination, $this->helper);
     $this->assertTrue($integrity->perform());
 }
コード例 #11
0
ファイル: Collection.php プロジェクト: kevinwojo/hubzero-cms
 /**
  * Check if everything checks out and the collection is ready to go
  *
  * @param  void
  * @return bool		true on success, throws exception on failure
  */
 public function verify()
 {
     require_once dirname(__DIR__) . DS . 'helpers' . DS . 'Integrity.php';
     $integrityCheck = \Integrity::collectionIntegrityCheck($this);
     if ($integrityCheck->status != 'ok') {
         $errorMessage = "Integrity check error:";
         foreach ($integrityCheck->errors as $error) {
             $errorMessage .= '<br>' . $error;
         }
         throw new \Exception($errorMessage);
     }
     if (empty($this->data->name)) {
         throw new \Exception(Lang::txt('No collection name set'));
     }
     if (empty($this->data->type)) {
         throw new \Exception(Lang::txt('No collection type set'));
     }
     return true;
 }
コード例 #12
0
ファイル: Sku.php プロジェクト: kevinwojo/hubzero-cms
 public function verify()
 {
     if (!isset($this->data->price) || !is_numeric($this->data->price)) {
         throw new \Exception(Lang::txt('No SKU price set'));
     }
     if (!isset($this->data->pId) || !is_numeric($this->data->pId)) {
         throw new \Exception(Lang::txt('No SKU Product Set'));
     }
     // Verify that the SKU has all options set (one option from each option group assigned to the parent product)
     $product = new Product($this->getProductId());
     $productOptionGroups = $product->getOptionGroups();
     // Init the set options array()
     $optionGroupOptionsSet = array();
     // Init the flag whether the extra/useless options are set
     $extraOptionsSet = false;
     foreach ($this->getOptions() as $oId) {
         $option = new Option($oId);
         $optionGroupId = $option->getOptionGroupId();
         if (in_array($optionGroupId, $productOptionGroups)) {
             $optionGroupOptionsSet[] = $optionGroupId;
         } else {
             // There are some options set that are from option groups not applied to this product
             // (most likely due to the removal of the option group from the product.) This should never happen.
             $extraOptionsSet = true;
         }
     }
     // At this point option groups options set must be the same as the product options groups, throw exception if not
     $missingOptions = array_diff($productOptionGroups, $optionGroupOptionsSet);
     if (!empty($missingOptions)) {
         throw new \Exception(Lang::txt('Not all product options are set'));
     }
     if ($extraOptionsSet) {
         throw new \Exception(Lang::txt('Extra options are set'));
     }
     // Integrity check
     require_once dirname(__DIR__) . DS . 'helpers' . DS . 'Integrity.php';
     $integrityCheck = \Integrity::skuIntegrityCheck($this);
     if ($integrityCheck->status != 'ok') {
         $errorMessage = "Integrity check error:";
         foreach ($integrityCheck->errors as $error) {
             $errorMessage .= '<br>' . $error;
         }
         throw new \Exception($errorMessage);
     }
     return true;
 }
コード例 #13
0
 private function checkIntegrity($collection)
 {
     // If the collection is not being published, no need to check for integrity
     if (!$collection->getActiveStatus()) {
         return true;
     }
     require_once dirname(dirname(__DIR__)) . DS . 'helpers' . DS . 'Integrity.php';
     $integrityCheck = \Integrity::collectionIntegrityCheck($collection);
     if ($integrityCheck->status != 'ok') {
         $errorMessage = "Integrity check error:";
         foreach ($integrityCheck->errors as $error) {
             $errorMessage .= '<br>' . $error;
         }
         throw new \Exception($errorMessage);
     }
     return true;
 }
コード例 #14
0
<?php

require_once CODE_ROOT . '/classes/integrity.php';
require_once CODE_ROOT . '/classes/operations.php';
require_once CODE_ROOT . '/classes/surgeons.php';
$integrity = new Integrity();
$integrity->result['views']['mainContent'] = 'integrity/form.php';
$operations = new Operations();
$yearsOperations = $operations->getOperationsYears();
if ($yearsOperations === false) {
    $integrity->result['message'][] = 'Ошибка при получении экстремумов даты операций';
    $integrity->result['success'] = false;
}
$integrityForm = filter_input(INPUT_GET, 'integrityForm', FILTER_VALIDATE_INT, Helpers::$filterForIntPositive);
if ($integrityForm === 1) {
    $period = filter_input(INPUT_GET, 'period', FILTER_VALIDATE_INT, Helpers::$filterForIntPositive);
    $year = filter_input(INPUT_GET, 'year', FILTER_VALIDATE_INT, Helpers::$filterForIntPositive);
    $integrity->getGeneralChecks($year, $period);
}
$result = $integrity->result;