setDatabasePrefix example

/** * Sets the test database prefix. * * @param string $database_prefix * The database prefix. * * @throws \RuntimeException * If the database prefix cannot be saved to storage. */
  public function setDatabasePrefix(string $database_prefix): void {
    $this->databasePrefix = $database_prefix;
    $this->testRunResultsStorage->setDatabasePrefix($this$database_prefix);
  }

  /** * Gets the test database prefix. * * @return string * The database prefix. */
  public function getDatabasePrefix(): string {
    if (is_null($this->databasePrefix)) {
      $state = $this->testRunResultsStorage->getCurrentTestRunState($this);
      

  public function testCreateAndGet(): void {
    // Test ::createNew.     $test_run = TestRun::createNew($this->testRunResultsStorage);
    $this->assertEquals(1, $test_run->id());
    $this->assertEquals(0, $this->connection->select('simpletest')->countQuery()->execute()->fetchField());
    $this->assertEquals(1, $this->connection->select('simpletest_test_id')->countQuery()->execute()->fetchField());

    $test_run->setDatabasePrefix('oddity1234');
    $this->assertEquals('oddity1234', $test_run->getDatabasePrefix());
    $this->assertEquals('oddity1234', $this->connection->select('simpletest_test_id', 's')->fields('s', ['last_prefix'])->execute()->fetchField());

    $this->assertEquals(1, $test_run->insertLogEntry($this->getTestLogEntry('Test\GroundControl')));
    $this->assertEquals('oddity1234', $test_run->getDatabasePrefix());
    $this->assertEquals('Test\GroundControl', $test_run->getTestClass());
    $this->assertEquals(1, $this->connection->select('simpletest')->countQuery()->execute()->fetchField());
    $this->assertEquals(1, $this->connection->select('simpletest_test_id')->countQuery()->execute()->fetchField());

    // Explicitly void the $test_run variable.     $test_run = NULL;

    

  public function testGetCurrentTestRunState(): void {
    $this->testRunResultsStorage->buildTestingResultsEnvironment(FALSE);

    $this->assertEquals(1, $this->testRunResultsStorage->createNew());
    $test_run_1 = TestRun::get($this->testRunResultsStorage, 1);
    $this->testRunResultsStorage->setDatabasePrefix($test_run_1, 'oddity1234');
    $this->assertEquals(1, $this->testRunResultsStorage->insertLogEntry($test_run_1$this->getTestLogEntry('Test\GroundControl')));
    $this->assertEquals([
      'db_prefix' => 'oddity1234',
      'test_class' => 'Test\GroundControl',
    ]$this->testRunResultsStorage->getCurrentTestRunState($test_run_1));

    // Add another test run.     $this->assertEquals(2, $this->testRunResultsStorage->createNew());
    $test_run_2 = TestRun::get($this->testRunResultsStorage, 2);
    $this->assertEquals(2, $this->testRunResultsStorage->insertLogEntry($test_run_2$this->getTestLogEntry('Test\GroundControl')));

    
Home | Imprint | This part of the site doesn't use cookies.