PHP code example of vjik / codeception-db-populator

1. Go to this page and download the library: Download vjik/codeception-db-populator library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

vjik / codeception-db-populator example snippets



return [
    'author' => [
        [
            'id' => 1,
            'name' => 'Ivan',
        ],
        [
            'id' => 2,
            'name' => 'Petr',
        ],
    ],
    'post' => [
        [
            'id' => 1,
            'author_id' => 2,
            'name' => 'First post',
        ],
        [
            'id' => 2,
            'author_id' => 2,
            'name' => 'My history',
        ],
    ],
];

final class BlogTest extends Unit
{
    public function testCreatePost(): void
    {
        $this->tester->loadDump('blog');
        $this->tester->loadRows('authors');
        ...
    }
}

$I->loadDump('blog'); // load one dump
$I->loadDump('blog', 'catalog'); // load several dumps

$I->loadRows('posts'); // load one set
$I->loadRows('users', 'comments'); // load several sets

tests/
  _data/
    dumps/
      user-management.sql
      blog.sql
      catalog.sql
    rows/
      users.php
      authors.php
      blog-categories.php
      posts-with-categories.php