1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
namespace Yiisoft\ActiveRecord\Tests\Driver\Mysql; |
6
|
|
|
|
7
|
|
|
use Yiisoft\ActiveRecord\ActiveQuery; |
8
|
|
|
use Yiisoft\ActiveRecord\Tests\Stubs\MagicActiveRecord\Beta; |
9
|
|
|
use Yiisoft\ActiveRecord\Tests\Stubs\MagicActiveRecord\Customer; |
10
|
|
|
use Yiisoft\ActiveRecord\Tests\Support\MysqlHelper; |
11
|
|
|
|
12
|
|
|
final class MagicActiveRecordTest extends \Yiisoft\ActiveRecord\Tests\MagicActiveRecordTest |
|
|
|
|
13
|
|
|
{ |
14
|
|
|
public function setUp(): void |
15
|
|
|
{ |
16
|
|
|
parent::setUp(); |
17
|
|
|
|
18
|
|
|
$mysqlHelper = new MysqlHelper(); |
19
|
|
|
$this->db = $mysqlHelper->createConnection(); |
|
|
|
|
20
|
|
|
} |
21
|
|
|
|
22
|
|
|
protected function tearDown(): void |
23
|
|
|
{ |
24
|
|
|
parent::tearDown(); |
25
|
|
|
|
26
|
|
|
$this->db->close(); |
27
|
|
|
|
28
|
|
|
unset($this->db); |
29
|
|
|
} |
30
|
|
|
|
31
|
|
|
public function testExplicitPkOnAutoIncrement(): void |
32
|
|
|
{ |
33
|
|
|
$this->checkFixture($this->db, 'customer'); |
34
|
|
|
|
35
|
|
|
$customer = new Customer($this->db); |
36
|
|
|
|
37
|
|
|
$customer->id = 1337; |
38
|
|
|
$customer->email = '[email protected]'; |
39
|
|
|
$customer->name = 'user1337'; |
40
|
|
|
$customer->address = 'address1337'; |
41
|
|
|
|
42
|
|
|
$this->assertTrue($customer->isNewRecord); |
|
|
|
|
43
|
|
|
|
44
|
|
|
$customer->save(); |
45
|
|
|
|
46
|
|
|
$this->assertEquals(1337, $customer->id); |
47
|
|
|
$this->assertFalse($customer->isNewRecord); |
48
|
|
|
} |
49
|
|
|
|
50
|
|
|
/** |
51
|
|
|
* {@see https://github.com/yiisoft/yii2/issues/15482} |
52
|
|
|
*/ |
53
|
|
|
public function testEagerLoadingUsingStringIdentifiers(): void |
54
|
|
|
{ |
55
|
|
|
$this->checkFixture($this->db, 'beta'); |
56
|
|
|
|
57
|
|
|
$betaQuery = new ActiveQuery(Beta::class, $this->db); |
58
|
|
|
|
59
|
|
|
$betas = $betaQuery->with('alpha')->all(); |
60
|
|
|
|
61
|
|
|
$this->assertNotEmpty($betas); |
62
|
|
|
|
63
|
|
|
$alphaIdentifiers = []; |
64
|
|
|
|
65
|
|
|
/** @var Beta[] $betas */ |
66
|
|
|
foreach ($betas as $beta) { |
67
|
|
|
$this->assertNotNull($beta->alpha); |
68
|
|
|
$this->assertEquals($beta->alpha_string_identifier, $beta->alpha->string_identifier); |
69
|
|
|
$alphaIdentifiers[] = $beta->alpha->string_identifier; |
70
|
|
|
} |
71
|
|
|
|
72
|
|
|
$this->assertEquals(['1', '01', '001', '001', '2', '2b', '2b', '02'], $alphaIdentifiers); |
73
|
|
|
} |
74
|
|
|
} |
75
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths