setType($type); $this->database->select("account", "*"); $this->assertQuery( <<database->queryString ); } /** * @covers ::select() * @covers ::selectContext() * @dataProvider typesProvider */ public function testSelectTableWithAlias($type) { $this->setType($type); $this->database->select("account (user)", "name"); $this->assertQuery( <<database->queryString ); } /** * @covers ::columnMap() * @covers ::columnPush() * @dataProvider typesProvider */ public function testSelectSingleColumn($type) { $this->setType($type); $this->database->select("account", "name"); $this->assertQuery( <<database->queryString ); } /** * @covers ::columnMap() * @covers ::columnPush() * @dataProvider typesProvider */ public function testSelectColumns($type) { $this->setType($type); $this->database->select("account", ["name", "id"]); $this->assertQuery( <<database->queryString ); } /** * @covers ::columnMap() * @covers ::columnPush() * @dataProvider typesProvider */ public function testSelectColumnsWithAlias($type) { $this->setType($type); $this->database->select("account", ["name(nickname)", "id"]); $this->assertQuery( <<database->queryString ); } /** * @covers ::columnMap() * @covers ::columnPush() * @dataProvider typesProvider */ public function testSelectColumnsWithType($type) { $this->setType($type); $this->database->select("account", ["name[String]", "data [JSON]"]); $this->assertQuery( <<database->queryString ); } /** * @covers ::columnMap() * @covers ::columnPush() * @dataProvider typesProvider */ public function testSelectColumnsWithAliasAndType($type) { $this->setType($type); $this->database->select("account", ["name (nickname) [String]", "data [JSON]"]); $this->assertQuery( <<database->queryString ); } /** * @covers ::columnMap() * @covers ::columnPush() * @dataProvider typesProvider */ public function testSelectColumnsWithRaw($type) { $this->setType($type); $this->database->select("account", [ "id [String]" => Medoo::raw("UUID()") ]); $this->assertQuery( <<database->queryString ); } /** * @covers ::select() * @covers ::selectContext() * @covers ::isJoin() * @dataProvider typesProvider */ public function testSelectWithWhere($type) { $this->setType($type); $this->database->select("account", [ "name", "id" ], [ "ORDER" => "age" ]); $this->assertQuery( <<database->queryString ); } /** * @covers ::select() * @covers ::selectContext() * @covers ::isJoin() * @covers ::buildJoin() * @dataProvider typesProvider */ public function testSelectWithLeftJoin($type) { $this->setType($type); $this->database->select("account", [ "[>]post" => "user_id" ], [ "account.name", "post.title" ]); $this->assertQuery( <<database->queryString ); } /** * @covers ::isJoin() * @covers ::buildJoin() * @dataProvider typesProvider */ public function testSelectWithRightJoin($type) { $this->setType($type); $this->database->select("account", [ "[<]post" => "user_id" ], [ "account.name", "post.title" ]); $this->assertQuery( <<database->queryString ); } /** * @covers ::isJoin() * @covers ::buildJoin() * @dataProvider typesProvider */ public function testSelectWithFullJoin($type) { $this->setType($type); $this->database->select("account", [ "[<>]post" => "user_id" ], [ "account.name", "post.title" ]); $this->assertQuery( <<database->queryString ); } /** * @covers ::isJoin() * @covers ::buildJoin() * @dataProvider typesProvider */ public function testSelectWithInnerJoin($type) { $this->setType($type); $this->database->select("account", [ "[><]post" => "user_id" ], [ "account.name", "post.title" ]); $this->assertQuery( <<database->queryString ); } /** * @covers ::isJoin() * @covers ::buildJoin() * @dataProvider typesProvider */ public function testSelectWithSameKeysJoin($type) { $this->setType($type); $this->database->select("account", [ "[>]photo" => ["user_id", "avatar_id"], ], [ "account.name", "photo.link" ]); $this->assertQuery( <<database->queryString ); } /** * @covers ::isJoin() * @covers ::buildJoin() * @dataProvider typesProvider */ public function testSelectWithKeyJoin($type) { $this->setType($type); $this->database->select("account", [ "[>]post" => ["user_id" => "author_id"], ], [ "account.name", "post.title" ]); $this->assertQuery( <<database->queryString ); } /** * @covers ::isJoin() * @covers ::buildJoin() * @dataProvider typesProvider */ public function testSelectWithAliasJoin($type) { $this->setType($type); $this->database->select("account", [ "[>]post (main_post)" => ["user_id" => "author_id"], ], [ "account.name", "main_post.title" ]); $this->assertQuery( <<database->queryString ); } /** * @covers ::isJoin() * @covers ::buildJoin() * @dataProvider typesProvider */ public function testSelectWithReferJoin($type) { $this->setType($type); $this->database->select("account", [ "[>]post" => ["user_id" => "author_id"], "[>]album" => ["post.author_id" => "user_id"], ], [ "account.name", "post.title", "album.link" ]); $this->assertQuery( <<database->queryString ); } /** * @covers ::isJoin() * @covers ::buildJoin() * @dataProvider typesProvider */ public function testSelectWithMultipleConditionJoin($type) { $this->setType($type); $this->database->select("account", [ "[>]album" => ["author_id" => "user_id"], "[>]post" => [ "user_id" => "author_id", "album.user_id" => "owner_id" ] ], [ "account.name", "post.title", "album.link" ]); $this->assertQuery( <<database->queryString ); } /** * @covers ::isJoin() * @covers ::buildJoin() * @dataProvider typesProvider */ public function testSelectWithAdditionalConditionJoin($type) { $this->setType($type); $this->database->select("account", [ "[>]post" => [ "user_id" => "author_id", "AND" => [ "post.id[>]" => 10 ] ] ], [ "account.name", "post.title" ]); $this->assertQuery( << 10 EOD, $this->database->queryString ); } /** * @covers ::isJoin() * @covers ::buildJoin() * @dataProvider typesProvider */ public function testSelectRawJoin($type) { $this->setType($type); $this->database->select("account", [ "[>]post" => Medoo::raw("ON = ") ], [ "account.name", "post.title" ]); $this->assertQuery( <<database->queryString ); } /** * @covers ::columnMap() * @covers ::columnPush() * @dataProvider typesProvider */ public function testSelectAllWithJoin($type) { $this->setType($type); $this->expectException(InvalidArgumentException::class); $this->database->select("account", [ "[>]post" => "user_id" ], [ "account.*" ]); } /** * @covers ::columnMap() * @covers ::columnPush() * @dataProvider typesProvider */ public function testSelectWithDataMapping($type) { $this->setType($type); $this->database->select("post", [ "[>]account" => ["user_id"] ], [ "post.content", "userData" => [ "account.user_id", "account.email", "meta" => [ "account.location", "account.gender" ] ] ]); $this->assertQuery( <<database->queryString ); } /** * @covers ::columnMap() * @covers ::columnPush() * @dataProvider typesProvider */ public function testSelectWithIndexMapping($type) { $this->setType($type); $this->database->select("account", [ "user_id" => [ "name (nickname)", "location" ] ]); $this->assertQuery( <<database->queryString ); } /** * @covers ::columnMap() * @covers ::columnPush() * @dataProvider typesProvider */ public function testSelectWithDistinct($type) { $this->setType($type); $this->database->select("account", [ "@location", "nickname" ]); $this->assertQuery( <<database->queryString ); } /** * @covers ::columnMap() * @covers ::columnPush() * @dataProvider typesProvider */ public function testSelectWithDistinctDiffOrder($type) { $this->setType($type); $this->database->select("account", [ "location", "@nickname" ]); $this->assertQuery( <<database->queryString ); } /** * @covers ::columnMap() * @covers ::columnPush() * @dataProvider typesProvider */ public function testSelectWithUnicodeCharacter($type) { $this->setType($type); $this->database->select("considérer", [ "name (名前)", "положение (ロケーション)" ]); $this->assertQuery( <<database->queryString ); } /** * @covers ::columnMap() * @covers ::columnPush() * @dataProvider typesProvider */ public function testSelectWithHyphenCharacter($type) { $this->setType($type); $this->database->select("account", [ "nick-name" ]); $this->assertQuery( <<database->queryString ); } /** * @covers ::columnMap() * @covers ::columnPush() * @dataProvider typesProvider */ public function testSelectWithSingleCharacter($type) { $this->setType($type); $this->database->select("a", [ "[>]e" => ["f"] ], [ "b (c)" ]); $this->assertQuery( <<database->queryString ); } }