This repository has been archived by the owner on Dec 6, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix bug in Queries\Query::updateScope and add tests
- Loading branch information
Elliot Levin
committed
Aug 30, 2014
1 parent
b07ab2a
commit cf6b7ad
Showing
2 changed files
with
60 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
<?php | ||
|
||
namespace Pinq\Tests\Integration\Queries; | ||
|
||
use Pinq\Expressions as O; | ||
use Pinq\Parsing; | ||
use Pinq\Providers; | ||
use Pinq\Queries as Q; | ||
use Pinq\Tests\PinqTestCase; | ||
|
||
class MiscQueryTest extends PinqTestCase | ||
{ | ||
protected function request() | ||
{ | ||
return new Q\RequestQuery(new Q\Scope(new Q\SourceInfo(''), []), new Q\Requests\Values(Q\Requests\Values::AS_ARRAY)); | ||
} | ||
|
||
protected function operation() | ||
{ | ||
return new Q\OperationQuery(new Q\Scope(new Q\SourceInfo(''), []), new Q\Operations\Clear()); | ||
} | ||
|
||
public function queries() | ||
{ | ||
return [ | ||
[$this->request()], | ||
[$this->operation()], | ||
]; | ||
} | ||
|
||
/** | ||
* @dataProvider queries | ||
*/ | ||
public function testUpdateScope(Q\IQuery $query) | ||
{ | ||
$newScope = new Q\Scope(new Q\SourceInfo(''), []); | ||
|
||
$this->assertSame($query->updateScope($query->getScope()), $query); | ||
$this->assertSame($query->updateScope($newScope)->getScope(), $newScope); | ||
} | ||
|
||
public function testUpdateRequest() | ||
{ | ||
$requestQuery = $this->request(); | ||
$newRequest = new Q\Requests\First(); | ||
|
||
$this->assertSame($requestQuery->updateRequest($requestQuery->getRequest()), $requestQuery); | ||
$this->assertSame($requestQuery->updateRequest($newRequest)->getRequest(), $newRequest); | ||
} | ||
|
||
public function testUpdateOperation() | ||
{ | ||
$operationQuery = $this->operation(); | ||
$newOperation = new Q\Operations\Clear(); | ||
|
||
$this->assertSame($operationQuery->updateOperation($operationQuery->getOperation()), $operationQuery); | ||
$this->assertSame($operationQuery->updateOperation($newOperation)->getOperation(), $newOperation); | ||
} | ||
} |