Skip to content

Commit

Permalink
add data soruces for no-primary-key testing
Browse files Browse the repository at this point in the history
  • Loading branch information
Paul M. Jones committed Sep 7, 2020
1 parent a6b13be commit 543bd32
Show file tree
Hide file tree
Showing 16 changed files with 256 additions and 8 deletions.
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/vendor
/composer.lock
/atlas-testing.sq3
/atlas-testing.php
/atlas-config.php
/atlas-sqlite.sq3
27 changes: 27 additions & 0 deletions src/DataSource/Nopkey/Nopkey.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?php
declare(strict_types=1);

namespace Atlas\Testing\DataSource\Nopkey;

use Atlas\Mapper\Mapper;
use Atlas\Table\Row;

/**
* @method NopkeyTable getTable()
* @method NopkeyRelationships getRelationships()
* @method NopkeyRecord|null fetchRecord($primaryVal, array $with = [])
* @method NopkeyRecord|null fetchRecordBy(array $whereEquals, array $with = [])
* @method NopkeyRecord[] fetchRecords(array $primaryVals, array $with = [])
* @method NopkeyRecord[] fetchRecordsBy(array $whereEquals, array $with = [])
* @method NopkeyRecordSet fetchRecordSet(array $primaryVals, array $with = [])
* @method NopkeyRecordSet fetchRecordSetBy(array $whereEquals, array $with = [])
* @method NopkeySelect select(array $whereEquals = [])
* @method NopkeyRecord newRecord(array $fields = [])
* @method NopkeyRecord[] newRecords(array $fieldSets)
* @method NopkeyRecordSet newRecordSet(array $records = [])
* @method NopkeyRecord turnRowIntoRecord(Row $row, array $with = [])
* @method NopkeyRecord[] turnRowsIntoRecords(array $rows, array $with = [])
*/
class Nopkey extends Mapper
{
}
16 changes: 16 additions & 0 deletions src/DataSource/Nopkey/NopkeyEvents.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php
declare(strict_types=1);

namespace Atlas\Testing\DataSource\Nopkey;

use Atlas\Mapper\Mapper;
use Atlas\Mapper\MapperEvents;
use Atlas\Mapper\Record;
use Atlas\Query\Delete;
use Atlas\Query\Insert;
use Atlas\Query\Update;
use PDOStatement;

class NopkeyEvents extends MapperEvents
{
}
15 changes: 15 additions & 0 deletions src/DataSource/Nopkey/NopkeyFields.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?php
/**
* This file was generated by Atlas. Changes will be overwritten.
*/
declare(strict_types=1);

namespace Atlas\Testing\DataSource\Nopkey;

/**
* @property mixed $name VARCHAR(255)
* @property mixed $email VARCHAR(255)
*/
trait NopkeyFields
{
}
14 changes: 14 additions & 0 deletions src/DataSource/Nopkey/NopkeyRecord.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?php
declare(strict_types=1);

namespace Atlas\Testing\DataSource\Nopkey;

use Atlas\Mapper\Record;

/**
* @method NopkeyRow getRow()
*/
class NopkeyRecord extends Record
{
use NopkeyFields;
}
20 changes: 20 additions & 0 deletions src/DataSource/Nopkey/NopkeyRecordSet.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php
declare(strict_types=1);

namespace Atlas\Testing\DataSource\Nopkey;

use Atlas\Mapper\RecordSet;

/**
* @method NopkeyRecord offsetGet($offset)
* @method NopkeyRecord appendNew(array $fields = [])
* @method NopkeyRecord|null getOneBy(array $whereEquals)
* @method NopkeyRecordSet getAllBy(array $whereEquals)
* @method NopkeyRecord|null detachOneBy(array $whereEquals)
* @method NopkeyRecordSet detachAllBy(array $whereEquals)
* @method NopkeyRecordSet detachAll()
* @method NopkeyRecordSet detachDeleted()
*/
class NopkeyRecordSet extends RecordSet
{
}
13 changes: 13 additions & 0 deletions src/DataSource/Nopkey/NopkeyRelationships.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php
declare(strict_types=1);

namespace Atlas\Testing\DataSource\Nopkey;

use Atlas\Mapper\MapperRelationships;

class NopkeyRelationships extends MapperRelationships
{
protected function define()
{
}
}
21 changes: 21 additions & 0 deletions src/DataSource/Nopkey/NopkeyRow.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php
/**
* This file was generated by Atlas. Changes will be overwritten.
*/
declare(strict_types=1);

namespace Atlas\Testing\DataSource\Nopkey;

use Atlas\Table\Row;

/**
* @property mixed $name VARCHAR(255)
* @property mixed $email VARCHAR(255)
*/
class NopkeyRow extends Row
{
protected $cols = [
'name' => null,
'email' => null,
];
}
15 changes: 15 additions & 0 deletions src/DataSource/Nopkey/NopkeySelect.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?php
declare(strict_types=1);

namespace Atlas\Testing\DataSource\Nopkey;

