Skip to content

Commit

Permalink
Merge 837a013 into 4fd84c1
Browse files Browse the repository at this point in the history
  • Loading branch information
pierredup committed Oct 12, 2015
2 parents 4fd84c1 + 837a013 commit f4d3ccc
Show file tree
Hide file tree
Showing 421 changed files with 6,883 additions and 2,032 deletions.
4 changes: 4 additions & 0 deletions .coveralls.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
service_name: travis-ci
src_dir: src
coverage_clover: build/logs/clover.xml
json_path: build/logs/coveralls-upload.json
2 changes: 1 addition & 1 deletion .php_cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ $finder = Symfony\CS\Finder\DefaultFinder::create()
->in('src');

return Symfony\CS\Config\Config::create()
->fixers(array('ordered_use', 'multiline_spaces_before_semicolon', 'concat_with_spaces'))
->fixers(array('ordered_use', 'multiline_spaces_before_semicolon', 'concat_without_spaces'))
->finder($finder)
;
36 changes: 24 additions & 12 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,42 +4,54 @@ php:
- 5.4
- 5.5
- 5.6
- nightly
- 7
- hhvm
- hhvm-nightly

matrix:
fast_finish: true
allow_failures:
- php: hhvm-nightly
- php: nightly
- php: 7

sudo: false
env:
global:
- SAUCE_USERNAME=csbill
- SAUCE_ACCESS_KEY=dc33d33b-1a56-4333-9195-659844348121
- SYMFONY_ENV=test

# cache vendor dirs
cache:
directories:
- $HOME/.composer/cache
- $HOME/.composer/cache/files

before_install:
- composer self-update

install:
- composer install --prefer-source --no-interaction
- composer install --prefer-source -n
- php app/console assets:install -n
- php app/console assetic:dump -n

before_script:
- mysql -e 'create database csbill;'
- if [[ "$TRAVIS_PHP_VERSION" != "hhvm"* ]]; then echo "memory_limit=4096M" >> ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/travis.ini; fi;
- php app/check.php
- sudo apt-get update
- sudo apt-get install apache2 libapache2-mod-fastcgi
- bash travis/travis-ci-apache.sh
- export DISPLAY=:99.0
- sh -e /etc/init.d/xvfb start
- sleep 3 # give xvfb some time to start
- bash travis/sauce.sh

script:
- php app/console security:check
- ./bin/behat --suite=installation -n -f progress
- ./bin/phpunit -c app
- bash travis/behat.sh
- bash travis/phpunit.sh

after_script:
- wget https://scrutinizer-ci.com/ocular.phar
- php ocular.phar code-coverage:upload --format=php-clover build/logs/clover.xml
- if [[ "$TRAVIS_PHP_VERSION" == "5.6"* ]]; then wget https://scrutinizer-ci.com/ocular.phar; fi;
- if [[ "$TRAVIS_PHP_VERSION" == "5.6"* ]]; then php ocular.phar code-coverage:upload --format=php-clover build/logs/clover.xml; fi;
- php ./bin/coveralls -v
- cat build/logs/coveralls-upload.json

notifications:
hipchat:
Expand Down
7 changes: 7 additions & 0 deletions app/AppKernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ public function registerBundles()
new Payum\Bundle\PayumBundle\PayumBundle(),
new Sylius\Bundle\FlowBundle\SyliusFlowBundle(),
new Finite\Bundle\FiniteBundle\FiniteFiniteBundle(),
new JMS\SerializerBundle\JMSSerializerBundle(),
new FOS\RestBundle\FOSRestBundle(),
new Bazinga\Bundle\HateoasBundle\BazingaHateoasBundle(),
new Nelmio\ApiDocBundle\NelmioApiDocBundle(),

new CSBill\CoreBundle\CSBillCoreBundle(),
new CSBill\InstallBundle\CSBillInstallBundle(),
Expand All @@ -52,6 +56,9 @@ public function registerBundles()
new CSBill\DashboardBundle\CSBillDashboardBundle(),
new CSBill\TaxBundle\CSBillTaxBundle(),
new CSBill\NotificationBundle\CSBillNotificationBundle(),
new CSBill\ApiBundle\CSBillApiBundle(),
new CSBill\CronBundle\CSBillCronBundle(),
new CSBill\MoneyBundle\CSBillMoneyBundle(),
);

