Skip to content

Commit

Permalink
move to new testing structure
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael Wilson committed Mar 11, 2016
1 parent d6f4f90 commit 0f1ad1a
Show file tree
Hide file tree
Showing 17 changed files with 66 additions and 51 deletions.
2 changes: 1 addition & 1 deletion phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit bootstrap="vendor/autoload.php"
<phpunit bootstrap="tests/bootstrap.php"
backupGlobals="false"
backupStaticAttributes="false"
colors="true"
Expand Down
24 changes: 0 additions & 24 deletions tests/CustomizedManagerTest.php

This file was deleted.

17 changes: 17 additions & 0 deletions tests/Integration/Managers/CustomizedManagerTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?php
namespace Michaels\Manager\Test\Integration\Managers;

use Michaels\Manager\Manager;
use Michaels\Manager\Test\Scenarios\InitManagerScenario;
use Michaels\Manager\Test\Scenarios\ManagesItemsScenario;
use Michaels\Manager\Test\Stubs\CustomizedManagerStub;

/**
* Tests customized implementations of Manager.
* Does NOT test ManagesItemsTrait api.
*/
class CustomizedManagerTest extends \PHPUnit_Framework_TestCase {

use ManagesItemsScenario, InitManagerScenario; // Pull in all the tests for ManagesItemsTrait, for integration testing
}

14 changes: 14 additions & 0 deletions tests/Integration/Managers/ManagerTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?php
namespace Michaels\Manager\Test\Managers\Integration;

use Michaels\Manager\Test\Scenarios\InitManagerScenario;
use Michaels\Manager\Test\Scenarios\ManagesItemsScenario;

/**
* Tests customized implementations of Manager.
* Does NOT test ManagesItemsTrait api.
*/
class ManagerTest extends \PHPUnit_Framework_TestCase
{
use ManagesItemsScenario, InitManagerScenario; // Pull in all the tests for ManagesItemsTrait, for integration testing
}
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
<?php
namespace Michaels\Manager\Test;

namespace Michaels\Manager\Test\Scenarios;
use Michaels\Manager\Manager;

