From cc87edbaa8b9620d05419c7f545e87847ff31910 Mon Sep 17 00:00:00 2001 From: Mike Chu Date: Tue, 8 Aug 2023 16:35:38 +0000 Subject: [PATCH 01/10] Add PHP pack ext --- .devcontainer/devcontainer.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 7316d069..577ad2ab 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -28,7 +28,8 @@ "extensions": [ "bmewburn.vscode-intelephense-client", "xdebug.php-debug", - "DEVSENSE.composer-php-vscode" + "DEVSENSE.composer-php-vscode", + "xdebug.php-pack" ] } } From b75bdabe74fa7e2f78400ee63b1844447b1317d7 Mon Sep 17 00:00:00 2001 From: Mike Chu Date: Tue, 8 Aug 2023 16:36:13 +0000 Subject: [PATCH 02/10] Add missing field definition --- .../ProjectConfigManager/HTTPProjectConfigManager.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/Optimizely/ProjectConfigManager/HTTPProjectConfigManager.php b/src/Optimizely/ProjectConfigManager/HTTPProjectConfigManager.php index 7b962aee..84a10893 100644 --- a/src/Optimizely/ProjectConfigManager/HTTPProjectConfigManager.php +++ b/src/Optimizely/ProjectConfigManager/HTTPProjectConfigManager.php @@ -77,6 +77,11 @@ class HTTPProjectConfigManager implements ProjectConfigManagerInterface */ private $datafileAccessToken; + /** + * @var boolean Flag indicates that the datafile access token is valid. + */ + private $isDatafileAccessTokenValid; + public function __construct( $sdkKey = null, $url = null, From fbc61426e6156e7cbcedf30f208957a07d089293 Mon Sep 17 00:00:00 2001 From: Mike Chu Date: Tue, 8 Aug 2023 16:41:14 +0000 Subject: [PATCH 03/10] Add missing field definition --- .../ProjectConfigManager/HTTPProjectConfigManager.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/Optimizely/ProjectConfigManager/HTTPProjectConfigManager.php b/src/Optimizely/ProjectConfigManager/HTTPProjectConfigManager.php index 7b962aee..84a10893 100644 --- a/src/Optimizely/ProjectConfigManager/HTTPProjectConfigManager.php +++ b/src/Optimizely/ProjectConfigManager/HTTPProjectConfigManager.php @@ -77,6 +77,11 @@ class HTTPProjectConfigManager implements ProjectConfigManagerInterface */ private $datafileAccessToken; + /** + * @var boolean Flag indicates that the datafile access token is valid. + */ + private $isDatafileAccessTokenValid; + public function __construct( $sdkKey = null, $url = null, From 9cb5c350b85beccc6a3a9e6d9a4991dffaef9c90 Mon Sep 17 00:00:00 2001 From: Mike Chu Date: Tue, 8 Aug 2023 16:41:58 +0000 Subject: [PATCH 04/10] Add phpunit test runner ext --- .devcontainer/devcontainer.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 577ad2ab..7142601a 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -29,7 +29,8 @@ "bmewburn.vscode-intelephense-client", "xdebug.php-debug", "DEVSENSE.composer-php-vscode", - "xdebug.php-pack" + "xdebug.php-pack", + "recca0120.vscode-phpunit" ] } } From 9185ac9c7b9d20f6a65e3b6f5ca0bdaa5b4bf6da Mon Sep 17 00:00:00 2001 From: Mike Chu Date: Tue, 8 Aug 2023 16:42:49 +0000 Subject: [PATCH 05/10] Change to use consistent _privateFieldNaming --- .../HTTPProjectConfigManager.php | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/Optimizely/ProjectConfigManager/HTTPProjectConfigManager.php b/src/Optimizely/ProjectConfigManager/HTTPProjectConfigManager.php index 84a10893..77c8d86b 100644 --- a/src/Optimizely/ProjectConfigManager/HTTPProjectConfigManager.php +++ b/src/Optimizely/ProjectConfigManager/HTTPProjectConfigManager.php @@ -75,12 +75,12 @@ class HTTPProjectConfigManager implements ProjectConfigManagerInterface /** * @var String datafile access token. */ - private $datafileAccessToken; + private $_datafileAccessToken; /** * @var boolean Flag indicates that the datafile access token is valid. */ - private $isDatafileAccessTokenValid; + private $_isDatafileAccessTokenValid; public function __construct( $sdkKey = null, @@ -92,14 +92,14 @@ public function __construct( LoggerInterface $logger = null, ErrorHandlerInterface $errorHandler = null, NotificationCenter $notificationCenter = null, - $datafileAccessToken = null + $_datafileAccessToken = null ) { $this->_skipJsonValidation = $skipJsonValidation; $this->_logger = $logger ?: new NoOpLogger(); $this->_errorHandler = $errorHandler ?: new NoOpErrorHandler(); $this->_notificationCenter = $notificationCenter ?: new NotificationCenter($this->_logger, $this->_errorHandler); - $this->datafileAccessToken = $datafileAccessToken; - $this->isDatafileAccessTokenValid = Validator::validateNonEmptyString($this->datafileAccessToken); + $this->_datafileAccessToken = $_datafileAccessToken; + $this->_isDatafileAccessTokenValid = Validator::validateNonEmptyString($this->_datafileAccessToken); $this->httpClient = new HttpClient(); $this->_url = $this->getUrl($sdkKey, $url, $urlTemplate); @@ -141,7 +141,7 @@ protected function getUrl($sdkKey, $url, $urlTemplate) } if (!Validator::validateNonEmptyString($urlTemplate)) { - if ($this->isDatafileAccessTokenValid) { + if ($this->_isDatafileAccessTokenValid) { $urlTemplate = ProjectConfigManagerConstants::AUTHENTICATED_DATAFILE_URL_TEMPLATE; } else { $urlTemplate = ProjectConfigManagerConstants::DEFAULT_DATAFILE_URL_TEMPLATE; @@ -184,8 +184,8 @@ protected function fetchDatafile() } // Add Authorization header if access token available. - if ($this->isDatafileAccessTokenValid) { - $headers['Authorization'] = "Bearer {$this->datafileAccessToken}"; + if ($this->_isDatafileAccessTokenValid) { + $headers['Authorization'] = "Bearer {$this->_datafileAccessToken}"; } $options = [ From bdcbe698386306517b59b754e3e60c211b47c58f Mon Sep 17 00:00:00 2001 From: Mike Chu Date: Tue, 8 Aug 2023 16:44:17 +0000 Subject: [PATCH 06/10] Add gitlens --- .devcontainer/devcontainer.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 7142601a..d9de1353 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -30,7 +30,8 @@ "xdebug.php-debug", "DEVSENSE.composer-php-vscode", "xdebug.php-pack", - "recca0120.vscode-phpunit" + "recca0120.vscode-phpunit", + "eamodio.gitlens" ] } } From 8e1504a0ea73b0d6ded0ea65753155ff2489c430 Mon Sep 17 00:00:00 2001 From: Mike Chu Date: Tue, 8 Aug 2023 16:47:30 +0000 Subject: [PATCH 07/10] Fix rename Didn't have a proper refactor ext/function --- .../ProjectConfigManager/HTTPProjectConfigManager.php | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/src/Optimizely/ProjectConfigManager/HTTPProjectConfigManager.php b/src/Optimizely/ProjectConfigManager/HTTPProjectConfigManager.php index c8deb937..839162bb 100644 --- a/src/Optimizely/ProjectConfigManager/HTTPProjectConfigManager.php +++ b/src/Optimizely/ProjectConfigManager/HTTPProjectConfigManager.php @@ -82,11 +82,6 @@ class HTTPProjectConfigManager implements ProjectConfigManagerInterface */ private $_isDatafileAccessTokenValid; - /** - * @var boolean Flag indicates that the datafile access token is valid. - */ - private $isDatafileAccessTokenValid; - public function __construct( $sdkKey = null, $url = null, @@ -97,13 +92,13 @@ public function __construct( LoggerInterface $logger = null, ErrorHandlerInterface $errorHandler = null, NotificationCenter $notificationCenter = null, - $_datafileAccessToken = null + $datafileAccessToken = null ) { $this->_skipJsonValidation = $skipJsonValidation; $this->_logger = $logger ?: new NoOpLogger(); $this->_errorHandler = $errorHandler ?: new NoOpErrorHandler(); $this->_notificationCenter = $notificationCenter ?: new NotificationCenter($this->_logger, $this->_errorHandler); - $this->_datafileAccessToken = $_datafileAccessToken; + $this->_datafileAccessToken = $datafileAccessToken; $this->_isDatafileAccessTokenValid = Validator::validateNonEmptyString($this->_datafileAccessToken); $this->httpClient = new HttpClient(); From 5ae8fba42d9bce34b10975bbd789ead1d4bcd835 Mon Sep 17 00:00:00 2001 From: Mike Chu Date: Tue, 8 Aug 2023 18:12:18 +0000 Subject: [PATCH 08/10] Update copyright header --- .../ProjectConfigManager/HTTPProjectConfigManager.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Optimizely/ProjectConfigManager/HTTPProjectConfigManager.php b/src/Optimizely/ProjectConfigManager/HTTPProjectConfigManager.php index 839162bb..83e5f839 100644 --- a/src/Optimizely/ProjectConfigManager/HTTPProjectConfigManager.php +++ b/src/Optimizely/ProjectConfigManager/HTTPProjectConfigManager.php @@ -1,12 +1,12 @@ Date: Wed, 9 Aug 2023 14:45:47 +0000 Subject: [PATCH 09/10] Refactor CI slightly --- .github/workflows/php.yml | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/.github/workflows/php.yml b/.github/workflows/php.yml index 574c3a53..a5b5ec06 100644 --- a/.github/workflows/php.yml +++ b/.github/workflows/php.yml @@ -11,7 +11,8 @@ jobs: name: Linting runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - name: Checkout code + uses: actions/checkout@v3 - name: Set up PHP uses: shivammathur/setup-php@v2 with: @@ -25,28 +26,24 @@ jobs: name: Source Clear Scan runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - name: Checkout code + uses: actions/checkout@v3 - name: Source clear scan env: SRCCLR_API_TOKEN: ${{ secrets.SRCCLR_API_TOKEN }} run: curl -sSL https://download.sourceclear.com/ci.sh | bash -s – scan - integration_tests: - name: Integration Tests - uses: optimizely/php-sdk/.github/workflows/integration_test.yml@master - secrets: - CI_USER_TOKEN: ${{ secrets.CI_USER_TOKEN }} - TRAVIS_COM_TOKEN: ${{ secrets.TRAVIS_COM_TOKEN }} - unit_tests: name: Unit Tests ${{ matrix.php-versions }} + needs: [ linting, source_clear ] runs-on: ubuntu-latest strategy: fail-fast: false matrix: php-versions: [ '8.1', '8.2' ] steps: - - uses: actions/checkout@v3 + - name: Checkout code + uses: actions/checkout@v3 - name: Set up PHP v${{ matrix.php-versions }} uses: shivammathur/setup-php@v2 with: @@ -77,3 +74,11 @@ jobs: run: | composer global require php-coveralls/php-coveralls php-coveralls --coverage_clover=./build/logs/clover.xml -v + + integration_tests: + name: Integration Tests + needs: [ unit_tests ] + uses: optimizely/php-sdk/.github/workflows/integration_test.yml@master + secrets: + CI_USER_TOKEN: ${{ secrets.CI_USER_TOKEN }} + TRAVIS_COM_TOKEN: ${{ secrets.TRAVIS_COM_TOKEN }} \ No newline at end of file From a333c6341b98e22ee018a019ffeda9a812478d04 Mon Sep 17 00:00:00 2001 From: Mike Chu Date: Wed, 9 Aug 2023 14:50:35 +0000 Subject: [PATCH 10/10] Add back EOL for file --- .github/workflows/php.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/php.yml b/.github/workflows/php.yml index a5b5ec06..109abb8a 100644 --- a/.github/workflows/php.yml +++ b/.github/workflows/php.yml @@ -81,4 +81,4 @@ jobs: uses: optimizely/php-sdk/.github/workflows/integration_test.yml@master secrets: CI_USER_TOKEN: ${{ secrets.CI_USER_TOKEN }} - TRAVIS_COM_TOKEN: ${{ secrets.TRAVIS_COM_TOKEN }} \ No newline at end of file + TRAVIS_COM_TOKEN: ${{ secrets.TRAVIS_COM_TOKEN }}