<span style=
"color: #008080;"
> 1</span> <span style=
"color: #0000ff;"
>
class
</span><span style=
"color: #000000;"
> DemoControllerTest
extends
\PHPUnit_Framework_TestCase
</span><span style=
"color: #008080;"
> 2</span> <span style=
"color: #000000;"
>{
</span><span style=
"color: #008080;"
> 3</span>
<span style=
"color: #008080;"
> 4</span> <span style=
"color: #008000;"
>
</span>
<span style=
"color: #008080;"
> 7</span> <span style=
"color: #0000ff;"
>
protected
</span> $<span style=
"color: #0000ff;"
>object</span><span style=
"color: #000000;"
>;
</span><span style=
"color: #008080;"
> 8</span>
<span style=
"color: #008080;"
> 9</span> <span style=
"color: #008000;"
>
</span>
<span style=
"color: #008080;"
> 13</span> <span style=
"color: #0000ff;"
>
protected
</span><span style=
"color: #000000;"
>
function
setUp()
</span><span style=
"color: #008080;"
> 14</span> <span style=
"color: #000000;"
> {
</span><span style=
"color: #008080;"
> 15</span> $<span style=
"color: #0000ff;"
>this</span>-><span style=
"color: #0000ff;"
>object</span> = <span style=
"color: #0000ff;"
>
new
</span><span style=
"color: #000000;"
> DemoController;
</span><span style=
"color: #008080;"
> 16</span> <span style=
"color: #000000;"
> }
</span><span style=
"color: #008080;"
> 17</span>
<span style=
"color: #008080;"
> 18</span> <span style=
"color: #008000;"
>
</span>
<span style=
"color: #008080;"
> 22</span> <span style=
"color: #0000ff;"
>
protected
</span><span style=
"color: #000000;"
>
function
tearDown()
</span><span style=
"color: #008080;"
> 23</span> <span style=
"color: #000000;"
> {
</span><span style=
"color: #008080;"
> 24</span>
<span style=
"color: #008080;"
> 25</span> <span style=
"color: #000000;"
> }
</span><span style=
"color: #008080;"
> 26</span>
<span style=
"color: #008080;"
> 27</span> <span style=
"color: #008000;"
>
</span>
<span style=
"color: #008080;"
> 32</span> <span style=
"color: #0000ff;"
>
public
</span><span style=
"color: #000000;"
>
function
testPlus()
</span><span style=
"color: #008080;"
> 33</span> <span style=
"color: #000000;"
> {
</span><span style=
"color: #008080;"
> 34</span> $<span style=
"color: #0000ff;"
>this</span>-><span style=
"color: #000000;"
>assertEquals(
</span><span style=
"color: #008080;"
> 35</span> <span style=
"color: #800080;"
>13</span>, $<span style=
"color: #0000ff;"
>this</span>-><span style=
"color: #0000ff;"
>object</span>->plus(<span style=
"color: #800080;"
>5</span>, <span style=
"color: #800080;"
>8</span><span style=
"color: #000000;"
>)
</span><span style=
"color: #008080;"
> 36</span> <span style=
"color: #000000;"
> );
</span><span style=
"color: #008080;"
> 37</span> <span style=
"color: #000000;"
> }
</span><span style=
"color: #008080;"
> 38</span>
<span style=
"color: #008080;"
> 39</span> <span style=
"color: #008000;"
>
</span>
<span style=
"color: #008080;"
> 44</span> <span style=
"color: #0000ff;"
>
public
</span><span style=
"color: #000000;"
>
function
testPlus2()
</span><span style=
"color: #008080;"
> 45</span> <span style=
"color: #000000;"
> {
</span><span style=
"color: #008080;"
> 46</span> $<span style=
"color: #0000ff;"
>this</span>-><span style=
"color: #000000;"
>assertEquals(
</span><span style=
"color: #008080;"
> 47</span> <span style=
"color: #800080;"
>92</span>, $<span style=
"color: #0000ff;"
>this</span>-><span style=
"color: #0000ff;"
>object</span>->plus(<span style=
"color: #800080;"
>16</span>, <span style=
"color: #800080;"
>76</span><span style=
"color: #000000;"
>)
</span><span style=
"color: #008080;"
> 48</span> <span style=
"color: #000000;"
> );
</span><span style=
"color: #008080;"
> 49</span> <span style=
"color: #000000;"
> }
</span><span style=
"color: #008080;"
> 50</span>
<span style=
"color: #008080;"
> 51</span> <span style=
"color: #008000;"
>
</span>
<span style=
"color: #008080;"
> 56</span> <span style=
"color: #0000ff;"
>
public
</span><span style=
"color: #000000;"
>
function
testPlus3()
</span><span style=
"color: #008080;"
> 57</span> <span style=
"color: #000000;"
> {
</span><span style=
"color: #008080;"
> 58</span> $<span style=
"color: #0000ff;"
>this</span>-><span style=
"color: #000000;"
>assertEquals(
</span><span style=
"color: #008080;"
> 59</span> <span style=
"color: #800080;"
>32</span>, $<span style=
"color: #0000ff;"
>this</span>-><span style=
"color: #0000ff;"
>object</span>->plus(<span style=
"color: #800080;"
>6</span>, <span style=
"color: #800080;"
>16</span><span style=
"color: #000000;"
>)
</span><span style=
"color: #008080;"
> 60</span> <span style=
"color: #000000;"
> );
</span><span style=
"color: #008080;"
> 61</span> <span style=
"color: #000000;"
> }
</span><span style=
"color: #008080;"
> 62</span>
<span style=
"color: #008080;"
> 63</span> <span style=
"color: #008000;"
>
</span>
<span style=
"color: #008080;"
> 68</span> <span style=
"color: #0000ff;"
>
public
</span><span style=
"color: #000000;"
>
function
testPlus4()
</span><span style=
"color: #008080;"
> 69</span> <span style=
"color: #000000;"
> {
</span><span style=
"color: #008080;"
> 70</span> $<span style=
"color: #0000ff;"
>this</span>-><span style=
"color: #000000;"
>assertEquals(
</span><span style=
"color: #008080;"
> 71</span> <span style=
"color: #800080;"
>0</span>, $<span style=
"color: #0000ff;"
>this</span>-><span style=
"color: #0000ff;"
>object</span>->plus(<span style=
"color: #800080;"
>6</span>, <span style=
"color: #800080;"
>4</span><span style=
"color: #000000;"
>)
</span><span style=
"color: #008080;"
> 72</span> <span style=
"color: #000000;"
> );
</span><span style=
"color: #008080;"
> 73</span> <span style=
"color: #000000;"
> }
</span><span style=
"color: #008080;"
> 74</span>
<span style=
"color: #008080;"
> 75</span> <span style=
"color: #008000;"
>
</span>
<span style=
"color: #008080;"
> 80</span> <span style=
"color: #0000ff;"
>
public
</span><span style=
"color: #000000;"
>
function
testPlus5()
</span><span style=
"color: #008080;"
> 81</span> <span style=
"color: #000000;"
> {
</span><span style=
"color: #008080;"
> 82</span> $<span style=
"color: #0000ff;"
>this</span>-><span style=
"color: #000000;"
>assertEquals(
</span><span style=
"color: #008080;"
> 83</span> <span style=
"color: #800080;"
>2</span>, $<span style=
"color: #0000ff;"
>this</span>-><span style=
"color: #0000ff;"
>object</span>->plus(<span style=
"color: #800000;"
>
'</span><span style="color: #800000;">abc</span><span style="color: #800000;">'
</span>, <span style=
"color: #800080;"
>1</span><span style=
"color: #000000;"
>)
</span><span style=
"color: #008080;"
> 84</span> <span style=
"color: #000000;"
> );
</span><span style=
"color: #008080;"
> 85</span> <span style=
"color: #000000;"
> }
</span><span style=
"color: #008080;"
> 86</span>
<span style=
"color: #008080;"
> 87</span> <span style=
"color: #008000;"
>
</span>
<span style=
"color: #008080;"
> 92</span> <span style=
"color: #0000ff;"
>
public
</span><span style=
"color: #000000;"
>
function
testSubtract()
</span><span style=
"color: #008080;"
> 93</span> <span style=
"color: #000000;"
> {
</span><span style=
"color: #008080;"
> 94</span> $<span style=
"color: #0000ff;"
>this</span>-><span style=
"color: #000000;"
>assertEquals(
</span><span style=
"color: #008080;"
> 95</span> <span style=
"color: #800080;"
>6</span>, $<span style=
"color: #0000ff;"
>this</span>-><span style=
"color: #0000ff;"
>object</span>->subtract(<span style=
"color: #800080;"
>14</span>, <span style=
"color: #800080;"
>8</span><span style=
"color: #000000;"
>)
</span><span style=
"color: #008080;"
> 96</span> <span style=
"color: #000000;"
> );
</span><span style=
"color: #008080;"
> 97</span> <span style=
"color: #000000;"
> }
</span><span style=
"color: #008080;"
> 98</span>
<span style=
"color: #008080;"
> 99</span> <span style=
"color: #008000;"
>
</span>
<span style=
"color: #008080;"
>104</span> <span style=
"color: #0000ff;"
>
public
</span><span style=
"color: #000000;"
>
function
testSubtract2()
</span><span style=
"color: #008080;"
>105</span> <span style=
"color: #000000;"
> {
</span><span style=
"color: #008080;"
>106</span> $<span style=
"color: #0000ff;"
>this</span>-><span style=
"color: #000000;"
>assertEquals(
</span><span style=
"color: #008080;"
>107</span> <span style=
"color: #800080;"
>10</span>, $<span style=
"color: #0000ff;"
>this</span>-><span style=
"color: #0000ff;"
>object</span>->subtract(<span style=
"color: #800080;"
>16</span>, <span style=
"color: #800080;"
>6</span><span style=
"color: #000000;"
>)
</span><span style=
"color: #008080;"
>108</span> <span style=
"color: #000000;"
> );
</span><span style=
"color: #008080;"
>109</span> <span style=
"color: #000000;"
> }
</span><span style=
"color: #008080;"
>110</span>
<span style=
"color: #008080;"
>111</span> <span style=
"color: #008000;"
>
</span>
<span style=
"color: #008080;"
>116</span> <span style=
"color: #0000ff;"
>
public
</span><span style=
"color: #000000;"
>
function
testSubtract3()
</span><span style=
"color: #008080;"
>117</span> <span style=
"color: #000000;"
> {
</span><span style=
"color: #008080;"
>118</span> $<span style=
"color: #0000ff;"
>this</span>-><span style=
"color: #000000;"
>assertEquals(
</span><span style=
"color: #008080;"
>119</span> <span style=
"color: #800080;"
>0</span>, $<span style=
"color: #0000ff;"
>this</span>-><span style=
"color: #0000ff;"
>object</span>->subtract(<span style=
"color: #800080;"
>6</span>, <span style=
"color: #800080;"
>4</span><span style=
"color: #000000;"
>)
</span><span style=
"color: #008080;"
>120</span> <span style=
"color: #000000;"
> );
</span><span style=
"color: #008080;"
>121</span> <span style=
"color: #000000;"
> }
</span><span style=
"color: #008080;"
>122</span>
<span style=
"color: #008080;"
>123</span> <span style=
"color: #008000;"
>
</span>
<span style=
"color: #008080;"
>128</span> <span style=
"color: #0000ff;"
>
public
</span><span style=
"color: #000000;"
>
function
testSubtract4()
</span><span style=
"color: #008080;"
>129</span> <span style=
"color: #000000;"
> {
</span><span style=
"color: #008080;"
>130</span> $<span style=
"color: #0000ff;"
>this</span>-><span style=
"color: #000000;"
>assertEquals(
</span><span style=
"color: #008080;"
>131</span> <span style=
"color: #800080;"
>44</span>, $<span style=
"color: #0000ff;"
>this</span>-><span style=
"color: #0000ff;"
>object</span>->subtract(<span style=
"color: #800000;"
>
'</span><span style="color: #800000;">45</span><span style="color: #800000;">'
</span>, <span style=
"color: #800080;"
>1</span><span style=
"color: #000000;"
>)
</span><span style=
"color: #008080;"
>132</span> <span style=
"color: #000000;"
> );
</span><span style=
"color: #008080;"
>133</span> <span style=
"color: #000000;"
> }
</span><span style=
"color: #008080;"
>134</span>
<span style=
"color: #008080;"
>135</span> <span style=
"color: #008000;"
>
</span>
<span style=
"color: #008080;"
>139</span> <span style=
"color: #0000ff;"
>
public
</span><span style=
"color: #000000;"
>
function
testConnectToServer()
</span><span style=
"color: #008080;"
>140</span> <span style=
"color: #000000;"
> {
</span><span style=
"color: #008080;"
>141</span> <span style=
"color: #008000;"
>
</span><span style=
"color: #008080;"
>142</span> <span style=
"color: #008000;"
>
</span><span style=
"color: #008080;"
>143</span> <span style=
"color: #008000;"
>
</span><span style=
"color: #008080;"
>144</span> <span style=
"color: #008000;"
>
<span style=
"color: #008080;"
>145</span>
$serverName
= <span style=
"color: #800000;"
>
'</span><span style="color: #800000;">wwwcom</span><span style="color: #800000;">'
</span><span style=
"color: #000000;"
>;
</span><span style=
"color: #008080;"
>146</span> $<span style=
"color: #0000ff;"
>this</span>->assertTrue($<span style=
"color: #0000ff;"
>this</span>-><span style=
"color: #0000ff;"
>object</span>->connectToServer(
$serverName
) === <span style=
"color: #0000ff;"
>false</span><span style=
"color: #000000;"
>);
</span><span style=
"color: #008080;"
>147</span> <span style=
"color: #000000;"
> }
</span><span style=
"color: #008080;"
>148</span> <span style=
"color: #0000ff;"
>
public
</span><span style=
"color: #000000;"
>
function
testConnectToServer2()
</span><span style=
"color: #008080;"
>149</span> <span style=
"color: #000000;"
> {
</span><span style=
"color: #008080;"
>150</span>
$serverName
= <span style=
"color: #800000;"
>
'</span><span style="color: #800000;">www.baidu.com</span><span style="color: #800000;">'
</span><span style=
"color: #000000;"
>;
</span><span style=
"color: #008080;"
>151</span> $<span style=
"color: #0000ff;"
>this</span>->assertTrue($<span style=
"color: #0000ff;"
>this</span>-><span style=
"color: #0000ff;"
>object</span>->connectToServer(
$serverName
) !== <span style=
"color: #0000ff;"
>false</span><span style=
"color: #000000;"
>);
</span><span style=
"color: #008080;"
>152</span> }