use Atlas\Mapper\MapperSelect;

/**
* @method NopkeyRecord|null fetchRecord()
* @method NopkeyRecord[] fetchRecords()
* @method NopkeyRecordSet fetchRecordSet()
*/
class NopkeySelect extends MapperSelect
{
}
65 changes: 65 additions & 0 deletions src/DataSource/Nopkey/NopkeyTable.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
<?php
/**
* This file was generated by Atlas. Changes will be overwritten.
*/
declare(strict_types=1);

namespace Atlas\Testing\DataSource\Nopkey;

use Atlas\Table\Table;

/**
* @method NopkeyRow|null fetchRow($primaryVal)
* @method NopkeyRow[] fetchRows(array $primaryVals)
* @method NopkeyTableSelect select(array $whereEquals = [])
* @method NopkeyRow newRow(array $cols = [])
* @method NopkeyRow newSelectedRow(array $cols)
*/
class NopkeyTable extends Table
{
const DRIVER = 'sqlite';

const NAME = 'nopkeys';

const COLUMNS = [
'name' => [
'name' => 'name',
'type' => 'VARCHAR',
'size' => 255,
'scale' => null,
'notnull' => false,
'default' => null,
'autoinc' => false,
'primary' => false,
'options' => null,
],
'email' => [
'name' => 'email',
'type' => 'VARCHAR',
'size' => 255,
'scale' => null,
'notnull' => false,
'default' => null,
'autoinc' => false,
'primary' => false,
'options' => null,
],
];

const COLUMN_NAMES = [
'name',
'email',
];

const COLUMN_DEFAULTS = [
'name' => null,
'email' => null,
];

const PRIMARY_KEY = [
];

const AUTOINC_COLUMN = null;

const AUTOINC_SEQUENCE = null;
}
17 changes: 17 additions & 0 deletions src/DataSource/Nopkey/NopkeyTableEvents.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?php
declare(strict_types=1);

namespace Atlas\Testing\DataSource\Nopkey;

use Atlas\Query\Delete;
use Atlas\Query\Insert;
use Atlas\Query\Select;
use Atlas\Query\Update;
use Atlas\Table\Row;
use Atlas\Table\Table;
use Atlas\Table\TableEvents;
use PDOStatement;

class NopkeyTableEvents extends TableEvents
{
}
14 changes: 14 additions & 0 deletions src/DataSource/Nopkey/NopkeyTableSelect.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?php
declare(strict_types=1);

namespace Atlas\Testing\DataSource\Nopkey;

use Atlas\Table\TableSelect;

/**
* @method NopkeyRow|null fetchRow()
* @method NopkeyRow[] fetchRows()
*/
class NopkeyTableSelect extends TableSelect
{
}
4 changes: 2 additions & 2 deletions src/DataSource/Summary/SummaryRow.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class SummaryRow extends Row
protected $cols = [
'summary_id' => null,
'thread_id' => null,
'reply_count' => '0',
'view_count' => '0',
'reply_count' => 0,
'view_count' => 0,
];
}
8 changes: 4 additions & 4 deletions src/DataSource/Summary/SummaryTable.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class SummaryTable extends Table
'size' => null,
'scale' => null,
'notnull' => true,
'default' => '0',
'default' => 0,
'autoinc' => false,
'primary' => false,
'options' => null,
Expand All @@ -61,7 +61,7 @@ class SummaryTable extends Table
'size' => null,
'scale' => null,
'notnull' => true,
'default' => '0',
'default' => 0,
'autoinc' => false,
'primary' => false,
'options' => null,
Expand All @@ -78,8 +78,8 @@ class SummaryTable extends Table
const COLUMN_DEFAULTS = [
'summary_id' => null,
'thread_id' => null,
'reply_count' => '0',
'view_count' => '0',
'reply_count' => 0,
'view_count' => 0,
];

const PRIMARY_KEY = [
Expand Down
1 change: 1 addition & 0 deletions src/DataSource/Thread/ThreadFields.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
* @property null|false|\Atlas\Testing\DataSource\Summary\SummaryRecord $summary
* @property null|\Atlas\Testing\DataSource\Reply\ReplyRecordSet $replies
* @property null|\Atlas\Testing\DataSource\Tagging\TaggingRecordSet $taggings
* @property null|false|\Atlas\Testing\DataSource\Tag\TagRecord $tags
*/
trait ThreadFields
{
Expand Down
10 changes: 10 additions & 0 deletions src/DataSourceFixture.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ public function exec()
$this->bidifoos();
$this->bidibars();

$this->nopkeys();

// return the connection used
return $this->connection;
}
Expand Down Expand Up @@ -295,4 +297,12 @@ public function bidibars()

$this->connection->perform("INSERT INTO bidibars (name) VALUES ('prebar')");
}

public function nopkeys()
{
$this->connection->query("CREATE TABLE nopkeys (
name VARCHAR(255),
email VARCHAR(255)
)");
}
}

0 comments on commit 543bd32

Please sign in to comment.