|
@@ 221-243 (lines=23) @@
|
| 218 |
|
$this->assertFalse($this->Vehicle->canShiftUp(2)); |
| 219 |
|
} |
| 220 |
|
|
| 221 |
|
public function testFindAllByState() { |
| 222 |
|
$this->assertFalse($this->Vehicle->findAllByState()); |
| 223 |
|
$this->assertFalse($this->Vehicle->findAllByState('illegal_state_should_not_be_possible')); |
| 224 |
|
$this->assertFalse($this->Vehicle->findAllByState(array('illegal_state_should_not_be_possible', 'parked'))); |
| 225 |
|
$this->assertCount(2, $this->Vehicle->findAllByState('parked')); |
| 226 |
|
$this->assertCount(1, $this->Vehicle->findAllByState('parked', array('conditions' => array('Vehicle.title' => 'Audi Q4')))); |
| 227 |
|
$this->assertCount(4, $this->Vehicle->findAllByState('all')); |
| 228 |
|
$this->assertCount(1, $this->Vehicle->findAllByState('idling')); |
| 229 |
|
$this->assertCount(3, $this->Vehicle->findAllByState(array('idling', 'parked'))); |
| 230 |
|
|
| 231 |
|
// test with transition array |
| 232 |
|
$testTransitions = $this->Vehicle->findAllByState('parked'); |
| 233 |
|
$this->assertTrue(is_array($testTransitions[0]['Vehicle']['Transitions'])); |
| 234 |
|
$this->assertCount(2, $testTransitions[0]['Vehicle']['Transitions']); |
| 235 |
|
|
| 236 |
|
// test without transitions array |
| 237 |
|
$testTransitions = $this->Vehicle->findAllByState('parked', array(), false); |
| 238 |
|
$this->assertFalse(isset($testTransitions[0]['Vehicle']['Transitions'])); |
| 239 |
|
|
| 240 |
|
$this->Vehicle = new RulesVehicle(1); |
| 241 |
|
$testTransitions = $this->Vehicle->findAllByState('parked', array(), true, 'driver'); |
| 242 |
|
$this->assertEqual(array('ignite', 'turn_off'), $testTransitions[0]['RulesVehicle']['Transitions']); |
| 243 |
|
} |
| 244 |
|
|
| 245 |
|
public function testFindCountByState() { |
| 246 |
|
$this->assertFalse($this->Vehicle->findCountByState()); |
|
@@ 256-278 (lines=23) @@
|
| 253 |
|
$this->assertEqual(3, $this->Vehicle->findCountByState(array('idling', 'parked'))); |
| 254 |
|
} |
| 255 |
|
|
| 256 |
|
public function testFindFirstByState() { |
| 257 |
|
$this->assertFalse($this->Vehicle->findFirstByState()); |
| 258 |
|
$this->assertFalse($this->Vehicle->findFirstByState('illegal_state_should_not_be_possible')); |
| 259 |
|
$this->assertFalse($this->Vehicle->findFirstByState(array('illegal_state_should_not_be_possible', 'parked'))); |
| 260 |
|
$this->assertCount(1, $this->Vehicle->findFirstByState('parked')); |
| 261 |
|
$this->assertCount(1, $this->Vehicle->findFirstByState('parked', array('conditions' => array('Vehicle.title' => 'Audi Q4')))); |
| 262 |
|
$this->assertCount(1, $this->Vehicle->findFirstByState('all')); |
| 263 |
|
$this->assertCount(1, $this->Vehicle->findFirstByState('idling')); |
| 264 |
|
$this->assertCount(1, $this->Vehicle->findFirstByState(array('idling', 'parked'))); |
| 265 |
|
|
| 266 |
|
// test with transition array |
| 267 |
|
$testTransitions = $this->Vehicle->findFirstByState('parked'); |
| 268 |
|
$this->assertTrue(is_array($testTransitions[0]['Vehicle']['Transitions'])); |
| 269 |
|
$this->assertCount(2, $testTransitions[0]['Vehicle']['Transitions']); |
| 270 |
|
|
| 271 |
|
// test without transitions array |
| 272 |
|
$testTransitions = $this->Vehicle->findFirstByState('parked', array(), false); |
| 273 |
|
$this->assertFalse(isset($testTransitions[0]['Vehicle']['Transitions'])); |
| 274 |
|
|
| 275 |
|
$this->Vehicle = new RulesVehicle(1); |
| 276 |
|
$testTransitions = $this->Vehicle->findFirstByState('parked', array(), true, 'driver'); |
| 277 |
|
$this->assertEqual(array('ignite', 'turn_off'), $testTransitions[0]['RulesVehicle']['Transitions']); |
| 278 |
|
} |
| 279 |
|
|
| 280 |
|
public function testInitialState() { |
| 281 |
|
$this->assertEquals("parked", $this->Vehicle->getCurrentState()); |