Skip to content

Commit

Permalink
Refactor tests
Browse files Browse the repository at this point in the history
  • Loading branch information
enumag committed Jun 21, 2016
1 parent 2266e3c commit db79dad
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 20 deletions.
1 change: 1 addition & 0 deletions composer.json
Expand Up @@ -19,6 +19,7 @@
"require-dev": {
"php": "^5.5.0|^7.0.0",
"arachne/bootstrap": "^0.2.1",
"arachne/codeception": "^0.7.0",
"codeception/codeception": "~2.2.0"
},
"autoload": {
Expand Down
6 changes: 6 additions & 0 deletions tests/integration.suite.yml
@@ -1,3 +1,9 @@
error_level: "E_ALL"

class_name: IntegrationSuiteTester

modules:
enabled:
- Arachne\Codeception\Module\NetteDIModule:
tempDir: ../_temp/integration
configurator: Arachne\Bootstrap\Configurator
4 changes: 0 additions & 4 deletions tests/integration/_bootstrap.php
@@ -1,5 +1 @@
<?php

define('TEMP_DIR', __DIR__.'/../_temp/integration_'.md5(time()));

mkdir(TEMP_DIR);
22 changes: 6 additions & 16 deletions tests/integration/src/PropertyAccessorExtensionTest.php
Expand Up @@ -2,7 +2,6 @@

namespace Tests\Integration;

use Arachne\Bootstrap\Configurator;
use Codeception\Test\Unit;
use Symfony\Component\PropertyAccess\PropertyAccessorBuilder;
use Symfony\Component\PropertyAccess\PropertyAccessorInterface;
Expand All @@ -14,40 +13,31 @@ class PropertyAccessorExtensionTest extends Unit
{
public function testDefaultConfiguration()
{
$container = $this->createContainer('default.neon');
$this->tester->useConfigFiles(['config/default.neon']);

$builder = $container->getByType(PropertyAccessorBuilder::class);
$builder = $this->tester->grabService(PropertyAccessorBuilder::class);
$this->assertInstanceOf(PropertyAccessorBuilder::class, $builder);
$this->assertFalse($builder->isMagicCallEnabled());
$this->assertFalse($builder->isExceptionOnInvalidIndexEnabled());

$accessor = $container->getByType(PropertyAccessorInterface::class);
$accessor = $this->tester->grabService(PropertyAccessorInterface::class);
$this->assertInstanceOf(PropertyAccessorInterface::class, $accessor);
$this->assertAttributeSame(false, 'magicCall', $accessor);
$this->assertAttributeSame(true, 'ignoreInvalidIndices', $accessor);
}

public function testCustomConfiguration()
{
$container = $this->createContainer('custom.neon');
$this->tester->useConfigFiles(['config/custom.neon']);

$builder = $container->getByType(PropertyAccessorBuilder::class);
$builder = $this->tester->grabService(PropertyAccessorBuilder::class);
$this->assertInstanceOf(PropertyAccessorBuilder::class, $builder);
$this->assertTrue($builder->isMagicCallEnabled());
$this->assertTrue($builder->isExceptionOnInvalidIndexEnabled());

$accessor = $container->getByType(PropertyAccessorInterface::class);
$accessor = $this->tester->grabService(PropertyAccessorInterface::class);
$this->assertInstanceOf(PropertyAccessorInterface::class, $accessor);
$this->assertAttributeSame(true, 'magicCall', $accessor);
$this->assertAttributeSame(false, 'ignoreInvalidIndices', $accessor);
}

private function createContainer($file)
{
$config = new Configurator();
$config->setTempDirectory(TEMP_DIR);
$config->addConfig(__DIR__.'/../config/'.$file);

return $config->createContainer();
}
}

0 comments on commit db79dad

Please sign in to comment.