Skip to content

Commit

Permalink
Move tests into Codesleeve\Stapler namespace.
Browse files Browse the repository at this point in the history
Tests have now been moved into the Codesleeve\Stapler namespace so that
there are no naming conflicts with the version of TestCase that's being
used.
  • Loading branch information
tabennett committed Mar 7, 2014
1 parent 7c7006c commit 98f8989
Show file tree
Hide file tree
Showing 10 changed files with 130 additions and 118 deletions.
3 changes: 1 addition & 2 deletions composer.json
Expand Up @@ -21,8 +21,7 @@
},
"autoload": {
"classmap": [
"src/migrations",
"tests/TestCase.php"
"src/migrations"
],
"psr-0": {
"Codesleeve\\Stapler": "src/"
Expand Down
6 changes: 3 additions & 3 deletions phpunit.xml
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit backupGlobals="false"
backupStaticAttributes="false"
bootstrap="vendor/autoload.php"
bootstrap="tests/bootstrap.php"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
Expand All @@ -11,8 +11,8 @@
syntaxCheck="false"
>
<testsuites>
<testsuite name="Package Test Suite">
<directory suffix=".php">./tests/</directory>
<testsuite name="Stapler Test Suite">
<directory suffix=".php">./tests/Codesleeve/Stapler/</directory>
</testsuite>
</testsuites>
</phpunit>
@@ -1,13 +1,13 @@
<?php
<?php namespace Codesleeve\Stapler;

use Mockery as m;

class AttachmentTest extends TestCase
{
/**
* Setup method.
*
* @return void
*
* @return void
*/
public function setUp()
{
Expand All @@ -16,8 +16,8 @@ public function setUp()

/**
* Teardown method.
*
* @return void
*
* @return void
*/
public function tearDown()
{
Expand All @@ -26,15 +26,15 @@ public function tearDown()

/**
* Test that the setUploadedFile method is working correctly.
*
*
* @return void
*/
public function testSetUploadedFile()
{
$IOWrapper = $this->buildMockIOWrapper();

$config = m::mock('Codesleeve\Stapler\Config', ['mockAttachment', []]);

$instance = m::mock();
$instance->shouldReceive('setAttribute')->once()->with('mockAttachment_file_name', '');
$instance->shouldReceive('setAttribute')->once()->with('mockAttachment_file_size', '');
Expand All @@ -52,7 +52,7 @@ public function testSetUploadedFile()

/**
* Test that the url method returns the url to a file that has been uploaded.
*
*
* @return void
*/
public function testUrlReturnsAUrl()
Expand All @@ -70,7 +70,7 @@ public function testUrlReturnsAUrl()

/**
* Test that the url method returns the default url when no file has been uploaded.
*
*
* @return void
*/
public function testUrlReturnsTheDefaultUrl()
Expand All @@ -80,13 +80,13 @@ public function testUrlReturnsTheDefaultUrl()
$attachment = m::mock('Codesleeve\Stapler\Attachment')->makePartial();
$attachment->shouldReceive('originalFilename')->once()->andReturn(false);
$attachment->setConfig($config);

$this->assertEquals('', $attachment->url());
}

/**
* Test that the path method returns the path to a file that has been uploaded.
*
*
* @return void
*/
public function testPathReturnsAPath()
Expand All @@ -104,7 +104,7 @@ public function testPathReturnsAPath()

/**
* Test that the path method returns the default path when no file has been uploaded.
*
*
* @return void
*/
public function testPathReturnsTheDefaultPath()
Expand All @@ -114,19 +114,19 @@ public function testPathReturnsTheDefaultPath()
$attachment = m::mock('Codesleeve\Stapler\Attachment')->makePartial();
$attachment->shouldReceive('originalFilename')->once()->andReturn(false);
$attachment->setConfig($config);

$this->assertEquals('/public', $attachment->path());
}

/**
* Test that the createdAt method is working correctly.
*
*
* @return void
*/
public function testCreatedAt()
{
$config = m::mock('Codesleeve\Stapler\Config', ['mockAttachment', []]);

$instance = m::mock();
$instance->shouldReceive('getAttribute')->once()->with('mockAttachment_created_at')->andReturn('foo');

Expand All @@ -139,13 +139,13 @@ public function testCreatedAt()

/**
* Test that the updatedAt method is working correctly.
*
*
* @return void
*/
public function testUpdatedAt()
{
$config = m::mock('Codesleeve\Stapler\Config', ['mockAttachment', []]);

$instance = m::mock();
$instance->shouldReceive('getAttribute')->once()->with('mockAttachment_updated_at')->andReturn('foo');

Expand All @@ -158,13 +158,13 @@ public function testUpdatedAt()

/**
* Test that the contentType method is working correctly.
*
*
* @return void
*/
public function testContentType()
{
$config = m::mock('Codesleeve\Stapler\Config', ['mockAttachment', []]);

$instance = m::mock();
$instance->shouldReceive('getAttribute')->once()->with('mockAttachment_content_type')->andReturn('foo');

Expand All @@ -177,13 +177,13 @@ public function testContentType()

/**
* Test that the size method is working correctly.
*
*
* @return void
*/
public function testSize()
{
$config = m::mock('Codesleeve\Stapler\Config', ['mockAttachment', []]);

$instance = m::mock();
$instance->shouldReceive('getAttribute')->once()->with('mockAttachment_file_size')->andReturn('foo');

Expand All @@ -196,13 +196,13 @@ public function testSize()

/**
* Test that the originalFilename method is working correctly.
*
*
* @return void
*/
public function testOriginalFilename()
{
$config = m::mock('Codesleeve\Stapler\Config', ['mockAttachment', []]);

$instance = m::mock();
$instance->shouldReceive('getAttribute')->once()->with('mockAttachment_file_name')->andReturn('foo');

Expand All @@ -215,7 +215,7 @@ public function testOriginalFilename()

/**
* Test that the afterSave method is working correctly.
*
*
* @return void
*/
public function testAfterSave()
Expand All @@ -232,7 +232,7 @@ public function testAfterSave()

/**
* Test that the beforeDelelete method is functioning properly.
*
*
* @return void
*/
public function testBeforeDelete()
Expand All @@ -249,7 +249,7 @@ public function testBeforeDelete()

/**
* Test the the afterDelete method is working correctly.
*
*
* @return void
*/
/*public function testAfterDelete()
Expand All @@ -271,8 +271,8 @@ public function testBeforeDelete()

/**
* Test that the destroy method is functioning correctly.
*
* @return void
*
* @return void
*/
public function testDestroy()
{
Expand All @@ -286,14 +286,14 @@ public function testDestroy()
/**
* Test that the clear method is working correctly when passed a
* specific set of styles to clear.
*
*
* @return void
*/
public function testClearWithStyles()
{
$attachment = m::mock('Codesleeve\Stapler\Attachment')->makePartial();
$attachment->shouldReceive('path')->once()->with('foo')->andReturn('bar');

$attachment->clear(['foo']);

$this->assertEquals(['bar'], $attachment->getQueuedForDeletion());
Expand All @@ -302,14 +302,14 @@ public function testClearWithStyles()
/**
* Test that the clear method is working correctly when no styles are passed
* and a file has already been uploaded and preserve files is set to false.
*
*
* @return void
*/
public function testClearWithoutStylesAndWithUploadedFile()
{
$config = m::mock('Codesleeve\Stapler\Config', [
'mockAttachment', [
'preserve_files' => false,
'preserve_files' => false,
'styles' => ['foo' => ''],
'convert_options' => []
]
Expand All @@ -335,7 +335,7 @@ public function testClearWithoutStylesAndWithUploadedFile()
/**
* Test that the clear method is working correctly when no styles are passed
* and a file has already been uploaded and preserve files is set to true.
*
*
* @return void
*/
public function testClearWithoutStylesAndWithUploadedFileAndPreserveFiles()
Expand All @@ -360,7 +360,7 @@ public function testClearWithoutStylesAndWithUploadedFileAndPreserveFiles()

/**
* Test that the getInstanceClass method is working correctly.
*
*
* @return void
*/
public function testGetInstanceClass()
Expand All @@ -375,7 +375,7 @@ public function testGetInstanceClass()

/**
* Build a mock IOWrapper object.
*
*
* @return IOWrapper
*/
protected function buildMockIOWrapper()
Expand All @@ -384,7 +384,7 @@ protected function buildMockIOWrapper()
$mockUploadedFile->shouldReceive('getFilename')->once();
$mockUploadedFile->shouldReceive('getSize')->once();
$mockUploadedFile->shouldReceive('getMimeType')->once();

$IOWrapper = m::mock('Codesleeve\Stapler\IOWrapper');
$IOWrapper->shouldReceive('make')->once()->andReturn($mockUploadedFile);

Expand Down
@@ -1,13 +1,13 @@
<?php
<?php namespace Codesleeve\Stapler;

use Mockery as m;

class ConfigTest extends TestCase
{
/**
* Setup method.
*
* @return void
*
* @return void
*/
public function setUp()
{
Expand All @@ -16,8 +16,8 @@ public function setUp()

/**
* Teardown method.
*
* @return void
*
* @return void
*/
public function tearDown()
{
Expand All @@ -26,15 +26,15 @@ public function tearDown()

/**
* Test the __get magic method is working correctly.
*
*
* @return void
*/
public function testGet()
{
$config = m::mock('Codesleeve\Stapler\Config', [
'mockAttachment',
'mockAttachment',
[
'foo' => 'bar',
'foo' => 'bar',
'styles' => ['baz' => ''],
'convert_options' => []
]
Expand Down

0 comments on commit 98f8989

Please sign in to comment.