You are here

public function FeatureContext::createUnitsOfType in Rooms - Drupal Booking for Hotels, B&Bs and Vacation Rentals 7

@Given /^(\d+) units of type "([^"]*)"$/

File

test/features/bootstrap/FeatureContext.php, line 280

Class

FeatureContext
Features context.

Code

public function createUnitsOfType($count, $type) {
  $random = new Random();
  for ($i = 0; $i < $count; $i++) {
    $unit = rooms_unit_create(array(
      'name' => $random
        ->name(8),
      'type' => $type,
      'default_state' => 1,
    ));
    if (isset($this->user->uid)) {
      $unit->uid = $this->user->uid;
    }
    $unit
      ->save();
    $this->units[] = $unit;
  }
}