Skip to content
This repository has been archived by the owner on Oct 13, 2021. It is now read-only.

Commit

Permalink
Moved examples classes from tests to subdic 'Examples/'
Browse files Browse the repository at this point in the history
  • Loading branch information
drbonzo committed Jun 4, 2014
1 parent 4e34f0f commit 05eabd3
Show file tree
Hide file tree
Showing 10 changed files with 68 additions and 58 deletions.
6 changes: 0 additions & 6 deletions tests/NorthslopePL/Metassione/Tests/EmptyKlass.php

This file was deleted.

@@ -1,5 +1,5 @@
<?php
namespace NorthslopePL\Metassione\Tests;
namespace NorthslopePL\Metassione\Tests\Examples;

class ArrayedKlass
{
Expand All @@ -9,42 +9,42 @@ class ArrayedKlass
private $numbers;

/**
* @var array|\NorthslopePL\Metassione\Tests\OnePropertyKlass[]
* @var array|\NorthslopePL\Metassione\Tests\Examples\OnePropertyKlass[]
*/
private $objects;

/**
* Inverted order of 'array' and classname
*
* @var \NorthslopePL\Metassione\Tests\OnePropertyKlass[]|array
* @var \NorthslopePL\Metassione\Tests\Examples\OnePropertyKlass[]|array
*/
private $objects2;

/**
* Without [] at the end
*
* @var array|\NorthslopePL\Metassione\Tests\OnePropertyKlass
* @var array|\NorthslopePL\Metassione\Tests\Examples\OnePropertyKlass
*/
private $objects3;

/**
* Without 'array|'
*
* @var \NorthslopePL\Metassione\Tests\OnePropertyKlass[]
* @var \NorthslopePL\Metassione\Tests\Examples\OnePropertyKlass[]
*/
private $invalidSpecificationForObjects;


/**
* @param array|\NorthslopePL\Metassione\Tests\OnePropertyKlass[] $objects
* @param array|\NorthslopePL\Metassione\Tests\Examples\OnePropertyKlass[] $objects
*/
public function setObjects($objects)
{
$this->objects = $objects;
}

/**
* @return array|\NorthslopePL\Metassione\Tests\OnePropertyKlass[]
* @return array|\NorthslopePL\Metassione\Tests\Examples\OnePropertyKlass[]
*/
public function getObjects()
{
Expand All @@ -68,47 +68,47 @@ public function getNumbers()
}

/**
* @param array|\NorthslopePL\Metassione\Tests\OnePropertyKlass[] $objects2
* @param array|\NorthslopePL\Metassione\Tests\Examples\OnePropertyKlass[] $objects2
*/
public function setObjects2($objects2)
{
$this->objects2 = $objects2;
}

/**
* @return array|\NorthslopePL\Metassione\Tests\OnePropertyKlass[]
* @return array|\NorthslopePL\Metassione\Tests\Examples\OnePropertyKlass[]
*/
public function getObjects2()
{
return $this->objects2;
}

/**
* @param array|\NorthslopePL\Metassione\Tests\OnePropertyKlass $objects3
* @param array|\NorthslopePL\Metassione\Tests\Examples\OnePropertyKlass $objects3
*/
public function setObjects3($objects3)
{
$this->objects3 = $objects3;
}

/**
* @return array|\NorthslopePL\Metassione\Tests\OnePropertyKlass
* @return array|\NorthslopePL\Metassione\Tests\Examples\OnePropertyKlass
*/
public function getObjects3()
{
return $this->objects3;
}

/**
* @param \NorthslopePL\Metassione\Tests\OnePropertyKlass[] $invalidSpecificationForObjects
* @param \NorthslopePL\Metassione\Tests\Examples\OnePropertyKlass[] $invalidSpecificationForObjects
*/
public function setInvalidSpecificationForObjects($invalidSpecificationForObjects)
{
$this->invalidSpecificationForObjects = $invalidSpecificationForObjects;
}

/**
* @return \NorthslopePL\Metassione\Tests\OnePropertyKlass[]
* @return \NorthslopePL\Metassione\Tests\Examples\OnePropertyKlass[]
*/
public function getInvalidSpecificationForObjects()
{
Expand Down
6 changes: 6 additions & 0 deletions tests/NorthslopePL/Metassione/Tests/Examples/EmptyKlass.php
@@ -0,0 +1,6 @@
<?php
namespace NorthslopePL\Metassione\Tests\Examples;

class EmptyKlass
{
}
@@ -0,0 +1,27 @@
<?php
namespace NorthslopePL\Metassione\Tests\Examples;

class OneObjectPropertyKlass
{
/**
* @var \NorthslopePL\Metassione\Tests\Examples\OnePropertyKlass
*/
private $value;

/**
* @param \NorthslopePL\Metassione\Tests\Examples\OnePropertyKlass $value
*/
public function setValue(OnePropertyKlass $value)
{
$this->value = $value;
}

/**
* @return \NorthslopePL\Metassione\Tests\Examples\OnePropertyKlass
*/
public function getValue()
{
return $this->value;
}

}
@@ -1,5 +1,5 @@
<?php
namespace NorthslopePL\Metassione\Tests;
namespace NorthslopePL\Metassione\Tests\Examples;

class OnePropertyKlass
{
Expand Down
@@ -1,12 +1,12 @@
<?php
namespace NorthslopePL\Metassione\Tests;
namespace NorthslopePL\Metassione\Tests\Examples;

class PropertyNotFoundKlass
{
/**
* Class Foo just does not exist. This is expected behaviour for that test.
*
* @var \NorthslopePL\Metassione\Tests\Foo
* @var \NorthslopePL\Metassione\Tests\Examples\Foo
*/
private $foo;

Expand All @@ -19,31 +19,31 @@ class PropertyNotFoundKlass
private $one;

/**
* @param \NorthslopePL\Metassione\Tests\Foo $foo
* @param \NorthslopePL\Metassione\Tests\Examples\Foo $foo
*/
public function setFoo($foo)
{
$this->foo = $foo;
}

/**
* @return \NorthslopePL\Metassione\Tests\Foo
* @return \NorthslopePL\Metassione\Tests\Examples\Foo
*/
public function getFoo()
{
return $this->foo;
}

/**
* @param \NorthslopePL\Metassione\Tests\OnePropertyKlass $one
* @param \NorthslopePL\Metassione\Tests\Examples\OnePropertyKlass $one
*/
public function setOne($one)
{
$this->one = $one;
}

/**
* @return \NorthslopePL\Metassione\Tests\OnePropertyKlass
* @return \NorthslopePL\Metassione\Tests\Examples\OnePropertyKlass
*/
public function getOne()
{
Expand Down
@@ -1,5 +1,5 @@
<?php
namespace NorthslopePL\Metassione\Tests;
namespace NorthslopePL\Metassione\Tests\Examples;

class SimpleKlass
{
Expand Down
27 changes: 0 additions & 27 deletions tests/NorthslopePL/Metassione/Tests/OneObjectPropertyKlass.php

This file was deleted.

4 changes: 4 additions & 0 deletions tests/NorthslopePL/Metassione/Tests/POPOConverterTest.php
Expand Up @@ -2,6 +2,10 @@
namespace NorthslopePL\Metassione\Tests;

use NorthslopePL\Metassione\POPOConverter;
use NorthslopePL\Metassione\Tests\Examples\ArrayedKlass;
use NorthslopePL\Metassione\Tests\Examples\EmptyKlass;
use NorthslopePL\Metassione\Tests\Examples\OnePropertyKlass;
use NorthslopePL\Metassione\Tests\Examples\SimpleKlass;

class POPOConverterTest extends \PHPUnit_Framework_TestCase
{
Expand Down
14 changes: 10 additions & 4 deletions tests/NorthslopePL/Metassione/Tests/POPOObjectFillerTest.php
Expand Up @@ -3,6 +3,12 @@

use NorthslopePL\Metassione\POPOObjectFiller;
use NorthslopePL\Metassione\Tests\Blog\Blog;
use NorthslopePL\Metassione\Tests\Examples\ArrayedKlass;
use NorthslopePL\Metassione\Tests\Examples\EmptyKlass;
use NorthslopePL\Metassione\Tests\Examples\OneObjectPropertyKlass;
use NorthslopePL\Metassione\Tests\Examples\OnePropertyKlass;
use NorthslopePL\Metassione\Tests\Examples\PropertyNotFoundKlass;
use NorthslopePL\Metassione\Tests\Examples\SimpleKlass;

class POPOObjectFillerTest extends \PHPUnit_Framework_TestCase
{
Expand Down Expand Up @@ -91,7 +97,7 @@ public function testFillingSimpleObjectWithRawDataThatIsNotAnObject()
$simpleObject = new SimpleKlass();
$rawData = 'foobar';

$this->setExpectedException('NorthslopePL\Metassione\ObjectFillingException', 'Raw data should be an object, but string was given. I was trying to fill object of class NorthslopePL\Metassione\Tests\SimpleKlass.');
$this->setExpectedException('NorthslopePL\Metassione\ObjectFillingException', 'Raw data should be an object, but string was given. I was trying to fill object of class NorthslopePL\Metassione\Tests\Examples\SimpleKlass.');

$this->objectFiller->fillObjectWithRawData($simpleObject, $rawData);
}
Expand All @@ -102,7 +108,7 @@ public function testFillingObjectWhenItsPropertysClassDoesNotExist()
$rawData = new \stdClass();
$rawData->foo = 'bar';

$this->setExpectedException('NorthslopePL\Metassione\ObjectFillingException', 'Class "NorthslopePL\Metassione\Tests\Foo" does not exist for property NorthslopePL\Metassione\Tests\PropertyNotFoundKlass::$foo');
$this->setExpectedException('NorthslopePL\Metassione\ObjectFillingException', 'Class "NorthslopePL\Metassione\Tests\Examples\Foo" does not exist for property NorthslopePL\Metassione\Tests\Examples\PropertyNotFoundKlass::$foo');
$this->objectFiller->fillObjectWithRawData($targetObject, $rawData);
}

Expand Down Expand Up @@ -167,7 +173,7 @@ public function testFillingObjectWithIncorrectlyDocumentedArrayProperty()
}
$rawData->invalidSpecificationForObjects = array($object1, $object2);

$this->setExpectedException('NorthslopePL\Metassione\ObjectFillingException', 'Raw data should be an object, but array was given. I was trying to fill object of class NorthslopePL\Metassione\Tests\OnePropertyKlass. Maybe you have forgotten about adding "array|" for property that holds this class NorthslopePL\Metassione\Tests\OnePropertyKlass');
$this->setExpectedException('NorthslopePL\Metassione\ObjectFillingException', 'Raw data should be an object, but array was given. I was trying to fill object of class NorthslopePL\Metassione\Tests\Examples\OnePropertyKlass. Maybe you have forgotten about adding "array|" for property that holds this class NorthslopePL\Metassione\Tests\Examples\OnePropertyKlass');
$this->objectFiller->fillObjectWithRawData($targetObject, $rawData);
}

Expand All @@ -188,7 +194,7 @@ public function testUsingUnqalifiedClassname()
$sourceData = new \stdClass();
$sourceData->one = (object)array('value' => 42);

$this->setExpectedException('NorthslopePL\Metassione\ObjectFillingException', 'Class "OnePropertyKlass" does not exist for property NorthslopePL\Metassione\Tests\PropertyNotFoundKlass::$one. Maybe you have forgotten to use fully qualified class name (with namespace, example: \Foo\Bar\OnePropertyKlass)?');
$this->setExpectedException('NorthslopePL\Metassione\ObjectFillingException', 'Class "OnePropertyKlass" does not exist for property NorthslopePL\Metassione\Tests\Examples\PropertyNotFoundKlass::$one. Maybe you have forgotten to use fully qualified class name (with namespace, example: \Foo\Bar\OnePropertyKlass)?');
$this->objectFiller->fillObjectWithRawData($targetObject, $sourceData);
}
}

0 comments on commit 05eabd3

Please sign in to comment.