<commit_before><?php

if (ini_get('zend.assertions') != 1) {
    exit('zend.assertions must be enabled');
}
assert_options(ASSERT_ACTIVE, true);
assert_options(ASSERT_WARNING, true);
assert_options(ASSERT_BAIL, true);


$targetNamespace = '\\Database';
$targetDirectory = __DIR__ . DIRECTORY_SEPARATOR . 'gen';

if (file_exists($targetDirectory) === false) {
    mkdir($targetDirectory);
}

$phpbin = trim(`which php`);
$command = $phpbin . ' ' . dirname(__DIR__) . DIRECTORY_SEPARATOR . 'bin' . DIRECTORY_SEPARATOR . 'generate.php ' . $targetNamespace . ' ' . $targetDirectory . ' ' . $_SERVER['argv'][1];
echo 'Running ' . $command . '...' . PHP_EOL;
passthru($command);

// test activiteit
require __DIR__ . '/bootstrap.php';
$url = parse_url($_SERVER['argv'][1]);
$connection = new \PDO($url['scheme'] . ':dbname=' . substr($url['path'], 1), $url['user'], $url['pass'], array(PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES \'UTF8\''));

$recordConfigurator = new \pulledbits\ActiveRecord\RecordFactory($targetDirectory);

$schema = new \pulledbits\ActiveRecord\SQL\Schema($recordConfigurator, $connection);

$starttijd = date('Y-m-d ') . '23:00:00';

$schema->delete('contactmoment', ['starttijd' => $starttijd, 'les_id' => '1']);
$schema->delete('contactmoment', ['starttijd' => $starttijd, 'les_id' => '2']);
assert(count($schema->read('contactmoment', [], ['starttijd' => $starttijd, 'les_id' => '2'])) === 0, 'previous record exists');
assert($schema->create('contactmoment', ['starttijd' => $starttijd, 'les_id' => '1']) === 1, 'no record created');
$record = $schema->read('contactmoment', [], ['starttijd' => $starttijd, 'les_id' => '1'])[0];
assert($record->les_id === '1', 'record is properly initialized');
$record->les_id = '2';
assert($record->les_id === $schema->read('contactmoment', [], ['starttijd' => $starttijd, 'les_id' => '2'])[0]->les_id, 'record is properly updated');

$viewRecord = $schema->read("contactmoment_vandaag", [], []);
assert(count($viewRecord) === 1, 'view records exist');

assert(count($record->delete()) === 1, 'delete confirms removal');
echo 'Done testing';<commit_msg>make sure contactmoment_vandaag also works with mulitple contactmomenten<commit_after><?php

if (ini_get('zend.assertions') != 1) {
    exit('zend.assertions must be enabled');
}
assert_options(ASSERT_ACTIVE, true);
assert_options(ASSERT_WARNING, true);
assert_options(ASSERT_BAIL, true);


$targetNamespace = '\\Database';
$targetDirectory = __DIR__ . DIRECTORY_SEPARATOR . 'gen';

if (file_exists($targetDirectory) === false) {
    mkdir($targetDirectory);
}

$phpbin = trim(`which php`);
$command = $phpbin . ' ' . dirname(__DIR__) . DIRECTORY_SEPARATOR . 'bin' . DIRECTORY_SEPARATOR . 'generate.php ' . $targetNamespace . ' ' . $targetDirectory . ' ' . $_SERVER['argv'][1];
echo 'Running ' . $command . '...' . PHP_EOL;
passthru($command);

// test activiteit
require __DIR__ . '/bootstrap.php';
$url = parse_url($_SERVER['argv'][1]);
$connection = new \PDO($url['scheme'] . ':dbname=' . substr($url['path'], 1), $url['user'], $url['pass'], array(PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES \'UTF8\''));

$recordConfigurator = new \pulledbits\ActiveRecord\RecordFactory($targetDirectory);

$schema = new \pulledbits\ActiveRecord\SQL\Schema($recordConfigurator, $connection);

$starttijd = date('Y-m-d ') . '23:00:00';

$schema->delete('contactmoment', ['starttijd' => $starttijd, 'les_id' => '1']);
$schema->delete('contactmoment', ['starttijd' => $starttijd, 'les_id' => '2']);
assert(count($schema->read('contactmoment', [], ['starttijd' => $starttijd, 'les_id' => '2'])) === 0, 'previous record exists');
assert($schema->create('contactmoment', ['starttijd' => $starttijd, 'les_id' => '1']) === 1, 'no record created');
$record = $schema->read('contactmoment', [], ['starttijd' => $starttijd, 'les_id' => '1'])[0];
assert($record->les_id === '1', 'record is properly initialized');
$record->les_id = '2';
assert($record->les_id === $schema->read('contactmoment', [], ['starttijd' => $starttijd, 'les_id' => '2'])[0]->les_id, 'record is properly updated');

$viewRecord = $schema->readFirst("contactmoment_vandaag", [], ['starttijd' => $starttijd]);
assert($viewRecord->starttijd === $starttijd, 'view records exist');

assert(count($record->delete()) === 1, 'delete confirms removal');
echo 'Done testing';
{'fraction_non_alphanumeric': 0.22304488662656177, 'fraction_numerical': 0.011337343822304488, 'mean_word_length': 6.415094339622642, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 55, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '613216', 'n_tokens_mistral': 1484, 'n_tokens_neox': 1486, 'n_words': 284}