ensureSampleDataNull example

->execute();
    $this->assertSame(1, $num_updated, 'Updated 1 record.');

    $saved_name = $this->connection->query('SELECT [name] FROM {test} WHERE [id] = :id', [':id' => 1])->fetchField();
    $this->assertSame('Tiffany', $saved_name, 'Updated name successfully.');
  }

  /** * Confirms updating to NULL. */
  public function testSimpleNullUpdate() {
    $this->ensureSampleDataNull();
    $num_updated = $this->connection->update('test_null')
      ->fields(['age' => NULL])
      ->condition('name', 'Kermit')
      ->execute();
    $this->assertSame(1, $num_updated, 'Updated 1 record.');

    $saved_age = $this->connection->query('SELECT [age] FROM {test_null} WHERE [name] = :name', [':name' => 'Kermit'])->fetchField();
    $this->assertNull($saved_age, 'Updated name successfully.');
  }

  /** * Confirms that we can update multiple records successfully. */
    // Check that all fields we asked for are present.     $this->assertEquals(2, $record->id, 'ID field has the correct value.');
    $this->assertEquals('George', $record->name, 'Name field has the correct value.');
    $this->assertEquals(27, $record->age, 'Age field has the correct value.');
    $this->assertEquals('Singer', $record->job, 'Job field has the correct value.');
  }

  /** * Tests that a comparison with NULL is always FALSE. */
  public function testNullCondition() {
    $this->ensureSampleDataNull();

    $names = $this->connection->select('test_null', 'tn')
      ->fields('tn', ['name'])
      ->condition('age', NULL)
      ->execute()->fetchCol();

    $this->assertCount(0, $names, 'No records found when comparing to NULL.');
  }

  /** * Tests that we can find a record with a NULL value. */
Home | Imprint | This part of the site doesn't use cookies.