diff --git a/.gitignore b/.gitignore index ff72e2d..f272444 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ /composer.lock /vendor +.phpunit.cache diff --git a/composer.json b/composer.json index 86cf896..fb92452 100644 --- a/composer.json +++ b/composer.json @@ -12,7 +12,7 @@ } ], "require": { - "php": ">=7.1.0", + "php": ">=8.1.0", "atlas/pdo": "~1.0", "atlas/query": "~1.0" }, @@ -24,7 +24,7 @@ "require-dev": { "atlas/testing": "~1.0", "pds/skeleton": "~1.0", - "phpunit/phpunit": "~7.0" + "phpunit/phpunit": "~10.0 || ~11.0 || ~12.0" }, "autoload-dev": { "psr-4": { diff --git a/phpunit.xml.dist b/phpunit.xml.dist index bb5c098..e8622b7 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -1,12 +1,13 @@ - - - - tests/ - - - - - ./src - - + + + + + tests/ + + + + + ./src + + diff --git a/src/TableLocator.php b/src/TableLocator.php index 768fd38..07dc541 100644 --- a/src/TableLocator.php +++ b/src/TableLocator.php @@ -20,7 +20,7 @@ class TableLocator protected $factory; - protected $tables = []; + protected $instances = []; public static function new(...$args) : TableLocator { @@ -33,7 +33,7 @@ public static function new(...$args) : TableLocator public function __construct( ConnectionLocator $connectionLocator, TableQueryFactory $tableQueryFactory, - callable $factory = null + ?callable $factory = null ) { $this->connectionLocator = $connectionLocator; $this->tableQueryFactory = $tableQueryFactory; diff --git a/tests/TableLocatorTest.php b/tests/TableLocatorTest.php index 20a684b..57fc831 100644 --- a/tests/TableLocatorTest.php +++ b/tests/TableLocatorTest.php @@ -9,7 +9,9 @@ class TableLocatorTest extends \PHPUnit\Framework\TestCase { - protected function setUp() + protected $tableLocator; + + protected function setUp() : void { $connection = (new DataSourceFixture())->exec(); $this->tableLocator = TableLocator::new($connection); diff --git a/tests/TableSelectTest.php b/tests/TableSelectTest.php index 1ddb6b2..ce66846 100644 --- a/tests/TableSelectTest.php +++ b/tests/TableSelectTest.php @@ -12,7 +12,7 @@ class TableSelectTest extends \PHPUnit\Framework\TestCase protected $table; - protected function setUp() + protected function setUp() : void { $connection = (new DataSourceFixture())->exec(); $this->table = TableLocator::new($connection)->get(EmployeeTable::CLASS); @@ -31,7 +31,7 @@ public function testFetchRow() // success $actual = $this->select->where('id = ', '1')->fetchRow(); $this->assertInstanceOf(EmployeeRow::CLASS, $actual); - $this->assertSame($expect, $actual->getArrayCopy()); + $this->assertSame($expect, array_map('strval', $actual->getArrayCopy())); // failure $actual = $this->select->where('id = ', '-1')->fetchRow(); @@ -64,9 +64,9 @@ public function testFetchRows() // success $actual = $this->select->where('id IN ', [1, 2, 3])->fetchRows(); $this->assertCount(3, $actual); - $this->assertSame($expect[0], $actual[0]->getArrayCopy()); - $this->assertSame($expect[1], $actual[1]->getArrayCopy()); - $this->assertSame($expect[2], $actual[2]->getArrayCopy()); + $this->assertSame($expect[0], array_map('strval', $actual[0]->getArrayCopy())); + $this->assertSame($expect[1], array_map('strval', $actual[1]->getArrayCopy())); + $this->assertSame($expect[2], array_map('strval', $actual[2]->getArrayCopy())); // failure $actual = $this->select->where('id IN ', [997, 998, 999])->fetchRows(); diff --git a/tests/TableTest.php b/tests/TableTest.php index f57d6e2..ad13f3c 100644 --- a/tests/TableTest.php +++ b/tests/TableTest.php @@ -22,7 +22,7 @@ class TableTest extends \PHPUnit\Framework\TestCase protected $tableLocator; - protected function setUp() + protected function setUp() : void { $connection = (new DataSourceFixture())->exec(); (new CompositeDataSourceFixture($connection))->exec(); @@ -65,7 +65,7 @@ public function testFetchRow() $this->logQueries(); $row = $this->table->fetchRow(1); $this->assertInstanceOf(EmployeeRow::CLASS, $row); - $this->assertSame($expect, $row->getArrayCopy()); + $this->assertSame($expect, array_map('strval', $row->getArrayCopy())); // check quoting $queries = $this->getQueries(); @@ -101,7 +101,7 @@ public function testFetchRow_compositeKey() 'course_number' => '100' ]); - $this->assertSame($expect, $actual->getArrayCopy()); + $this->assertSame($expect, array_map('strval', $actual->getArrayCopy())); // check quoting $queries = $this->getQueries(); @@ -174,9 +174,9 @@ public function testFetchRows() $this->assertInstanceOf(EmployeeRow::CLASS, $actual[0]); $this->assertInstanceOf(EmployeeRow::CLASS, $actual[1]); $this->assertInstanceOf(EmployeeRow::CLASS, $actual[2]); - $this->assertSame($expect[0], $actual[0]->getArrayCopy()); - $this->assertSame($expect[1], $actual[1]->getArrayCopy()); - $this->assertSame($expect[2], $actual[2]->getArrayCopy()); + $this->assertSame($expect[0], array_map('strval', $actual[0]->getArrayCopy())); + $this->assertSame($expect[1], array_map('strval', $actual[1]->getArrayCopy())); + $this->assertSame($expect[2], array_map('strval', $actual[2]->getArrayCopy())); // check quoting $queries = $this->getQueries(); @@ -224,9 +224,9 @@ public function testFetchRows_compositeKey() $this->assertInstanceOf(CourseRow::CLASS, $actual[0]); $this->assertInstanceOf(CourseRow::CLASS, $actual[1]); $this->assertInstanceOf(CourseRow::CLASS, $actual[2]); - $this->assertSame($expect[0], $actual[0]->getArrayCopy()); - $this->assertSame($expect[1], $actual[1]->getArrayCopy()); - $this->assertSame($expect[2], $actual[2]->getArrayCopy()); + $this->assertSame($expect[0], array_map('strval', $actual[0]->getArrayCopy())); + $this->assertSame($expect[1], array_map('strval', $actual[1]->getArrayCopy())); + $this->assertSame($expect[2], array_map('strval', $actual[2]->getArrayCopy())); // check quoting $queries = $this->getQueries(); @@ -287,6 +287,7 @@ public function testInsertRow() $actual = $this->table->getReadConnection()->fetchOne( 'SELECT * FROM employee WHERE id = 13' ); + $actual = array_map('strval', $actual); $this->assertSame($expect, $actual); // try to insert again, should fail on unique name