comparison core/modules/migrate/tests/src/Kernel/SqlBaseTest.php @ 14:1fec387a4317

Update Drupal core to 8.5.2 via Composer
author Chris Cannam
date Mon, 23 Apr 2018 09:46:53 +0100
parents 4c8ae668cc8c
children
comparison
equal deleted inserted replaced
13:5fb285c0d0e3 14:1fec387a4317
7 7
8 namespace Drupal\Tests\migrate\Kernel; 8 namespace Drupal\Tests\migrate\Kernel;
9 9
10 use Drupal\Core\Database\Query\ConditionInterface; 10 use Drupal\Core\Database\Query\ConditionInterface;
11 use Drupal\Core\Database\Query\SelectInterface; 11 use Drupal\Core\Database\Query\SelectInterface;
12 use Drupal\Core\Database\StatementInterface;
12 use Drupal\migrate\Exception\RequirementsException; 13 use Drupal\migrate\Exception\RequirementsException;
13 use Drupal\Core\Database\Database; 14 use Drupal\Core\Database\Database;
14 use Drupal\migrate\Plugin\migrate\source\SqlBase; 15 use Drupal\migrate\Plugin\migrate\source\SqlBase;
15 use Drupal\migrate\Plugin\MigrationInterface; 16 use Drupal\migrate\Plugin\MigrationInterface;
16 17
44 public function testConnectionTypes() { 45 public function testConnectionTypes() {
45 $sql_base = new TestSqlBase([], $this->migration); 46 $sql_base = new TestSqlBase([], $this->migration);
46 47
47 // Verify that falling back to the default 'migrate' connection (defined in 48 // Verify that falling back to the default 'migrate' connection (defined in
48 // the base class) works. 49 // the base class) works.
49 $this->assertSame($sql_base->getDatabase()->getTarget(), 'default'); 50 $this->assertSame('default', $sql_base->getDatabase()->getTarget());
50 $this->assertSame($sql_base->getDatabase()->getKey(), 'migrate'); 51 $this->assertSame('migrate', $sql_base->getDatabase()->getKey());
51 52
52 // Verify the fallback state key overrides the 'migrate' connection. 53 // Verify the fallback state key overrides the 'migrate' connection.
53 $target = 'test_fallback_target'; 54 $target = 'test_fallback_target';
54 $key = 'test_fallback_key'; 55 $key = 'test_fallback_key';
55 $config = ['target' => $target, 'key' => $key]; 56 $config = ['target' => $target, 'key' => $key];
147 148
148 if ($high_water) { 149 if ($high_water) {
149 $source->getHighWaterStorage()->set($this->migration->id(), $high_water); 150 $source->getHighWaterStorage()->set($this->migration->id(), $high_water);
150 } 151 }
151 152
152 $query_result = new \ArrayIterator($query_result); 153 $statement = $this->createMock(StatementInterface::class);
153 154 $statement->expects($this->atLeastOnce())->method('setFetchMode')->with(\PDO::FETCH_ASSOC);
154 $query = $this->getMock(SelectInterface::class); 155 $query = $this->createMock(SelectInterface::class);
155 $query->method('execute')->willReturn($query_result); 156 $query->method('execute')->willReturn($statement);
156 $query->expects($this->atLeastOnce())->method('orderBy')->with('order', 'ASC'); 157 $query->expects($this->atLeastOnce())->method('orderBy')->with('order', 'ASC');
157 158
158 $condition_group = $this->getMock(ConditionInterface::class); 159 $condition_group = $this->getMock(ConditionInterface::class);
159 $query->method('orConditionGroup')->willReturn($condition_group); 160 $query->method('orConditionGroup')->willReturn($condition_group);
160 161