assertEquals('SELECT COUNT(*) FROM a_table', Count::all('a_table'), 'SELECT statement not generated correctly'); } public function testByFieldsSucceeds(): void { Configuration::$mode = Mode::SQLite; $this->assertEquals("SELECT COUNT(*) FROM somewhere WHERE data->>'errors' > :errors", Count::byFields('somewhere', [Field::GT('errors', 10, ':errors')]), 'SELECT statement not generated correctly'); } #[TestDox('By contains succeeds for PostgreSQL')] public function testByContainsSucceedsForPostgreSQL(): void { Configuration::$mode = Mode::PgSQL; $this->assertEquals('SELECT COUNT(*) FROM the_table WHERE data @> :criteria', Count::byContains('the_table'), 'SELECT statement not generated correctly'); } #[TestDox('By contains fails for non PostgreSQL')] public function testByContainsFailsForNonPostgreSQL(): void { $this->expectException(DocumentException::class); Count::byContains(''); } #[TestDox('By JSON Path succeeds for PostgreSQL')] public function testByJsonPathSucceedsForPostgreSQL(): void { Configuration::$mode = Mode::PgSQL; $this->assertEquals('SELECT COUNT(*) FROM a_table WHERE jsonb_path_exists(data, :path::jsonpath)', Count::byJsonPath('a_table'), 'SELECT statement not generated correctly'); } #[TestDox('By JSON Path fails for non PostgreSQL')] public function testByJsonPathFailsForNonPostgreSQL(): void { $this->expectException(DocumentException::class); Count::byJsonPath(''); } }