ratonesytortillas /wp-content/plugins/yet-another-photoblog/lib/Savant2-2.4.3/Savant2/tests/1_assign.php

Language PHP Lines 141
MD5 Hash 0278d419eed2716b7c399db1c2f16754 Estimated Cost $2,030 (why?)
Repository https://github.com/Mercedes/ratonesytortillas.git View Raw File View Project SPDX
  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
<?php

/**
* 
* Tests assign() issues
*
* @version $Id: 1_assign.php,v 1.2 2004/12/08 01:24:59 pmjones Exp $
* 
*/


error_reporting(E_ALL);

require_once 'Savant2.php';
$savant =& new Savant2(array('template_path' => 'templates'));

echo "<h1>assign 0 (string, null)</h1>";
$val = null;
$result = $savant->assign('nullvar', $val);
echo "result: <pre>";
print_r($result);
echo "</pre>";
echo "properties: <pre>";
print_r(get_object_vars($savant));
echo "</pre>";


echo "<h1>assign 1 (string, mixed)</h1>";
$result = $savant->assign('variable', 'variable_value');
echo "result: <pre>";
print_r($result);
echo "</pre>";
echo "properties: <pre>";
print_r(get_object_vars($savant));
echo "</pre>";


echo "<h1>assign 2 (array)</h1>";
$result = $savant->assign(array('array1' => 'value1', 'array2' => 'value2'));
echo "result: <pre>";
print_r($result);
echo "</pre>";
echo "properties: <pre>";
print_r(get_object_vars($savant));
echo "</pre>";

echo "<h1>assign 3 (object)</h1>";
$object = new StdClass();
$object->obj1 = 'this';
$object->obj2 = 'that';
$object->obj3 = 'other';
$result = $savant->assign($object);
echo "result: <pre>";
print_r($result);
echo "</pre>";
echo "properties: <pre>";
print_r(get_object_vars($savant));
echo "</pre>";


echo "<h1>assignRef</h1>";
$reference = 'reference_value';
$result = $savant->assignRef('reference', $reference);
echo "result: <pre>";
print_r($result);
echo "</pre>";
echo "properties: <pre>";
print_r(get_object_vars($savant));
echo "</pre>";

/*
echo "<h1>assignObject</h1>";
$object = new stdClass();
$result = $savant->assignObject('object', $object);
echo "result: <pre>";
print_r($result);
echo "</pre>";
echo "properties: <pre>";
print_r(get_object_vars($savant));
echo "</pre>";
*/

echo "<h1>Assign variable without value</h1>";
$result = $savant->assign('variable_without_value');
echo "result: <pre>";
print_r($result);
echo "</pre>";
echo "properties: <pre>";
print_r(get_object_vars($savant));
echo "</pre>";


echo "<h1>Assign reference without value</h1>";
$result = $savant->assignRef('reference_without_value');
echo "result: <pre>";
print_r($result);
echo "</pre>";
echo "properties: <pre>";
print_r(get_object_vars($savant));
echo "</pre>";

/*
echo "<h1>Assign object when value is not object</h1>";
$reference3 = 'failed!';
$result = $savant->assignObject('object2', $reference3);
echo "result: <pre>";
print_r($result);
echo "</pre>";
echo "properties: <pre>";
print_r(get_object_vars($savant));
echo "</pre>";
*/

echo "<h1>Change reference values from logic</h1>";
$reference = 'CHANGED VALUE FROM LOGIC';
echo "properties: <pre>";
print_r(get_object_vars($savant));
echo "</pre>";

echo "<h1>getVars</h1>";

echo "<p>All</p><pre>";
print_r($savant->getVars());
echo "</pre>";

echo "<p>Some</p><pre>";
print_r($savant->getVars(array('obj1', 'obj2', 'obj3')));
echo "</pre>";

echo "<p>One</p><pre>";
print_r($savant->getVars('variable'));
echo "</pre>";

echo "<p>Nonexistent</p><pre>";
var_dump($savant->getVars('nosuchvar'));
echo "</pre>";

$savant->display('assign.tpl.php');
echo "<p>After: $reference</p>";

?>
Back to Top