diff --git a/.travis.yml b/.travis.yml index b8b5acb..f31a2bc 100644 --- a/.travis.yml +++ b/.travis.yml @@ -31,7 +31,7 @@ before_script: script: - if [[ $PHPUNIT_TEST ]]; then vendor/bin/phpunit; fi - if [[ $PHPUNIT_COVERAGE_TEST ]]; then phpdbg -qrr vendor/bin/phpunit --coverage-clover=coverage.xml; fi - - if [[ $PHPCS_TEST ]]; then vendor/bin/phpcs src/ tests/ *.php; fi + - if [[ $PHPCS_TEST ]]; then vendor/bin/phpcs src/ tests/; fi after_success: - - if [[ $PHPUNIT_COVERAGE_TEST ]]; then bash <(curl -s https://codecov.io/bash) -f coverage.xml -F php; fi \ No newline at end of file + - if [[ $PHPUNIT_COVERAGE_TEST ]]; then bash <(curl -s https://codecov.io/bash) -f coverage.xml -F php; fi diff --git a/Jenkinsfile b/Jenkinsfile index e2847b5..0bfe582 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -18,7 +18,7 @@ pipeline { stage('Checkstyle Report') { steps { - sh 'vendor/bin/phpcs --report=checkstyle --report-file=build/logs/checkstyle.xml --standard=phpcs.xml.dist --extensions=php,inc --ignore=autoload.php --ignore=vendor/ src/ tests/ || exit 0' + sh 'vendor/bin/phpcs --report=checkstyle --report-file=build/logs/checkstyle.xml --standard=phpcs.xml.dist --extensions=php,inc --ignore=autoload.php --ignore=vendor/ src/ tests/' } } @@ -80,4 +80,4 @@ pipeline { recordIssues enabledForFailure: true, tool: cpd(pattern: '**/logs/pmd-cpd.xml') } } -} \ No newline at end of file +} diff --git a/src/pages/Locator.php b/src/pages/Locator.php index 4d89a95..f76071b 100644 --- a/src/pages/Locator.php +++ b/src/pages/Locator.php @@ -109,7 +109,7 @@ public static function get_locations( $exclude = [], $callback = null ) { - $locationClass = Config::inst()->get(Locator::class, 'location_class'); + $locationClass = Config::inst()->get(static::class, 'location_class'); $locations = $locationClass::get()->filter($filter)->exclude($exclude); if (!empty($filterAny)) { @@ -153,7 +153,7 @@ public static function locator_categories_by_locator($id = 0) return false; } - return Locator::get()->byID($id)->getUsedCategories(); + return static::get()->byID($id)->getUsedCategories(); } /** @@ -227,7 +227,7 @@ public function getInfoWindowTemplate() { return ModuleResourceLoader::singleton()->resolveURL( Config::inst()->get( - Locator::class, + static::class, 'infoWindowTemplate' ) ); @@ -242,7 +242,7 @@ public function getListTemplate() { return ModuleResourceLoader::singleton()->resolveURL( Config::inst()->get( - Locator::class, + static::class, 'listTemplate' ) ); diff --git a/src/pages/LocatorController.php b/src/pages/LocatorController.php index e03c6c6..5a7e7b7 100644 --- a/src/pages/LocatorController.php +++ b/src/pages/LocatorController.php @@ -215,7 +215,7 @@ public function setLocations(HTTPRequest $request = null) } $filter = $this->config()->get('base_filter'); - $categoryVar = Config::inst()->get(Locator::class, 'category_var'); + $categoryVar = $this->data()->config()->get('category_var'); if ($request->getVar($categoryVar)) { $filter['Categories.ID'] = $request->getVar($categoryVar); } else { @@ -234,7 +234,8 @@ public function setLocations(HTTPRequest $request = null) $exclude = $this->config()->get('base_exclude'); $this->extend('updateLocatorExclude', $exclude, $request); - $locations = Locator::get_locations($filter, $filterAny, $exclude); + $class = $this->data()->ClassName; + $locations = $class::get_locations($filter, $filterAny, $exclude); $locations = DataToArrayListHelper::to_array_list($locations); //allow for adjusting list post possible distance calculation @@ -245,7 +246,7 @@ public function setLocations(HTTPRequest $request = null) } if ($this->getShowRadius()) { - $radiusVar = Config::inst()->get(Locator::class, 'radius_var'); + $radiusVar = $this->data()->config()->get('radius_var'); if ($radius = (int)$request->getVar($radiusVar)) { $locations = $locations->filterByCallback(function ($location) use (&$radius) { diff --git a/tests/pages/LocatorControllerTest.php b/tests/pages/LocatorControllerTest.php index f9e62d4..f954f71 100644 --- a/tests/pages/LocatorControllerTest.php +++ b/tests/pages/LocatorControllerTest.php @@ -2,7 +2,6 @@ namespace Dynamic\Locator\Tests; -use \DOMDocument; use Dynamic\Locator\LocationCategory; use Dynamic\Locator\Locator; use Dynamic\Locator\LocatorController; @@ -50,7 +49,7 @@ public function testXml() $this->assertEquals(200, $page->getStatusCode()); $this->assertEquals('application/xml', $page->getHeader('content-type')); - $dom = new DOMDocument(); + $dom = new \DOMDocument(); // true if it loads, false if it doesn't $valid = $dom->loadXML($page->getBody()); $this->assertTrue($valid);