public hasVersion ( ) : boolean | ||
Résultat | boolean | true if one of the versions can handle the request, false otherwise |
public function testManualVersionSet() { /** @var Version $version */ $version = Mockery::mock('OpenSkill\\Datatable\\Versions\\Datatable19Version'); $versionEngine = new VersionEngine([]); $versionEngine->setVersion($version); $this->assertTrue($versionEngine->hasVersion()); $this->assertSame($version, $versionEngine->getVersion()); }
/** * Tests for issue #26 (https://github.com/OpenSkill/Datatable/issues/26) * Datatable 1.10 would always be selected, even if the query was for * Datatable 1.9 */ public function testGivesDatatable19Version() { $query = new Request(['sEcho' => '6', 'iColumns' => '2', 'sColumns' => '', 'iDisplayStart' => '0', 'iDisplayLength' => '10', 'mDataProp_0' => 'id', 'mDataProp_1' => 'name', 'sSearch' => '', 'bRegex' => 'false', 'sSearch_0' => '', 'bRegex_0' => 'false', 'bSearchable_0' => 'true', 'sSearch_1' => '', 'bRegex_1' => 'false', 'bSearchable_1' => 'true', 'iSortCol_0' => '0', 'sSortDir_0' => 'asc', 'iSortingCols' => '1', 'bSortable_0' => 'true', 'bSortable_1' => 'true', '_' => '1456903066843']); $requestStack = Mockery::mock('Symfony\\Component\\HttpFoundation\\RequestStack'); $requestStack->shouldReceive('getCurrentRequest')->andReturn($query); $dt = new Datatable19Version($requestStack); $dt2 = new Datatable110Version($requestStack); $versionEngine = new VersionEngine([$dt2, $dt]); $this->assertTrue($versionEngine->hasVersion()); $this->assertTrue($versionEngine->getVersion()->canParseRequest()); $this->assertSame($dt, $versionEngine->getVersion()); }
/** * @return bool True if any version should handle the current request */ public function shouldHandle() { return $this->versionEngine->hasVersion(); }
/** * @return bool True if any version should handle the current request */ public function shouldHandle() { return $this->versionEngine->hasVersion() && $this->versionEngine->getVersion()->canParseRequest(); }