if (in_array($this->getEnvironment(), array('dev', 'test'))) {
Expand Down
8 changes: 7 additions & 1 deletion app/DoctrineMigrations/Version040.php
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,13 @@ public function up(Schema $schema)
$this->addSql('DROP INDEX IDX_4FABF983C182F730 ON payment_methods');
$this->addSql('ALTER TABLE payment_methods DROP defaultStatus_id, CHANGE public internal TINYINT(1) DEFAULT NULL');

$this->addSql('INSERT INTO payment_methods (id, name, settings, created, updated, deleted, internal, enabled, payment_method) VALUES (NULL, "Cash", "a:0:{}", NOW(), NOW(), NULL, 0, 1, "cash"), (NULL, "Bank Transfer", "a:0:{}", NOW(), NOW(), NULL, 0, 1, "bank_transfer")');
$this->addSql('
INSERT INTO payment_methods
(id, name, settings, created, updated, deleted, internal, enabled, payment_method)
VALUES
(NULL, "Cash", "a:0:{}", NOW(), NOW(), NULL, 1, 1, "cash"),
(NULL, "Bank Transfer", "a:0:{}", NOW(), NOW(), NULL, 1, 1, "bank_transfer")
');

$this->addSql('ALTER TABLE payments DROP FOREIGN KEY FK_65D29B326BF700BD');
$this->addSql('DROP INDEX IDX_65D29B326BF700BD ON payments');
Expand Down
75 changes: 75 additions & 0 deletions app/DoctrineMigrations/Version050.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
<?php

namespace Application\Migrations;

use Doctrine\DBAL\Migrations\AbstractMigration;
use Doctrine\DBAL\Schema\Schema;

/**
* Auto-generated Migration: Please modify to your needs!
*/
class Version050 extends AbstractMigration
{
/**
* @param Schema $schema
*/
public function up(Schema $schema)
{
// this up() migration is auto-generated, please modify it to your needs
$this->abortIf($this->connection->getDatabasePlatform()->getName() != 'mysql', 'Migration can only be executed safely on \'mysql\'.');

$this->addSql('UPDATE client_credit SET `value` = `value` * 100');
$this->addSql('ALTER TABLE client_credit CHANGE `value` `value` INT NOT NULL');

$this->addSql('UPDATE quote_lines SET price = price * 100, total = total * 100');
$this->addSql('ALTER TABLE quote_lines CHANGE price price INT NOT NULL, CHANGE total total INT NOT NULL');

$this->addSql('UPDATE quotes SET total = total * 100, base_total = base_total * 100, tax = tax * 100');
$this->addSql('ALTER TABLE quotes CHANGE total total INT NOT NULL, CHANGE base_total base_total INT NOT NULL, CHANGE tax tax INT DEFAULT NULL');

$this->addSql('UPDATE invoices SET total = total * 100, base_total = base_total * 100, tax = tax * 100, balance = balance * 100');
$this->addSql('ALTER TABLE invoices CHANGE total total INT NOT NULL, CHANGE base_total base_total INT NOT NULL, CHANGE tax tax INT DEFAULT NULL, CHANGE balance balance INT NOT NULL');

$this->addSql('UPDATE invoice_lines SET total = total * 100');
$this->addSql('ALTER TABLE invoice_lines CHANGE price price INT NOT NULL, CHANGE total total INT NOT NULL');

$this->addSql('UPDATE payments SET amount = amount * 100');
$this->addSql('ALTER TABLE payments CHANGE amount amount INT NOT NULL');

$this->addSql('CREATE TABLE api_tokens (id INT AUTO_INCREMENT NOT NULL, user_id INT DEFAULT NULL, name VARCHAR(125) NOT NULL, token VARCHAR(125) NOT NULL, created DATETIME NOT NULL, updated DATETIME NOT NULL, INDEX IDX_2CAD560EA76ED395 (user_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_bin ENGINE = InnoDB');
$this->addSql('ALTER TABLE api_tokens ADD CONSTRAINT FK_2CAD560EA76ED395 FOREIGN KEY (user_id) REFERENCES users (id)');

$this->addSql('CREATE TABLE api_token_history (id INT AUTO_INCREMENT NOT NULL, token_id INT DEFAULT NULL, ip VARCHAR(255) NOT NULL, resource VARCHAR(125) NOT NULL, method VARCHAR(25) NOT NULL, requestData LONGTEXT NOT NULL COMMENT \'(DC2Type:array)\', userAgent VARCHAR(255) NOT NULL, created DATETIME NOT NULL, updated DATETIME NOT NULL, INDEX IDX_61D8DC4441DEE7B9 (token_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB');
$this->addSql('ALTER TABLE api_token_history ADD CONSTRAINT FK_61D8DC4441DEE7B9 FOREIGN KEY (token_id) REFERENCES api_tokens (id)');
}

/**
* @param Schema $schema
*/
public function down(Schema $schema)
{
// this down() migration is auto-generated, please modify it to your needs
$this->abortIf($this->connection->getDatabasePlatform()->getName() != 'mysql', 'Migration can only be executed safely on \'mysql\'.');

$this->addSql('ALTER TABLE client_credit CHANGE value value DOUBLE PRECISION NOT NULL');
$this->addSql('UPDATE client_credit SET `value` = `value` / 100');

$this->addSql('ALTER TABLE invoice_lines CHANGE price price NUMERIC(10, 2) NOT NULL');
$this->addSql('UPDATE invoice_lines SET price = price / 100');

$this->addSql('ALTER TABLE invoices CHANGE total total DOUBLE PRECISION NOT NULL, CHANGE base_total base_total DOUBLE PRECISION NOT NULL, CHANGE balance balance DOUBLE PRECISION NOT NULL, CHANGE tax tax DOUBLE PRECISION DEFAULT NULL');
$this->addSql('UPDATE invoices SET total = total / 100, base_total = base_total / 100, tax = tax / 100, balance = balance / 100');

$this->addSql('ALTER TABLE payments CHANGE amount amount DOUBLE PRECISION NOT NULL');
$this->addSql('UPDATE payments SET amount = amount / 100');

$this->addSql('ALTER TABLE quote_lines CHANGE price price NUMERIC(10, 2) NOT NULL');
$this->addSql('UPDATE quote_lines SET price = price / 100');

$this->addSql('ALTER TABLE quotes CHANGE total total DOUBLE PRECISION NOT NULL, CHANGE base_total base_total DOUBLE PRECISION NOT NULL, CHANGE tax tax DOUBLE PRECISION DEFAULT NULL');
$this->addSql('UPDATE quotes SET total = total / 100, base_total = base_total / 100, tax = tax / 100');

$this->addSql('DROP TABLE api_tokens');
$this->addSql('DROP TABLE api_token_history');
}
}
6 changes: 3 additions & 3 deletions app/check.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ function get_error_message(Requirement $requirement, $lineSize)
return;
}

$errorMessage = wordwrap($requirement->getTestMessage(), $lineSize - 3, PHP_EOL.' ').PHP_EOL;
$errorMessage = wordwrap($requirement->getTestMessage(), $lineSize - 3, PHP_EOL.' ').PHP_EOL;
$errorMessage .= ' > '.wordwrap($requirement->getHelpText(), $lineSize - 5, PHP_EOL.' > ').PHP_EOL;

return $errorMessage;
Expand Down Expand Up @@ -121,8 +121,8 @@ function echo_block($style, $title, $message)
echo PHP_EOL.PHP_EOL;

echo_style($style, str_repeat(' ', $width).PHP_EOL);
echo_style($style, str_pad(' ['.$title.']', $width, ' ', STR_PAD_RIGHT).PHP_EOL);
echo_style($style, str_pad($message, $width, ' ', STR_PAD_RIGHT).PHP_EOL);
echo_style($style, str_pad(' ['.$title.']', $width, ' ', STR_PAD_RIGHT).PHP_EOL);
echo_style($style, str_pad($message, $width, ' ', STR_PAD_RIGHT).PHP_EOL);
echo_style($style, str_repeat(' ', $width).PHP_EOL);
}

