Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tests/missed tests #17

Merged
merged 24 commits into from
Sep 9, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
ab2d7a2
fix keeping history of uploaded files after each flash
Sep 8, 2014
abb9cb0
add testing for provider initialization testInitializingObject
Sep 8, 2014
5b50d42
add testing for files upload
Sep 8, 2014
d5122eb
add testing for the push command
Sep 8, 2014
3b0d039
add testing for the facade url generator
Sep 8, 2014
287a56e
add validators
Sep 9, 2014
918ce2b
add validation
Sep 9, 2014
25bcb68
rename configuration cass (validator) to ProviderValidator
Sep 9, 2014
50a48bb
update usage of Vinelab\Cdn\Validators\Contracts\Configurations
Sep 9, 2014
bdc07a2
add exception class to be trow when a function input is missed
Sep 9, 2014
089388a
add missed public functions to validator interfaces
Sep 9, 2014
5a20550
update the FacadeTest after injecting new dependency to the CdnFacade
Sep 9, 2014
f480446
add if condition to check if $path exist in the asset() function
Sep 9, 2014
7b2d033
add testing for null asset parameter
Sep 9, 2014
4bad486
rename the exception EmptyInputException to EmptyPathException
Sep 9, 2014
98ee6ee
remove checkIfEmpty from the Validator class
Sep 9, 2014
83886ec
add tests for the providers factory class (testAwsS3ProviderCreation)
Sep 9, 2014
e7f32ea
add tests for the providers factory create
Sep 9, 2014
0e6badf
add test for empty /public directory when reading allowed directories
Sep 9, 2014
0cbeea5
rename the FacadeTest to CdnFacadeTest
Sep 9, 2014
b36f9f5
rename the AwsS3Test to AwsS3ProviderTest
Sep 9, 2014
739076d
add tests for the asset class
Sep 9, 2014
8e588f9
fix the asset() by checking if parameter isset
Sep 9, 2014
e8d6676
add register the package (for the config files) in the Service Provider.
Sep 9, 2014
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 13 additions & 13 deletions src/Vinelab/Cdn/Asset.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class Asset implements AssetInterface{
*
* @var array
*/
private $default_include = [
protected $default_include = [
'directories' => ['public'],
'extensions' => [],
'patterns' => [],
Expand All @@ -29,7 +29,7 @@ class Asset implements AssetInterface{
*
* @var array
*/
private $default_exclude = [
protected $default_exclude = [
'directories' => [],
'files' => [],
'extensions' => [],
Expand All @@ -40,40 +40,40 @@ class Asset implements AssetInterface{
/**
* @var Array
*/
public $included_directories;
protected $included_directories;
/**
* @var Array
*/
public $included_files;
protected $included_files;
/**
* @var Array
*/
public $included_extensions;
protected $included_extensions;
/**
* @var Array
*/
public $included_patterns;
protected $included_patterns;

/**
* @var Array
*/
public $excluded_directories;
protected $excluded_directories;
/**
* @var Array
*/
public $excluded_files;
protected $excluded_files;
/**
* @var Array
*/
public $excluded_extensions;
protected $excluded_extensions;
/**
* @var Array
*/
public $excluded_patterns;
protected $excluded_patterns;
/*
* @var boolean
*/
public $exclude_hidden;
protected $exclude_hidden;

/*
* Allowed assets for upload (found in included_directories)
Expand Down Expand Up @@ -113,7 +113,7 @@ public function init($configurations = array())
*
* @param $configurations
*/
public function parseAndFillConfiguration($configurations)
private function parseAndFillConfiguration($configurations)
{
$this->default_include = isset($configurations['include']) ?
array_merge($this->default_include, $configurations['include']) : $this->default_include;
Expand Down Expand Up @@ -179,7 +179,7 @@ public function getExcludedPatterns()
}

/**
* @return mixed
* @return Collection
*/
public function getAssets()
{
Expand Down
2 changes: 1 addition & 1 deletion src/Vinelab/Cdn/Cdn.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public function push()
// return an instance of the corresponding Provider concrete according to the configuration
$provider = $this->provider_factory->create($configurations);

$provider->upload($this->asset_holder->getAssets());
return $provider->upload($this->asset_holder->getAssets());
}

}
25 changes: 21 additions & 4 deletions src/Vinelab/Cdn/CdnFacade.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,20 @@
use Vinelab\Cdn\Contracts\ProviderFactoryInterface;
use Vinelab\Cdn\Contracts\CdnFacadeInterface;
use Vinelab\Cdn\Contracts\CdnHelperInterface;
use Vinelab\Cdn\Validators\CdnFacadeValidator;
use Vinelab\Cdn\Exceptions\EmptyPathException;

/**
* Class CdnFacade
* @package Vinelab\Cdn
*/
class CdnFacade implements CdnFacadeInterface{

/**
* @var Contracts\ProviderFactoryInterface
*/
protected $provider_factory;

/**
* @var instance of the default provider object
*/
Expand All @@ -24,20 +31,28 @@ class CdnFacade implements CdnFacadeInterface{
*/
protected $helper;

/**
* @var Validators\CdnFacadeValidator
*/
protected $cdn_facade_validator;

/**
* Calls the provider initializer
*
* @param ProviderFactoryInterface $provider_factory
* @param Contracts\CdnHelperInterface $helper
* @param Validators\CdnFacadeValidator $cdn_facade_validator
*
* @internal param \Vinelab\Cdn\Repository $configurations
*/
public function __construct(
ProviderFactoryInterface $provider_factory,
CdnHelperInterface $helper
CdnHelperInterface $helper,
CdnFacadeValidator $cdn_facade_validator
) {
$this->provider_factory = $provider_factory;
$this->helper = $helper;
$this->cdn_facade_validator = $cdn_facade_validator;

$this->init();
}
Expand All @@ -49,10 +64,14 @@ public function __construct(
*
* @param $path
*
* @return string
* @return mixed
* @throws Exceptions\EmptyPathException
*/
public function asset($path)
{
if ( ! isset($path))
throw new EmptyPathException('Path does not exist.');

// remove slashes from begging and ending of the path then call the
// url generator of the provider
return $this->provider->urlGenerator($this->cleanPath($path));
Expand Down Expand Up @@ -85,6 +104,4 @@ private function init()
$this->provider = $this->provider_factory->create($configurations);
}



}
3 changes: 3 additions & 0 deletions src/Vinelab/Cdn/CdnHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ public function __construct(Repository $configurations)
/**
* Check if the config file exist and return it or
* throw an exception
*
* @return array
* @throws Exceptions\MissingConfigurationFileException
*/
public function getConfigurations()
{
Expand Down
16 changes: 14 additions & 2 deletions src/Vinelab/Cdn/CdnServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,18 @@ public function register()
);

$this->app->bind(
'Vinelab\Cdn\Validators\Contracts\ConfigurationsInterface',
'Vinelab\Cdn\Validators\Configurations'
'Vinelab\Cdn\Validators\Contracts\ProviderValidatorInterface',
'Vinelab\Cdn\Validators\ProviderValidator'
);

$this->app->bind(
'Vinelab\Cdn\Validators\Contracts\CdnFacadeValidatorInterface',
'Vinelab\Cdn\Validators\CdnFacadeValidator'
);

$this->app->bind(
'Vinelab\Cdn\Validators\Contracts\ValidatorInterface',
'Vinelab\Cdn\Validators\Validator'
);

// register the commands:
Expand Down Expand Up @@ -106,6 +116,8 @@ public function register()
});


// registering the package (for the config files)
$this->package("vinelab/cdn");

}

Expand Down
1 change: 0 additions & 1 deletion src/Vinelab/Cdn/Contracts/AssetInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
interface AssetInterface {

public function init($configurations);
public function parseAndFillConfiguration($configurations);

public function getIncludedDirectories();
public function getIncludedExtensions();
Expand Down
1 change: 1 addition & 0 deletions src/Vinelab/Cdn/Exceptions/Exceptions.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@ class CdnException extends \RuntimeException {}
class MissingConfigurationFileException extends CdnException {}
class MissingConfigurationException extends CdnException {}
class UnsupportedProviderException extends CdnException {}
class EmptyPathException extends CdnException {}

2 changes: 1 addition & 1 deletion src/Vinelab/Cdn/Finder.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ private function includeThis(AssetInterface $asset_holder)

// include files with this extensions
foreach ($asset_holder->getIncludedExtensions() as $extension) {
$this->name('*'.$extension);
$this->name('*' . $extension);
}

// include patterns
Expand Down
Loading