diff --git a/.gitignore b/.gitignore index e04166e..0b7a110 100644 --- a/.gitignore +++ b/.gitignore @@ -1,10 +1,7 @@ -/vendor/ /bin/ /composer.phar /composer.lock -/vagrant/.vagrant -!/features/fixtures/project/web/app_test.php -/features/fixtures/project/web/* -/features/fixtures/project/web/uploaded -/features/fixtures/project/web/bundles /features/fixtures/project/app/data.sqlite +/features/fixtures/project/web/bundles +/features/fixtures/project/web/uploaded +/vendor/ diff --git a/.travis.yml b/.travis.yml index 4b33558..75e5d68 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,13 +1,11 @@ language: php -sudo: true - cache: directories: - - $HOME/.composer/cache - - bin - vendor +sudo: required + addons: firefox: "47.0.1" @@ -22,19 +20,20 @@ before_install: - phpenv config-rm xdebug.ini - composer update $COMPOSER_FLAGS - composer validate - - wget --no-clobber -O bin/selenium.jar http://selenium-release.storage.googleapis.com/2.53/selenium-server-standalone-2.53.1.jar || true + - wget --no-clobber -O vendor/bin/selenium.jar http://selenium-release.storage.googleapis.com/2.53/selenium-server-standalone-2.53.1.jar || true before_script: - nohup php -S localhost:8080 -t features/fixtures/project/web > server.log 2>&1 & - - features/fixtures/project/app/console assets:install features/fixtures/project/web --relative --symlink + - features/fixtures/project/app/console ckeditor:install --clear=skip + - features/fixtures/project/app/console assets:install --symlink features/fixtures/project/web - sh -e /etc/init.d/xvfb start - export DISPLAY=:99.0 - - java -jar bin/selenium.jar > /dev/null 2>&1 & + - java -jar vendor/bin/selenium.jar > /dev/null 2>&1 & - sleep 5 script: - - bin/phpspec run -f progress -v - - bin/behat --no-snippets --verbose --profile=travis -v + - vendor/bin/phpspec run -f progress + - vendor/bin/behat --no-snippets --profile=travis after_failure: - cat /tmp/FSiAdminTranslatableBundle/logs/test.log diff --git a/behat.yml b/behat.yml index 92b6f75..24f248c 100644 --- a/behat.yml +++ b/behat.yml @@ -9,13 +9,14 @@ default: &default - FSi\Bundle\AdminTranslatableBundle\Behat\Context\PopoverContext extensions: Behat\MinkExtension: + base_url: 'http://admin-translatable-bundle-web' sessions: default: symfony2: ~ javascript: selenium2: browser: firefox - base_url: 'http://fsi-admin-translatable-bundle.dev/app_test.php/' + wd_host: http://admin-translatable-bundle-selenium:4444/wd/hub javascript_session: javascript Behat\Symfony2Extension: kernel: @@ -32,3 +33,7 @@ travis: extensions: Behat\MinkExtension: base_url: "http://localhost:8080/app_test.php" + sessions: + javascript: + selenium2: + wd_host: http://localhost:4444/wd/hub diff --git a/composer.json b/composer.json index 9fbaed6..80e6d02 100644 --- a/composer.json +++ b/composer.json @@ -11,6 +11,8 @@ } ], "require": { + "fsi/admin-bundle": "^3.0", + "fsi/doctrine-extensions-bundle": "^2.0", "php": ">=7.1", "symfony/form": "^2.8|^3.0|^4.0", "symfony/framework-bundle": "^2.8|^3.0|^4.0", @@ -20,14 +22,11 @@ "symfony/translation": "^2.6|^3.0|^4.0", "symfony/twig-bridge": "^3.0.3|^4.0", "symfony/validator": "^2.5|^3.0|^4.0", - "symfony/twig-bundle": "^2.8|^3.0|^4.0", - "fsi/admin-bundle": "^3.0@dev", - "fsi/doctrine-extensions-bundle": "^2.0@dev", - "fsi/doctrine-extensions": "^2.0@dev" + "symfony/twig-bundle": "^2.8|^3.0|^4.0" }, "require-dev": { "behat/behat": "^3.3", - "behat/mink": "^1.7@dev", + "behat/mink": "^1.7", "behat/mink-browserkit-driver": "^1.3", "behat/mink-extension": "^2.2", "behat/mink-selenium2-driver": "^1.3", @@ -35,12 +34,8 @@ "bossa/phpspec2-expect": "^2.0|^3.0", "doctrine/doctrine-bundle": "^1.6", "ext-pdo_sqlite": "*", - "fsi/datagrid": "^2.0@dev", - "fsi/datagrid-bundle": "^2.0@dev", - "fsi/datasource": "^2.0@dev", - "fsi/datasource-bundle": "^2.0@dev", - "fsi/resource-repository-bundle": "^2.0@dev", "friendsofsymfony/ckeditor-bundle": "^1.0", + "fsi/resource-repository-bundle": "^2.0", "phpspec/phpspec": "^3.4.2|^4.0", "phpspec/prophecy": "^1.7.2", "sensiolabs/behat-page-object-extension": "^3.0@dev", @@ -53,7 +48,7 @@ "twig/twig": "^1.34|^2.0" }, "config": { - "bin-dir": "bin" + "bin-dir": "vendor/bin" }, "autoload": { "psr-4": { diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..fdd3c78 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,22 @@ +--- +version: '3' + +services: + web: + build: + context: ./docker + dockerfile: web + container_name: admin-translatable-bundle-web + ports: + - 80:80 + - 443:443 + environment: + PHP_IDE_CONFIG: 'serverName=localhost' + HOST_UID: 1000 + HOST_GID: 1000 + volumes: + - .:/var/www/application + - ~/.composer:/var/www/.composer + selenium: + image: selenium/standalone-firefox:2.53.1 + container_name: admin-translatable-bundle-selenium diff --git a/docker/apache-config.conf b/docker/apache-config.conf new file mode 100644 index 0000000..a1c1baf --- /dev/null +++ b/docker/apache-config.conf @@ -0,0 +1,17 @@ + + DocumentRoot /var/www/application/features/fixtures/project/web + ServerName localhost + ErrorLog /dev/stdout + + + DocumentRoot /var/www/application/features/fixtures/project/web + ServerName localhost + ErrorLog /dev/stdout + SSLEngine on + SSLCertificateFile /etc/apache2/ssl/apache.crt + SSLCertificateKeyFile /etc/apache2/ssl/apache.key + + + Options FollowSymLinks + AllowOverride All + diff --git a/docker/web b/docker/web new file mode 100644 index 0000000..458b86c --- /dev/null +++ b/docker/web @@ -0,0 +1,5 @@ +FROM fsiopen/docker-php-apache:7.1 + +USER root + +ADD apache-config.conf /etc/apache2/sites-available/application.conf diff --git a/features/fixtures/project/app/config/config.yml b/features/fixtures/project/app/config/config.yml index b5f2028..e4c650a 100644 --- a/features/fixtures/project/app/config/config.yml +++ b/features/fixtures/project/app/config/config.yml @@ -1,5 +1,5 @@ parameters: - locale: en + locale: en services: test.admin.manager: diff --git a/features/fixtures/project/web/.htaccess b/features/fixtures/project/web/.htaccess new file mode 100644 index 0000000..93215dd --- /dev/null +++ b/features/fixtures/project/web/.htaccess @@ -0,0 +1,45 @@ +DirectoryIndex app_test.php + +SetEnvIf Server_Addr ^10\.0\.0\.200 development=on +SetEnvIf Server_Addr ^172\. development=on + + + php_value post_max_size 32M + php_value upload_max_filesize 32M + + + + RewriteEngine On + + # Determine the RewriteBase automatically and set it as environment variable. + # If you are using Apache aliases to do mass virtual hosting or installed the + # project in a subdirectory, the base path will be prepended to allow proper + # resolution of the app.php file and to redirect to the correct URI. It will + # work in environments without path prefix as well, providing a safe, one-size + # fits all solution. But as you do not need it in this case, you can comment + # the following 2 lines to eliminate the overhead. + RewriteCond %{REQUEST_URI}::$1 ^(/.+)/(.*)::\2$ + RewriteRule ^(.*) - [E=BASE:%1] + + # If the requested filename exists, simply serve it. + # We only want to let Apache serve files and not directories. + RewriteCond %{REQUEST_FILENAME} -f + RewriteRule .? - [L] + + RewriteRule .? %{ENV:BASE}/app_test.php [L] + + + + + # When mod_rewrite is not available, we instruct a temporary redirect of + # the start page to the front controller explicitly so that the website + # and the generated links can still be used. + RedirectMatch 302 ^/$ /app_test.php/ + # RedirectTemp cannot be used instead + + + + + Header set Cache-control "no-cache" env=development + Header unset expires env=development + diff --git a/features/fixtures/project/web/app_test.php b/features/fixtures/project/web/app_test.php index b01f677..16449d2 100644 --- a/features/fixtures/project/web/app_test.php +++ b/features/fixtures/project/web/app_test.php @@ -1,5 +1,7 @@ - ServerName {{ vhost_name }} - ServerAlias www.{{ vhost_name }} - - DocumentRoot {{ vhost_docroot }} - - Options -Indexes FollowSymLinks MultiViews - AllowOverride All - Order allow,deny - allow from all - - diff --git a/vagrant/provisioning/roles/apache/vars/main.yml b/vagrant/provisioning/roles/apache/vars/main.yml deleted file mode 100644 index c26c8e6..0000000 --- a/vagrant/provisioning/roles/apache/vars/main.yml +++ /dev/null @@ -1,2 +0,0 @@ -vhost_name: fsi-admin-translatable-bundle.dev -vhost_docroot: /var/www/admin-translatable-bundle/features/fixtures/project/web diff --git a/vagrant/provisioning/roles/composer/tasks/main.yml b/vagrant/provisioning/roles/composer/tasks/main.yml deleted file mode 100644 index 6a7e18c..0000000 --- a/vagrant/provisioning/roles/composer/tasks/main.yml +++ /dev/null @@ -1,3 +0,0 @@ ---- -- name: Install Composer - shell: curl -sS https://getcomposer.org/installer | php && mv composer.phar /usr/local/bin/composer creates=/usr/local/bin/composer \ No newline at end of file diff --git a/vagrant/provisioning/roles/java/tasks/main.yml b/vagrant/provisioning/roles/java/tasks/main.yml deleted file mode 100644 index dbe41a3..0000000 --- a/vagrant/provisioning/roles/java/tasks/main.yml +++ /dev/null @@ -1,14 +0,0 @@ ---- - -- name: install pycurl package - apt: pkg=python-pycurl state=present - sudo: yes - -- name: Add JRE ppa - apt_repository: repo=ppa:webupd8team/java state=present - -- name: Automatically select the Oracle License - shell: echo debconf shared/accepted-oracle-license-v1-1 select true | sudo debconf-set-selections - -- name: Install JRE - apt: pkg=oracle-java7-installer state=latest update-cache=yes force=yes diff --git a/vagrant/provisioning/roles/mysql/handlers/main.yml b/vagrant/provisioning/roles/mysql/handlers/main.yml deleted file mode 100644 index 86618a8..0000000 --- a/vagrant/provisioning/roles/mysql/handlers/main.yml +++ /dev/null @@ -1,4 +0,0 @@ ---- - -- name: restart mysql - service: name=mysql state=restarted \ No newline at end of file diff --git a/vagrant/provisioning/roles/mysql/tasks/main.yml b/vagrant/provisioning/roles/mysql/tasks/main.yml deleted file mode 100644 index 3c462ce..0000000 --- a/vagrant/provisioning/roles/mysql/tasks/main.yml +++ /dev/null @@ -1,29 +0,0 @@ ---- - -- name: Install Mysql package - apt: name={{ item }} state=installed - with_items: - - mysql-server - - python-mysqldb - - python-selinux - -- name: Create Mysql configuration file - template: src=my.cnf.j2 dest=/etc/my.cnf - notify: - - restart mysql - -- name: Start Mysql Service - service: name=mysql state=started enabled=true - -- name: Copy .my.cnf file with root password credentials - template: src=.my.cnf.j2 dest=~/.my.cnf mode=0600 - -- name: Update mysql root password for all root accounts - mysql_user: name=root host={{ item }} password={{ mysql_root_db_pass }} - with_items: - - 127.0.0.1 - - ::1 - - localhost - -- name: Remove the test database - mysql_db: name=test state=absent \ No newline at end of file diff --git a/vagrant/provisioning/roles/mysql/templates/.my.cnf.j2 b/vagrant/provisioning/roles/mysql/templates/.my.cnf.j2 deleted file mode 100644 index e99d79f..0000000 --- a/vagrant/provisioning/roles/mysql/templates/.my.cnf.j2 +++ /dev/null @@ -1,3 +0,0 @@ -[client] -user=root -password={{ mysql_root_db_pass }} \ No newline at end of file diff --git a/vagrant/provisioning/roles/mysql/templates/my.cnf.j2 b/vagrant/provisioning/roles/mysql/templates/my.cnf.j2 deleted file mode 100644 index c42f0cf..0000000 --- a/vagrant/provisioning/roles/mysql/templates/my.cnf.j2 +++ /dev/null @@ -1,26 +0,0 @@ -[mysqld] -datadir=/var/lib/mysql -socket=/var/lib/mysql/mysql.sock -user=mysql -# Disabling symbolic-links is recommended to prevent assorted security risks -symbolic-links=0 -port={{ mysql_port }} - -key_buffer = 16K -max_allowed_packet = 1M -table_cache = 4 -sort_buffer_size = 64K -read_buffer_size = 256K -read_rnd_buffer_size = 256K -net_buffer_length = 2K -thread_stack = 64K -innodb_buffer_pool_size = 16M -innodb_additional_mem_pool_size = 2M -innodb_log_file_size = 5M -innodb_log_buffer_size = 8M -innodb_flush_log_at_trx_commit = 1 -innodb_lock_wait_timeout = 50 - -[mysqld_safe] -log-error=/var/log/mysqld.log -pid-file=/var/run/mysqld/mysqld.pid \ No newline at end of file diff --git a/vagrant/provisioning/roles/php5/tasks/main.yml b/vagrant/provisioning/roles/php5/tasks/main.yml deleted file mode 100644 index 71e5768..0000000 --- a/vagrant/provisioning/roles/php5/tasks/main.yml +++ /dev/null @@ -1,26 +0,0 @@ -- name: Install python-pycurl - apt: pkg=python-pycurl state=latest - -- name: Add php repository key - apt_key: url=http://keyserver.ubuntu.com:11371/pks/lookup?op=get&search=0x4F4EA0AAE5267A6C state=present - -- name: Add php repository - apt_repository: repo='deb http://ppa.launchpad.net/ondrej/php5-oldstable/ubuntu precise main' state=present - -- name: Install PHP - apt: name=php5 state=latest - -- name: Intsall PHP packages - apt: name={{ item }} state=latest - with_items: - - php-apc - - php5-cli - - php5-gd - - php5-mysql - - php5-curl - - php5-intl - - php5-mcrypt - - php5-sqlite - -- name: Configure PHP - template: src=php_config.ini.j2 dest=/etc/php5/conf.d/php_config.ini diff --git a/vagrant/provisioning/roles/php5/templates/php_config.ini.j2 b/vagrant/provisioning/roles/php5/templates/php_config.ini.j2 deleted file mode 100644 index 1f124ce..0000000 --- a/vagrant/provisioning/roles/php5/templates/php_config.ini.j2 +++ /dev/null @@ -1,6 +0,0 @@ -; Extra php configuration - -date.timezone = "Europe/Warsaw" -display_errors = On -error_reporting = -1 -short_open_tag = 0 diff --git a/vagrant/provisioning/roles/selenium/defaults/main.yml b/vagrant/provisioning/roles/selenium/defaults/main.yml deleted file mode 100644 index 8249475..0000000 --- a/vagrant/provisioning/roles/selenium/defaults/main.yml +++ /dev/null @@ -1,3 +0,0 @@ -selenium_file: selenium-server-standalone-{{selenium_version}}.0.jar -display_number: "{{display_number}}" - diff --git a/vagrant/provisioning/roles/selenium/files/.gitignore b/vagrant/provisioning/roles/selenium/files/.gitignore deleted file mode 100644 index d392f0e..0000000 --- a/vagrant/provisioning/roles/selenium/files/.gitignore +++ /dev/null @@ -1 +0,0 @@ -*.jar diff --git a/vagrant/provisioning/roles/selenium/tasks/main.yml b/vagrant/provisioning/roles/selenium/tasks/main.yml deleted file mode 100644 index b46ee82..0000000 --- a/vagrant/provisioning/roles/selenium/tasks/main.yml +++ /dev/null @@ -1,21 +0,0 @@ -- name: Download selenium - connection: local - sudo: False - get_url: url=http://selenium-release.storage.googleapis.com/{{selenium_version}}/{{selenium_file}} dest={{cur_dir}}/{{selenium_file}} force=no - -- name: Copy selenium - copy: src={{selenium_file}} dest=/usr/local/bin/{{selenium_file}} owner=root group=root mode=644 - -- name: Install init script - template: src=selenium.j2 dest=/etc/init.d/selenium owner=root group=root mode=755 - -- name: Link installation - shell: update-rc.d selenium defaults - -- name: Install browser - apt: name={{item}} - with_items: - - firefox - -- name: start selenium - service: name=selenium state=started enabled=yes diff --git a/vagrant/provisioning/roles/selenium/templates/selenium.j2 b/vagrant/provisioning/roles/selenium/templates/selenium.j2 deleted file mode 100644 index b1123c7..0000000 --- a/vagrant/provisioning/roles/selenium/templates/selenium.j2 +++ /dev/null @@ -1,49 +0,0 @@ -#!/bin/bash - -DESC="Selenium server" -RUN_AS=root -JAVA_BIN=/usr/bin/java - -SELENIUM_DIR=/usr/local/bin/ -SELENIUM_RUN_DIR=/var/run/ -PID_FILE="$SELENIUM_RUN_DIR/selenium.pid" -JAR_FILE="$SELENIUM_DIR/{{selenium_file}}" -LOG_FILE="$SELENIUM_RUN_DIR/selenium.log" - -MAX_MEMORY="-Xmx500m" -STACK_SIZE="-Xss1024k" - -DAEMON_OPTS=" -client $MAX_MEMORY $STACK_SIZE -jar $JAR_FILE -log $LOG_FILE" - -NAME=selenium - -# TODO: Put together /etc/init.d/xvfb - -case "$1" in - start) - echo -n "Starting $DESC: " - export DISPLAY=:{{display_number}} - start-stop-daemon -c $RUN_AS --start --background --pidfile $PID_FILE --make-pidfile --exec $JAVA_BIN -- $DAEMON_OPTS - echo "$NAME." - ;; - - stop) - echo -n "Stopping $DESC: " - start-stop-daemon --stop --pidfile $PID_FILE - echo "$NAME." - ;; - - restart|force-reload) - echo -n "Restarting $DESC: " - start-stop-daemon --stop --pidfile $PID_FILE -sleep 1 -start-stop-daemon -c $RUN_AS --start --background --pidfile $PID_FILE --make-pidfile --exec $JAVA_BIN -- $DAEMON_OPTS -echo "$NAME." -;; - - *) - N=/etc/init.d/$NAME - echo "Usage: $N {start|stop|restart|force-reload}" >&2 - exit 1 - ;; -esac diff --git a/vagrant/provisioning/roles/selenium/vars/main.yml b/vagrant/provisioning/roles/selenium/vars/main.yml deleted file mode 100644 index 5e9446d..0000000 --- a/vagrant/provisioning/roles/selenium/vars/main.yml +++ /dev/null @@ -1 +0,0 @@ -cur_dir: "{{lookup('pipe','pwd')}}" diff --git a/vagrant/provisioning/roles/tools/tasks/main.yml b/vagrant/provisioning/roles/tools/tasks/main.yml deleted file mode 100644 index 2eb8646..0000000 --- a/vagrant/provisioning/roles/tools/tasks/main.yml +++ /dev/null @@ -1,12 +0,0 @@ ---- -- name: Update apt - apt: update_cache=yes - -- name: Install common tools - apt: name={{ item }} state=latest - with_items: - - git-core - - vim - - curl - - mc - - acl diff --git a/vagrant/provisioning/roles/xvfb/defaults/main.yml b/vagrant/provisioning/roles/xvfb/defaults/main.yml deleted file mode 100644 index 97cc937..0000000 --- a/vagrant/provisioning/roles/xvfb/defaults/main.yml +++ /dev/null @@ -1,2 +0,0 @@ -display_number: "{{display_number}}" - diff --git a/vagrant/provisioning/roles/xvfb/tasks/main.yml b/vagrant/provisioning/roles/xvfb/tasks/main.yml deleted file mode 100644 index abf87cd..0000000 --- a/vagrant/provisioning/roles/xvfb/tasks/main.yml +++ /dev/null @@ -1,19 +0,0 @@ -- name: Install xvfb - apt: name={{item}} - with_items: - - xvfb - - x11-xkb-utils - - xfonts-100dpi - - xfonts-75dpi - - xfonts-scalable - - xfonts-cyrillic - - x11-apps - -- name: Install init script - template: src=xvfb.j2 dest=/etc/init.d/xvfb owner=root group=root mode=755 - -- name: Link installation - shell: update-rc.d xvfb defaults - -- name: start xvfb - service: name=xvfb state=started enabled=yes diff --git a/vagrant/provisioning/roles/xvfb/templates/xvfb.j2 b/vagrant/provisioning/roles/xvfb/templates/xvfb.j2 deleted file mode 100644 index e652026..0000000 --- a/vagrant/provisioning/roles/xvfb/templates/xvfb.j2 +++ /dev/null @@ -1,25 +0,0 @@ -XVFB=/usr/bin/Xvfb -XVFBARGS=":{{display_number}} -screen 0 1280x960x24 -fbdir /var/run -ac" -PIDFILE=/var/run/xvfb.pid - -case "$1" in - start) - echo -n "Starting virtual X frame buffer: Xvfb" - start-stop-daemon --start --quiet --pidfile $PIDFILE --make-pidfile --background --exec $XVFB -- $XVFBARGS - echo "." - ;; - stop) - echo -n "Stopping virtual X frame buffer: Xvfb" - start-stop-daemon --stop --quiet --pidfile $PIDFILE - echo "." - ;; - restart) - $0 stop - $0 start - ;; - *) - echo "Usage: /etc/init.d/xvfb {start|stop|restart}" - exit 1 -esac - -exit 0 diff --git a/vagrant/provisioning/site.yml b/vagrant/provisioning/site.yml deleted file mode 100644 index 223ef49..0000000 --- a/vagrant/provisioning/site.yml +++ /dev/null @@ -1,43 +0,0 @@ ---- -- name: Prepare basic env for php apps on all nodes - hosts: all - remote_user: vagrant - sudo: yes - vars_files: - - variables.yml - roles: - - tools - - apache - - php5 - - composer - - java - - xvfb - - selenium - tasks: - - name: create directory for bundles' public resources - file: - path: /var/www/admin-translatable-bundle/features/fixtures/project/web/bundles - owner: vagrant - group: vagrant - state: directory - - name: copy admin-bundle's public resources - file: - src: /var/www/admin-translatable-bundle/vendor/fsi/admin-bundle/Resources/public - dest: /var/www/admin-translatable-bundle/features/fixtures/project/web/bundles/fsiadmin - owner: vagrant - group: vagrant - state: link - - name: copy admin-translatable-bundle's public resources - file: - src: /var/www/admin-translatable-bundle/Resources/public - dest: /var/www/admin-translatable-bundle/features/fixtures/project/web/bundles/fsiadmintranslatable - owner: vagrant - group: vagrant - state: link - - name: copy ckeditor-bundle's public resources - file: - src: /var/www/admin-translatable-bundle/vendor/friendsofsymfony/ckeditor-bundle/Resources/public - dest: /var/www/admin-translatable-bundle/features/fixtures/project/web/bundles/fosckeditor - owner: vagrant - group: vagrant - state: link diff --git a/vagrant/provisioning/variables.yml b/vagrant/provisioning/variables.yml deleted file mode 100644 index 198ec7d..0000000 --- a/vagrant/provisioning/variables.yml +++ /dev/null @@ -1,4 +0,0 @@ ---- - -display_number: 99 -selenium_version: 2.43