diff --git a/tests/Fixture/CompositeIncrementsFixture.php b/tests/Fixture/CompositeIncrementsFixture.php new file mode 100644 index 00000000000..2992cd64d87 --- /dev/null +++ b/tests/Fixture/CompositeIncrementsFixture.php @@ -0,0 +1,41 @@ + ['type' => 'integer', 'null' => false, 'autoIncrement' => true], + 'account_id' => ['type' => 'integer', 'null' => false], + 'name' => ['type' => 'string', 'default' => null], + '_constraints' => ['primary' => ['type' => 'primary', 'columns' => ['id', 'account_id']]] + ]; + + /** + * records property + * + * @var array + */ + public $records = [ + ]; +} diff --git a/tests/Fixture/SiteAuthorsFixture.php b/tests/Fixture/SiteAuthorsFixture.php index 3a8e3c807f5..80efba339ab 100644 --- a/tests/Fixture/SiteAuthorsFixture.php +++ b/tests/Fixture/SiteAuthorsFixture.php @@ -25,7 +25,7 @@ class SiteAuthorsFixture extends TestFixture * @var array */ public $fields = [ - 'id' => ['type' => 'integer', 'autoIncrement' => true], + 'id' => ['type' => 'integer'], 'name' => ['type' => 'string', 'default' => null], 'site_id' => ['type' => 'integer', 'null' => true], '_constraints' => ['primary' => ['type' => 'primary', 'columns' => ['id', 'site_id']]] @@ -37,9 +37,9 @@ class SiteAuthorsFixture extends TestFixture * @var array */ public $records = [ - ['name' => 'mark', 'site_id' => 1], - ['name' => 'juan', 'site_id' => 2], - ['name' => 'jose', 'site_id' => 2], - ['name' => 'andy', 'site_id' => 1] + ['id' => 1, 'name' => 'mark', 'site_id' => 1], + ['id' => 2, 'name' => 'juan', 'site_id' => 2], + ['id' => 3, 'name' => 'jose', 'site_id' => 2], + ['id' => 4, 'name' => 'andy', 'site_id' => 1] ]; } diff --git a/tests/TestCase/ORM/TableTest.php b/tests/TestCase/ORM/TableTest.php index b7f02c7d542..4ea4d0d2ef6 100644 --- a/tests/TestCase/ORM/TableTest.php +++ b/tests/TestCase/ORM/TableTest.php @@ -55,7 +55,7 @@ class TableTest extends TestCase 'core.authors', 'core.tags', 'core.articles_tags', - 'core.site_authors', + 'core.composite_increments', 'core.site_articles', ]; @@ -2000,11 +2000,11 @@ public function testSaveNewErrorCompositeKeyNoIncrement() public function testSaveNewCompositeKeyIncrement() { $this->skipIfSqlite(); - $articles = TableRegistry::get('SiteAuthors'); - $article = $articles->newEntity(['site_id' => 3, 'name' => 'new guy']); - $this->assertSame($article, $articles->save($article)); - $this->assertNotEmpty($article->id, 'Primary key should have been populated'); - $this->assertSame(3, $article->site_id); + $table = TableRegistry::get('CompositeIncrements'); + $thing = $table->newEntity(['account_id' => 3, 'name' => 'new guy']); + $this->assertSame($thing, $table->save($thing)); + $this->assertNotEmpty($thing->id, 'Primary key should have been populated'); + $this->assertSame(3, $thing->account_id); } /**