Skip to content

Commit

Permalink
#7 added getTimegridUnits to the core methods
Browse files Browse the repository at this point in the history
  • Loading branch information
TobiasFranek committed Jul 7, 2018
1 parent c72fd76 commit 191baed
Show file tree
Hide file tree
Showing 5 changed files with 155 additions and 1 deletion.
5 changes: 5 additions & 0 deletions src/Models/StatusData.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@
use Webuntis\Models\Interfaces\AdministrativeModelInterface;
use JMS\Serializer\Annotation\SerializedName;

/**
* StatusData Model
* @author Tobias Franek <[email protected]>
* @license MIT
*/
class StatusData extends AbstractModel implements CachableModelInterface, AdministrativeModelInterface
{
const CACHE_LIFE_TIME = 0;
Expand Down
93 changes: 93 additions & 0 deletions src/Models/TimegridUnits.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
<?php

namespace Webuntis\Models;

use Webuntis\Models\AbstractModel;
use Webuntis\Models\Interfaces\CachableModelInterface;
use Webuntis\Models\Interfaces\AdministrativeModelInterface;
use JMS\Serializer\Annotation\SerializedName;

/**
* TimegridUntits Model
* @author Tobias Franek <[email protected]>
* @license MIT
*/
class TimegridUnits extends AbstractModel implements CachableModelInterface, AdministrativeModelInterface
{
const CACHE_LIFE_TIME = 0;
const METHOD = "getTimegridUnits";

/**
* @var int
*/
private $day;

/**
* @var array
* @SerializedName("timeUnits")
*/
private $timeUnits;

/**
* Getter for day
*
* @return int
*/
public function getDay() : int
{
return $this->day;
}

/**
* Setter for day
*
* @param int $day
*
* @return TimegridUnits
*/
public function setDay(int $day) : self
{
$this->day = $day;

return $this;
}

/**
* Getter for timeUnits
*
* @return array
*/
public function getTimeUnits() : array
{
return $this->timeUnits;
}

/**
* Setter for timeUnits
*
* @param array $timeUnits
*
* @return TimegridUnits
*/
public function setTimeUnits(array $timeUnits) : self
{
$this->timeUnits = $timeUnits;

return $this;
}

/**
* sets an given field
*
* @param mixed $field
* @param mixed $value
*
* @return TimegridUnits
*/
public function set($field, $value) : self
{
$this->$field = $value;

return $this;
}
}
11 changes: 11 additions & 0 deletions src/Resources/config/TimegridUnits.webuntis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
Webuntis\Models\TimegridUnits:
repositoryClass: null
fields:
day:
type: int
api:
name: day
timeUnits:
type: array
api:
name: timeUnits
3 changes: 2 additions & 1 deletion tests/Configuration/YAMLConfigurationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ public function testLoad() : void
'Substitutions' => 'Webuntis\Models\Substitutions',
'Teachers' => 'Webuntis\Models\Teachers',
'ClassRegEvents' => 'Webuntis\Models\ClassRegEvents',
'StatusData' => 'Webuntis\Models\StatusData'
'StatusData' => 'Webuntis\Models\StatusData',
'TimegridUnits' => 'Webuntis\Models\TimegridUnits'
];
$expectedRepositories = [
'Default' => 'Webuntis\Repositories\Repository',
Expand Down
44 changes: 44 additions & 0 deletions tests/Models/TimegridUnitsTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<?php
declare(strict_types=1);

namespace Webuntis\Tests\Models;

use PHPUnit\Framework\TestCase;
use Webuntis\Models\TimegridUnits;

/**
* TimegridUnitsTest
* @author Tobias Franek <[email protected]>
* @license MIT
*/
final class TimegridUnitsTest extends TestCase
{
public function testCreate() : void
{
$data = [
'id' => 1,
'day' => 0,
'timeUnits' => [
'test' => 'test'
]
];

$classes = new TimegridUnits($data);

$this->assertEquals(1, $classes->getId());
$this->assertEquals(0, $classes->getDay());
$this->assertEquals([
'test' => 'test'
], $classes->getTimeUnits());

$expected = [
'id' => 1,
'day' => 0,
'timeUnits' => [
'test' => 'test'
]
];

$this->assertEquals($expected, $classes->serialize());
}
}

0 comments on commit 191baed

Please sign in to comment.