Expand Down
20 changes: 20 additions & 0 deletions app/config/assetVersion.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php

/*
* This file is part of CSBill project.
*
* (c) 2013-2015 Pierre du Plessis <info@customscripts.co.za>
*
* This source file is subject to the MIT license that is bundled
* with this source code in the file LICENSE.
*/

$container->loadFromExtension(
'framework',
array(
'templating' => array(
'engines' => array('twig'),
'assets_version' => CSBill\CoreBundle\CSBillCoreBundle::VERSION,
),
)
);
45 changes: 42 additions & 3 deletions app/config/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ imports:
- { resource: parameters.yml }
- { resource: security.yml }
- { resource: payments.yml }
- { resource: assetVersion.php }
- { resource: @CSBillInvoiceBundle/Resources/config/finite.yml }
- { resource: @CSBillQuoteBundle/Resources/config/finite.yml }

Expand All @@ -15,8 +16,8 @@ framework:
form: ~
csrf_protection: ~
validation: { enable_annotations: true }
templating:
engines: ['twig']
#templating:
#engines: ['twig']
#assets_version: SomeVersionScheme
default_locale: %locale%
trusted_proxies: ~
Expand Down Expand Up @@ -62,6 +63,7 @@ doctrine:
charset: UTF8
types:
uuid: Rhumsaa\Uuid\Doctrine\UuidType
money: CSBill\MoneyBundle\Doctrine\Types\MoneyType
# if using pdo_sqlite as your database driver, add the path in parameters.yml
# e.g. database_path: %kernel.root_dir%/data/data.db3
# path: %database_path%
Expand All @@ -70,6 +72,8 @@ doctrine:
auto_generate_proxy_classes: %kernel.debug%
entity_managers:
default:
hydrators:
money: CSBill\MoneyBundle\Doctrine\Hydrator\MoneyHydrator
filters:
softdeleteable:
class: Gedmo\SoftDeleteable\Filter\SoftDeleteableFilter
Expand Down Expand Up @@ -141,4 +145,39 @@ fos_user:
type: profile_form
service:
email_canonicalizer: csbill.user.canonicalizer
username_canonicalizer: csbill.user.canonicalizer
username_canonicalizer: csbill.user.canonicalizer

