Skip to content

Commit

Permalink
Test repro using CI
Browse files Browse the repository at this point in the history
  • Loading branch information
mvorisek committed Jun 9, 2021
1 parent 2fff975 commit 9396d64
Show file tree
Hide file tree
Showing 69 changed files with 64 additions and 14,626 deletions.
49 changes: 49 additions & 0 deletions repro.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<?php

namespace PhpBug81113;

use Atk4\Data\Model;
use Atk4\Data\Persistence;

if (!class_exists(\Composer\Autoload::class, false)) {
require_once __DIR__ . '/../../../vendor/autoload.php';
}

$createModelWithConnection = function () {
// establish connection
$dsn = $GLOBALS['DB_DSN'] ?? 'sqlite::memory:';
$user = $GLOBALS['DB_USER'] ?? null;
$pass = $GLOBALS['DB_PASSWD'] ?? null;

$p = Persistence::connect($dsn, $user, $pass);

$db = new Persistence\Sql($p->connection);
$m = new Model($db, ['table' => 'user']);

$m->addFields(['name', 'gender']);

return [$p, $m];
};

$wrDbalConns = [];
(function () use ($createModelWithConnection, &$wrDbalConns) {
for ($i = 0; $i < 5; $i++) {
[$p, $m] = $createModelWithConnection();
$wrDbalConns[] = \WeakReference::create(
$p->connection->connection
);
$wrDbalConns[] = \WeakReference::create(
\Closure::bind(static fn() => $p->connection->connection->_conn, null, \Doctrine\DBAL\Connection::class)
);
}
})();

echo '------------' . "\n";
gc_collect_cycles();
gc_collect_cycles();
echo '------------' . "\n";
print_r(array_map(function (\WeakReference $wrConn) {
$dbalConn = $wrConn->get();
return $dbalConn !== null ? 'NOT freed' : 'ok';
}, $wrDbalConns));
echo '------------' . "\n";
47 changes: 2 additions & 45 deletions tests-schema/BasicTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,53 +4,10 @@

namespace Atk4\Schema\Tests;

use Atk4\Schema\PhpunitTestCase;

class BasicTest extends PhpunitTestCase
class BasicTest extends \Atk4\Core\AtkPhpunit\TestCase
{
/**
* @doesNotPerformAssertions
*/
public function testCreate(): void
{
$this->dropTableIfExists('user');

$this->createMigrator()->table('user')->id()
->field('foo')
->field('bar', ['type' => 'integer'])
->field('baz', ['type' => 'text'])
->field('bl', ['type' => 'boolean'])
->field('tm', ['type' => 'time'])
->field('dt', ['type' => 'date'])
->field('dttm', ['type' => 'datetime'])
->field('fl', ['type' => 'float'])
->field('mn', ['type' => 'money'])
// ->field('en', ['type' => 'enum'])
->create();
}

/**
* Tests creating and dropping of tables.
*
* @doesNotPerformAssertions
*/
public function testCreateAndDrop(): void
{
$this->dropTableIfExists('user');

$this->createMigrator()->table('user')->id()
->field('foo')
->field('bar', ['type' => 'integer'])
->field('baz', ['type' => 'text'])
->field('bl', ['type' => 'boolean'])
->field('tm', ['type' => 'time'])
->field('dt', ['type' => 'date'])
->field('dttm', ['type' => 'datetime'])
->field('fl', ['type' => 'float'])
->field('mn', ['type' => 'money'])
// ->field('en', ['type' => 'enum'])
->create();

$this->createMigrator()->table('user')->drop();
$this->assertTrue(true);
}
}
195 changes: 0 additions & 195 deletions tests-schema/ModelTest.php

This file was deleted.

29 changes: 0 additions & 29 deletions tests-schema/PhpunitTestCaseTest.php

This file was deleted.

13 changes: 13 additions & 0 deletions tests/BasicTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php

declare(strict_types=1);

namespace Atk4\Data\Tests;

class BasicTest extends \Atk4\Core\AtkPhpunit\TestCase
{
public function testRepro(): void
{
require_once __DIR__ . '/../repro.php';
}
}
Loading

0 comments on commit 9396d64

Please sign in to comment.