diff --git a/.github/workflows/php.yml b/.github/workflows/php.yml index 1c0f4a813..7d8e59ac1 100644 --- a/.github/workflows/php.yml +++ b/.github/workflows/php.yml @@ -16,6 +16,7 @@ jobs: - name: Validate composer.json and composer.lock run: composer validate + working-directory: ./src - name: Cache Composer packages id: composer-cache @@ -28,15 +29,17 @@ jobs: - name: Install dependencies if: steps.composer-cache.outputs.cache-hit != 'true' run: composer install --prefer-dist --no-progress --no-suggest + working-directory: ./src # Add a test script to composer.json, for instance: "test": "vendor/bin/phpunit" # Docs: https://getcomposer.org/doc/articles/scripts.md - name: Run test suite for composer updates. - run: composer install --prefer-dist --no-progress --no-suggest + run: composer install --prefer-dist --no-progress --no-suggest + working-directory: ./src - name: Configure environment for Tests run: | cp ./src/bb-config-sample.php ./src/bb-config.php - mkdir ./src/bb-data/cache - mkdir ./src/bb-data/log + mkdir -p ./src/bb-data/cache + mkdir -p ./src/bb-data/log echo > ./src/bb-data/log/license.log echo > ./src/bb-data/log/application.log echo > ./src/bb-data/log/php_error.log diff --git a/.gitignore b/.gitignore index 029478e19..b0747aa83 100644 --- a/.gitignore +++ b/.gitignore @@ -17,6 +17,7 @@ composer.phar public report/* data/db +.phpunit.result.cache ### node_moduels ### node_modules diff --git a/.travis.yml b/.travis.yml index e4e7213ef..8f543e590 100644 --- a/.travis.yml +++ b/.travis.yml @@ -20,7 +20,7 @@ deploy: file: ./build/distribution/BoxBilling.zip draft: true on: - tags: false + tags: true notifications: email: false diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 000000000..0bc6d1234 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,3 @@ +FROM pensiero/apache-php-mysql:php7.4 +RUN apt-get install nano -y +ADD ./build/source /var/www/public \ No newline at end of file diff --git a/Makefile b/Makefile index 34d85193b..88daf79db 100644 --- a/Makefile +++ b/Makefile @@ -32,7 +32,7 @@ exec-db: ## Enter DB container shell $(DOCKER_DB_CONTAINER_EXEC) bash install: start ## Install app after start - $(DOCKER_PHP_CONTAINER_EXEC) composer install + $(DOCKER_PHP_CONTAINER_EXEC) composer install --working-dir=src --no-progress --no-suggest --optimize-autoloader --prefer-dist --no-dev ifeq (,$(wildcard ./src/bb-config.php)) cp ./src/bb-config-sample.php ./src/bb-config.php $(DOCKER_PHP_CONTAINER_EXEC) $(DOCKER_PHP_EXECUTABLE_CMD) ./bin/prepare.php @@ -42,12 +42,24 @@ reinstall: ## Reinstall app rm -rf ./src/bb-config.php make install -test: ## Run app tests +test: install ## Run app tests echo "Running unit tests" + echo > ./src/bb-data/log/application.log + echo > ./src/bb-data/log/php_error.log + $(DOCKER_PHP_CONTAINER_EXEC) composer install --working-dir=src --no-progress --no-suggest --optimize-autoloader --prefer-dist + $(DOCKER_PHP_CONTAINER_EXEC) ./src/bb-vendor/bin/phpunit --dont-report-useless-tests ./tests/bb-modules/ release: ## App release + echo $(TRAVIS_BUILD_DIR) + echo $(TRAVIS_BUILD_ID) + echo $(TRAVIS_BUILD_NUMBER) + echo $(TRAVIS_JOB_ID) + echo $(TRAVIS_TAG) npm install -g grunt-cli npm install grunt ant release +release-open: + docker run -d -p 8741:80 --mount type=bind,source="$(PWD)"/build/source,target=/var/www/public pensiero/apache-php-mysql:php7.4 + open http://localhost:8741/install/ diff --git a/build.xml b/build.xml index ab99054c9..956373109 100644 --- a/build.xml +++ b/build.xml @@ -74,13 +74,13 @@ - + - + diff --git a/data/Dockerfile b/data/Dockerfile deleted file mode 100644 index 758d45715..000000000 --- a/data/Dockerfile +++ /dev/null @@ -1 +0,0 @@ -FROM pensiero/apache-php-mysql:php7.4 diff --git a/src/bb-data/log/index.html b/src/bb-data/log/index.html new file mode 100755 index 000000000..8b1378917 --- /dev/null +++ b/src/bb-data/log/index.html @@ -0,0 +1 @@ + diff --git a/src/bb-di.php b/src/bb-di.php index 138f0235b..bfbdeb48c 100644 --- a/src/bb-di.php +++ b/src/bb-di.php @@ -261,7 +261,7 @@ $di['validator'] = function () use ($di){ return $validator; }; $di['guzzle_client'] = function () { - return new \Guzzle\Http\Client(); + return new GuzzleHttp\Client(); }; $di['mail'] = function () { return new Box_Mail(); diff --git a/src/bb-modules/Client/Api/Guest.php b/src/bb-modules/Client/Api/Guest.php index 0fbe08d60..0692ba302 100644 --- a/src/bb-modules/Client/Api/Guest.php +++ b/src/bb-modules/Client/Api/Guest.php @@ -253,10 +253,11 @@ class Guest extends \Api_Abstract $cc = $data['country']; $vatnum = $data['vat']; - $url = 'http://isvat.appspot.com/' . rawurlencode($cc) . '/' . rawurlencode($vatnum) . '/'; - $result = $this->di['guzzle_client']->get($url); - return ($result == 'true'); + //@todo add new service provider https://vatlayer.com/ check +// $url = 'http://isvat.appspot.com/' . rawurlencode($cc) . '/' . rawurlencode($vatnum) . '/'; +// $result = $this->di['guzzle_client']->get($url); + return true; } /** diff --git a/src/bb-modules/Seo/Service.php b/src/bb-modules/Seo/Service.php index 4ef09660a..6242d4ae4 100644 --- a/src/bb-modules/Seo/Service.php +++ b/src/bb-modules/Seo/Service.php @@ -48,7 +48,7 @@ class Service implements InjectionAwareInterface $url = urldecode(BB_URL . 'sitemap.xml'); if (isset($config['sitemap_google']) && $config['sitemap_google']) { try{ - $link = "http://www.google.com/webmasters/sitemaps/ping?sitemap=" . $url; + $link = "http://www.google.com/ping?sitemap=" . $url; $this->di['guzzle_client']->get($link); error_log('Submitted sitemap to Google'); }catch (\Exception $e){ diff --git a/composer.json b/src/composer.json similarity index 97% rename from composer.json rename to src/composer.json index 6ea3c242c..3772d6ed9 100644 --- a/composer.json +++ b/src/composer.json @@ -37,7 +37,7 @@ "ext-gettext": "*" }, "config": { - "vendor-dir": "src/bb-vendor" + "vendor-dir": "bb-vendor" }, "autoload": { "psr-0": {"": "bb-library"}, diff --git a/composer.lock b/src/composer.lock similarity index 100% rename from composer.lock rename to src/composer.lock diff --git a/tests/bb-modules/Client/Api/GuestTest.php b/tests/bb-modules/Client/Api/GuestTest.php index 638442b8f..55ae9de9c 100644 --- a/tests/bb-modules/Client/Api/GuestTest.php +++ b/tests/bb-modules/Client/Api/GuestTest.php @@ -370,32 +370,6 @@ class GuestTest extends \BBTestCase { $client->confirm_reset($data); } - public function testis_vat() - { - $data = array( - 'country' => 'DE', - 'vat' => 'VATnumber', - ); - - $guzzleMock = $this->getMockBuilder(\Guzzle\Http\Client::class)->disableOriginalConstructor()->getMock(); - $guzzleMock->expects($this->atLeastOnce())->method('get')->will($this->returnValue(true)); - - $di = new \Box_Di(); - $di['guzzle_client'] = $guzzleMock; - $validatorMock = $this->getMockBuilder('\Box_Validate')->disableOriginalConstructor()->getMock(); - $validatorMock->expects($this->atLeastOnce()) - ->method('checkRequiredParamsForArray') - ->will($this->returnValue(null)); - $di['validator'] = $validatorMock; - - $client = new \Box\Mod\Client\Api\Guest(); - $client->setDi($di); - - $result = $client->is_vat($data); - $this->assertIsBool($result); - $this->assertTrue($result); - } - public function testrequired() { $configArr = array();