@@ -50,4 +50,66 @@ public function testGetUnknownStatReturns0()
5050 {
5151 $ this ->assertEquals (0 , \Resque \Stat::get ('test_get_unknown ' ));
5252 }
53+
54+ // Tests with DISABLE_STATS=true
55+
56+ public function testStatIncrNoOpWhenDisabled ()
57+ {
58+ \Resque \Stat::setDisableStats (true );
59+ $ this ->assertTrue (\Resque \Stat::incr ('test_incr_disabled ' ));
60+ $ this ->assertTrue (\Resque \Stat::incr ('test_incr_disabled ' ));
61+ $ this ->assertEmpty ($ this ->redis ->get ('resque:stat:test_incr_disabled ' ));
62+ \Resque \Stat::setDisableStats (false );
63+ }
64+
65+ public function testStatIncrByXNoOpWhenDisabled ()
66+ {
67+ \Resque \Stat::setDisableStats (true );
68+ $ this ->assertTrue (\Resque \Stat::incr ('test_incrX_disabled ' , 10 ));
69+ $ this ->assertTrue (\Resque \Stat::incr ('test_incrX_disabled ' , 11 ));
70+ $ this ->assertEmpty ($ this ->redis ->get ('resque:stat:test_incrX_disabled ' ));
71+ \Resque \Stat::setDisableStats (false );
72+ }
73+
74+ public function testStatDecrNoOpWhenDisabled ()
75+ {
76+ \Resque \Stat::incr ('test_decr_disabled ' , 22 );
77+ \Resque \Stat::setDisableStats (true );
78+ $ this ->assertTrue (\Resque \Stat::decr ('test_decr_disabled ' ));
79+ $ this ->assertEquals (22 , $ this ->redis ->get ('resque:stat:test_decr_disabled ' ));
80+ \Resque \Stat::setDisableStats (false );
81+ }
82+
83+ public function testStatDecrByXNoOpWhenDisabled ()
84+ {
85+ \Resque \Stat::incr ('test_decrX_disabled ' , 22 );
86+ \Resque \Stat::setDisableStats (true );
87+ $ this ->assertTrue (\Resque \Stat::decr ('test_decrX_disabled ' , 11 ));
88+ $ this ->assertEquals (22 , $ this ->redis ->get ('resque:stat:test_decrX_disabled ' ));
89+ \Resque \Stat::setDisableStats (false );
90+ }
91+
92+ public function testGetStatReturns0WhenDisabled ()
93+ {
94+ \Resque \Stat::incr ('test_get_disabled ' , 100 );
95+ \Resque \Stat::setDisableStats (true );
96+ $ this ->assertEquals (0 , \Resque \Stat::get ('test_get_disabled ' ));
97+ \Resque \Stat::setDisableStats (false );
98+ }
99+
100+ public function testGetUnknownStatReturns0WhenDisabled ()
101+ {
102+ \Resque \Stat::setDisableStats (true );
103+ $ this ->assertEquals (0 , \Resque \Stat::get ('test_get_unknown_disabled ' ));
104+ \Resque \Stat::setDisableStats (false );
105+ }
106+
107+ public function testClearStatNoOpWhenDisabled ()
108+ {
109+ \Resque \Stat::incr ('test_clear_disabled ' , 50 );
110+ \Resque \Stat::setDisableStats (true );
111+ $ this ->assertTrue (\Resque \Stat::clear ('test_clear_disabled ' ));
112+ \Resque \Stat::setDisableStats (false );
113+ $ this ->assertEquals (50 , $ this ->redis ->get ('resque:stat:test_clear_disabled ' ));
114+ }
53115}
0 commit comments