fos_rest:
param_fetcher_listener: true
allowed_methods_listener: true
routing_loader:
default_format: json
serializer:
serialize_null: true
view:
formats:
jsonp: true
json: true
xml: true
rss: false
html: false
templating_formats:
html: false
force_redirects:
html: false
serialize_null: true
failed_validation: HTTP_BAD_REQUEST
exception_wrapper_handler: null
disable_csrf_role: ROLE_API_AUTHENTICATED
body_listener: true
format_listener: true
access_denied_listener:
json: true
xml: true
jsonp: true

nelmio_api_doc:
sandbox:
enabled: false
cache:
enabled: true
8 changes: 7 additions & 1 deletion app/config/routing.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
cs_bill_api:
resource: "@CSBillApiBundle/Resources/config/routing.yml"
prefix: /api

cs_bill_dashboard:
resource: "@CSBillDashboardBundle/Resources/config/routing.yml"
prefix: /

csbill_settings:
resource: "@CSBillSettingsBundle/Resources/config/routing.yml"
Expand Down Expand Up @@ -38,6 +41,9 @@ csbill_tax:
resource: "@CSBillTaxBundle/Resources/config/routing.yml"
prefix: /tax

csbill_user:
resource: "@CSBillUserBundle/Resources/config/routing.yml"
prefix: /profile

# External Routes

Expand Down
14 changes: 13 additions & 1 deletion app/config/security.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,25 @@ security:
providers:
fos_userbundle:
id: fos_user.user_provider.username_email
api_token_user_provider:
id: api_token_user_provider

firewalls:
dev:
pattern: ^/(_(profiler|wdt)|css|images|js)/
security: false

api_doc:
pattern: ^/api/docs
anonymous: ~

api:
pattern: ^/api
stateless: true
simple_preauth:
authenticator: api_token_authenticator
provider: api_token_user_provider

installer:
pattern: ^/install(.*)
anonymous: ~
Expand All @@ -34,7 +47,6 @@ security:
anonymous: true
context: frontend


# Payments
create:
pattern: ^/payments/create/([a-zA-Z0-9-]{36})
Expand Down
3 changes: 0 additions & 3 deletions app/phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,6 @@
</filter>

<logging>
<log type="coverage-html" target="../build/coverage" title="CSBill" charset="UTF-8" yui="true"
highlight="true" lowUpperBound="35" highLowerBound="75"/>
<log type="coverage-clover" target="../build/logs/clover.xml" />
<log type="junit" target="../build/logs/junit.xml" logIncompleteSkipped="false" />
</logging>
</phpunit>
Loading

0 comments on commit f4d3ccc

Please sign in to comment.