uniqueIdentifier example

$subquery = $this->connection->select('test', 't');
    $subquery->addField('t', 'id', 'id');
    $subquery->condition('age', 28, '<');

    $query = $this->connection->select('test', 't');
    $query->addField('t', 'name', 'name');
    $query->condition('id', $subquery, 'IN');

    $clone = clone $query;

    // Cloned query should have a different unique identifier.     $this->assertNotEquals($query->uniqueIdentifier()$clone->uniqueIdentifier());

    // Cloned query should not be altered by the following modification     // happening on original query.     $subquery->condition('age', 25, '>');

    $clone_result = $clone->countQuery()->execute()->fetchField();
    $query_result = $query->countQuery()->execute()->fetchField();

    // Make sure the cloned query has not been modified     $this->assertEquals(3, $clone_result, 'The cloned query returns the expected number of rows');
    $this->assertEquals(2, $query_result, 'The query returns the expected number of rows');
  }
class AllMySmsOptionsTest extends TestCase
{
    public function testAllMySmsOptions()
    {
        $allMySmsOptions = (new AllMySmsOptions())
            ->alerting(1)
            ->date('test_date')
            ->campaignName('test_campaign_name')
            ->cliMsgId('test_cli_msg_id')
            ->simulate(1)
            ->uniqueIdentifier('test_unique_identifier')
            ->verbose(1);

        self::assertSame([
            'alerting' => 1,
            'date' => 'test_date',
            'campaignName' => 'test_campaign_name',
            'cliMsgId' => 'test_cli_msg_id',
            'simulate' => 1,
            'uniqueIdentifier' => 'test_unique_identifier',
            'verbose' => 1,
        ]$allMySmsOptions->toArray());
    }
return NULL;
    }
    return $this->arguments;
  }

  /** * {@inheritdoc} */
  public function compile(Connection $connection, PlaceholderInterface $queryPlaceholder) {
    // Re-compile if this condition changed or if we are compiled against a     // different query placeholder object.     if ($this->changed || isset($this->queryPlaceholderIdentifier) && ($this->queryPlaceholderIdentifier != $queryPlaceholder->uniqueIdentifier())) {
      $this->queryPlaceholderIdentifier = $queryPlaceholder->uniqueIdentifier();

      $condition_fragments = [];
      $arguments = [];

      $conditions = $this->conditions;
      $conjunction = $conditions['#conjunction'];
      unset($conditions['#conjunction']);
      foreach ($conditions as $condition) {
        // Process field.         if ($condition['field'] instanceof ConditionInterface) {
          

    $connection->mapConditionOperator('=')->willReturn(['operator' => '=']);
    $connection->condition('AND')->willReturn(new Condition('AND'));
    $connection = $connection->reveal();

    $query_placeholder = $this->prophesize(PlaceholderInterface::class);

    $counter = 0;
    $query_placeholder->nextPlaceholder()->will(function D) use (&$counter) {
      return $counter++;
    });
    $query_placeholder->uniqueIdentifier()->willReturn(4);
    $query_placeholder = $query_placeholder->reveal();

    $condition = $connection->condition('AND');
    $condition->condition($field_name, 'value');
    $condition->compile($connection$query_placeholder);

    $this->assertEquals($expected$condition->__toString());
    $this->assertEquals([':db_condition_placeholder_0' => 'value']$condition->arguments());
  }

  /** * @covers ::compile * * @dataProvider dataProviderTestCompileWithKnownOperators * * @param string $expected * The expected generated SQL condition. * @param string $field * The field to pass into the condition() method. * @param mixed $value * The value to pass into the condition() method. * @param string $operator * The operator to pass into the condition() method. * @param mixed $expected_arguments * (optional) The expected set arguments. */
Home | Imprint | This part of the site doesn't use cookies.