Skip to content

Commit

Permalink
Merge pull request #156 from jedi58/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
jedi58 committed Apr 4, 2019
2 parents 5041383 + 0949757 commit 0e21907
Show file tree
Hide file tree
Showing 21 changed files with 739 additions and 24 deletions.
20 changes: 20 additions & 0 deletions .codeclimate.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
engines:
duplication:
enabled: true
config:
languages:
- javascript
- php
fixme:
enabled: true
phpmd:
enabled: true
ratings:
paths:
- "**.inc"
- "**.js"
- "**.php"
exclude_paths:
- docs/
- tests/
- vendor/
3 changes: 3 additions & 0 deletions .coveralls.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
coverage_clover: tests/logs/clover.xml
json_path: tests/logs/coveralls-upload.json
service_name: travis-ci
9 changes: 3 additions & 6 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,14 @@ before_script:
- php composer.phar dump-autoload --optimize

script:
- mkdir ./tests/logs/
- ./vendor/bin/simple-phpunit --coverage-clover ./tests/logs/clover.xml
- mkdir -p ./tests/logs/
- php ./vendor/bin/simple-phpunit

after_script:
after_success:
- travis_retry php vendor/bin/php-coveralls -v

matrix:
fast_finish: true
allow_failures:
- php: "nightly"

addons:
code_climate:
repo_token: 85e9beea73c263cb01cea13642b2c6de1f1a8fd24c95d576c43b768f12c1558d
2 changes: 2 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
"symfony/flex": "^1.0",
"symfony/form": "^4.1",
"symfony/framework-bundle": "^4.1",
"symfony/http-kernel": "^4.1",
"symfony/monolog-bundle": "^3.3",
"symfony/orm-pack": "^1.0",
"symfony/security-bundle": "^4.1",
Expand All @@ -35,6 +36,7 @@
"symfony/debug": "^4.1",
"symfony/dotenv": "^4.1",
"symfony/maker-bundle": "^1.8",
"symfony/phpunit-bridge": "^4.1",
"symfony/profiler-pack": "^1.0",
"symfony/test-pack": "^1.0",
"symfony/web-server-bundle": "^4.1"
Expand Down
2 changes: 1 addition & 1 deletion composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions config/packages/twig.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,5 @@ twig:
strict_variables: '%kernel.debug%'
#globals:
# settings: "@App\"
form_themes:
- 'form/fieldset.html.twig'
27 changes: 27 additions & 0 deletions phpunit.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit
bootstrap="vendor/autoload.php"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true">

<testsuites>
<testsuite name="Inachis">
<directory>./tests/phpunit/</directory>
</testsuite>
</testsuites>

<filter>
<whitelist>
<directory>./src/</directory>
<exclude>
<directory>./vendor/</directory>
</exclude>
</whitelist>
</filter>

<logging>
<log type="coverage-clover" target="tests/logs/clover.xml"/>
</logging>
</phpunit>
16 changes: 0 additions & 16 deletions src/Entity/Image.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,6 @@ public function __construct()
{
}

/**
* @return string
*/
public function getId()
{
return $this->id;
}

public function getDimensionX()
{
return $this->dimensionX;
Expand All @@ -83,14 +75,6 @@ public function getAltText()
return $this->altText;
}

/**
* @param $value
*/
public function setId($value)
{
$this->id = $value;
}

public function setDimensionX($value)
{
$this->dimensionX = (int) $value;
Expand Down
8 changes: 8 additions & 0 deletions src/Entity/Page.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\ORM\Mapping as ORM;
use App\Exception\InvalidTimezoneException;

/**
* Object for handling pages of a site.
Expand Down Expand Up @@ -563,9 +564,15 @@ public function setModDate(\DateTime $value = null)
* Sets the value of {@link timezone}.
*
* @param string $value The timezone for the post_date
* @throws InvalidTimezoneException
*/
public function setTimezone($value)
{
if (!$this->isValidTimezone($value)) {
throw new InvalidTimezoneException(
sprintf('Did not recognise timezone %s', $value)
);
}
$this->timezone = $value;
}

Expand Down Expand Up @@ -729,6 +736,7 @@ public function isValidTimezone($timezone)
* Determines if current page is scheduled for publishing.
*
* @return bool Result of testing if {@link post_date} is in the future
* @throws \Exception
*/
public function isScheduledPage()
{
Expand Down
3 changes: 2 additions & 1 deletion src/Entity/Url.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ class Url
* @param Page $content The {@link Page} object the link is for
* @param string $link The short link for the content
* @param bool $default
* @throws \Exception
*/
public function __construct(Page $content, $link = '', $default = true)
{
Expand Down Expand Up @@ -167,7 +168,7 @@ public function setModDateToNow()
*/
public function validateURL()
{
return preg_match('/^[a-z0-9\-]+$/i', $this->link);
return preg_match('/^[a-z0-9\-]+$/i', $this->link) === 1;
}

public function associateContent()
Expand Down
7 changes: 7 additions & 0 deletions src/Exception/InvalidTimezoneException.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?php

namespace App\Exception;

class InvalidTimezoneException extends \Exception
{
}
56 changes: 56 additions & 0 deletions src/Form/Type/FieldsetType.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
<?php

namespace App\Form\Type;

use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\Form\FormInterface;
use Symfony\Component\Form\FormView;
use Symfony\Component\OptionsResolver\OptionsResolver;

class FieldsetType extends AbstractType
{
/**
* @param FormBuilderInterface $builder
* @param array $options
*/
public function buildForm(FormBuilderInterface $builder, array $options)
{
// execute the callable with our FormBuilder passed as an argument
$options['types']($builder);
}

/**
* @param FormView $view
* @param FormInterface $form
* @param array $options
*/
public function buildView(FormView $view, FormInterface $form, array $options)
{
if (false !== $options['legend']) {
$view->vars['legend'] = $options['legend'];
}
}

/**
* @param OptionsResolver $resolver
*/
public function configureOptions(OptionsResolver $resolver)
{
$resolver->setDefaults([
'legend' => false,
'virtual' => true,
'types' => null,
])
->setAllowedTypes('types', 'callable')
->setRequired('types');
}

/**
* @return string
*/
public function getName()
{
return 'fieldset';
}
}
11 changes: 11 additions & 0 deletions src/Views/form/fieldset.html.twig
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{% block fieldset_widget %}
<fieldset {{ block('widget_container_attributes') }}>

{% if legend is defined and legend is not empty %}
<legend>{{ legend | trans({}, translation_domain) }}</legend>
{% endif %}

{{- form_widget(form) -}}

</fieldset>
{% endblock fieldset_widget %}
24 changes: 24 additions & 0 deletions tests/phpunit/Entity/ImageTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,4 +90,28 @@ public function testSetAndGetModDate()
$this->image->setModDateFromDateTime($now);
$this->assertEquals($now->format('Y-m-d H:i:s'), $this->image->getModDate());
}

public function testSetAndGetDimensionX()
{
$this->image->setDimensionX(100);
$this->assertEquals(100, $this->image->getDimensionX());
}

public function testSetAndGetDimensionY()
{
$this->image->setDimensionY(100);
$this->assertEquals(100, $this->image->getDimensionY());
}

public function testSetAndGetCaption()
{
$this->image->setCaption('test');
$this->assertEquals('test', $this->image->getCaption());
}

public function testSetAndGetAltText()
{
$this->image->setAltText('test');
$this->assertEquals('test', $this->image->getAltText());
}
}
Loading

0 comments on commit 0e21907

Please sign in to comment.