/**
* Tests customized implementations of Manager.
* Tests Array Access, JSON, and Iterator for Manager.
* Does NOT test ManagesItemsTrait api.
*/
class ManagerTest extends \PHPUnit_Framework_TestCase {

trait InitManagerScenario
{
public function test_init_manager()
{
$expectedItems = ['one' => 1, 'two' => 2];
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?php
namespace Michaels\Manager\Test;
namespace Michaels\Manager\Test\Unit\Bags;

use Michaels\Manager\Bags\FileBag;
use Michaels\Manager\Test\Utilities\FileBagTestTrait;
Expand Down Expand Up @@ -32,7 +32,7 @@ class FileBagTest extends \PHPUnit_Framework_TestCase
*/
public function setup()
{
$this->goodTestFileDirectory = realpath(__DIR__ . '/../Fixtures/FilesWithGoodExtensions');
$this->goodTestFileDirectory = realpath($GLOBALS['test_config']['test_dir'] . '/Fixtures/FilesWithGoodExtensions');

$this->goodTestFileObjects = $this->setFilesToSplInfoObjects($this->goodTestFileDirectory);
$this->badTestFileObjects = $this->setFilesToBadObjects();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?php
namespace Michaels\Manager\Test;
namespace Michaels\Manager\Test\Unit\Decoders;

use Michaels\Manager\Decoders\JsonDecoder;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?php
namespace Michaels\Manager\Test;
namespace Michaels\Manager\Test\Unit\Decoders;

use Michaels\Manager\Decoders\PhpDecoder;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?php
namespace Michaels\Manager\Test;
namespace Michaels\Manager\Test\Unit\Decoders;

use Michaels\Manager\Decoders\YamlDecoder;
use Symfony\Component\Yaml\Yaml;
Expand Down
22 changes: 12 additions & 10 deletions tests/FileLoaderTest.php → tests/Unit/FileLoaderTest.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?php
namespace Michaels\Manager\Test;
namespace Michaels\Manager\Test\Unit;

use Michaels\Manager\Manager;
use Michaels\Manager\FileLoader;
Expand All @@ -12,6 +12,8 @@ class FileLoaderTest extends \PHPUnit_Framework_TestCase
use FileBagTestTrait;

protected $testData;

/** @var FileLoader */
private $fileLoader;

private $defaultArray = [];
Expand Down Expand Up @@ -43,15 +45,15 @@ public function setup()

public function test_adding_files_as_array()
{
$goodTestFileDirectory = realpath(__DIR__ . '/Fixtures/FilesWithGoodData');
$goodTestFileDirectory = realpath($GLOBALS['test_config']['test_dir'] . '/Fixtures/FilesWithGoodData');
$goodFiles = $this->setFilesToSplInfoObjects($goodTestFileDirectory);
$this->fileLoader->addFiles($goodFiles);
$this->assertEquals($this->defaultArray, $this->fileLoader->process());
}

public function test_adding_file_bag()
{
$goodTestFileDirectory = realpath(__DIR__ . '/Fixtures/FilesWithGoodData');
$goodTestFileDirectory = realpath($GLOBALS['test_config']['test_dir'] . '/Fixtures/FilesWithGoodData');
$goodFiles = $this->setFilesToSplInfoObjects($goodTestFileDirectory);
$fileBag = new FileBag($goodFiles);
$this->fileLoader->addFiles($fileBag);
Expand All @@ -61,8 +63,8 @@ public function test_adding_file_bag()

public function test_adding_a_custom_decoder_and_processing()
{
$goodTestFileDirectory = realpath(__DIR__ . '/Fixtures/FilesWithGoodData');
$goodCustomFileDirectory = realpath(__DIR__ . '/Fixtures/CustomFileWithGoodData');
$goodTestFileDirectory = realpath($GLOBALS['test_config']['test_dir'] . '/Fixtures/FilesWithGoodData');
$goodCustomFileDirectory = realpath($GLOBALS['test_config']['test_dir'] . '/Fixtures/CustomFileWithGoodData');
$goodFiles = $this->setFilesToSplInfoObjects($goodTestFileDirectory);
$goodCustomFile = $this->setFilesToSplInfoObjects($goodCustomFileDirectory);
$goodFiles = array_merge($goodFiles, $goodCustomFile);
Expand Down Expand Up @@ -150,8 +152,8 @@ public function test_using_explicit_namespaces()
{
$fileLoader = new FileLoader();
$fileLoader->addFiles([
new \SplFileInfo(__DIR__.'/Fixtures/FilesWithGoodData/jsonConfig.json'),
[new \SplFileInfo(__DIR__.'/Fixtures/FilesWithGoodData/phpConfig.php'), 'customNs']
new \SplFileInfo($GLOBALS['test_config']['test_dir'] . '/Fixtures/FilesWithGoodData/jsonConfig.json'),
[new \SplFileInfo($GLOBALS['test_config']['test_dir'] . '/Fixtures/FilesWithGoodData/phpConfig.php'), 'customNs']
]);

$expected['jsonConfig'] = $this->testData;
Expand All @@ -166,9 +168,9 @@ public function test_loading_files_as_a_path()
{
$fileLoader = new FileLoader();
$fileLoader->addFiles([
__DIR__.'/Fixtures/FilesWithGoodData/yamlConfig.yaml',
[__DIR__.'/Fixtures/FilesWithGoodData/phpConfig.php', 'customNs'],
new \SplFileInfo(__DIR__.'/Fixtures/FilesWithGoodData/jsonConfig.json'),
$GLOBALS['test_config']['test_dir'] . '/Fixtures/FilesWithGoodData/yamlConfig.yaml',
[$GLOBALS['test_config']['test_dir'] . '/Fixtures/FilesWithGoodData/phpConfig.php', 'customNs'],
new \SplFileInfo($GLOBALS['test_config']['test_dir'] . '/Fixtures/FilesWithGoodData/jsonConfig.json'),
]);

$expected['yamlConfig'] = $this->testData;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?php
namespace Michaels\Manager\Test\Traits;
namespace Michaels\Manager\Test\Unit\Traits;
use Michaels\Manager\Test\Scenarios\ArrayableScenario;

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?php
namespace Michaels\Manager\Test\Traits;
namespace Michaels\Manager\Test\Unit\Traits;

use Michaels\Manager\Test\Scenarios\ChainsNestedItemsScenario;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?php
namespace Michaels\Manager\Test\Traits;
namespace Michaels\Manager\Test\Unit\Traits;

use Michaels\Manager\Test\Scenarios\CollectionScenario;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?php
namespace Michaels\Manager\Test\Traits;
namespace Michaels\Manager\Test\Unit\Traits;

use Michaels\Manager\Test\Scenarios\LoadsFilesScenario;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?php
namespace Michaels\Manager\Test\Traits;
namespace Michaels\Manager\Test\Unit\Traits;

use Michaels\Manager\Test\Scenarios\ManagesIocScenario;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?php
namespace Michaels\Manager\Test\Traits;
namespace Michaels\Manager\Test\Unit\Traits;

use Michaels\Manager\Test\Scenarios\ManagesIocScenario;

Expand Down
7 changes: 7 additions & 0 deletions tests/bootstrap.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?php

require_once __DIR__ . "/../vendor/autoload.php";

$GLOBALS['test_config'] = [
'test_dir' => __DIR__,
];

0 comments on commit 0f1ad1a

Please sign in to comment.