Skip to content

Commit

Permalink
ArrayOfPhotoSize class init
Browse files Browse the repository at this point in the history
  • Loading branch information
iGusev committed Jun 29, 2015
1 parent b339b98 commit c4740c0
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/Types/ArrayOfPhotoSize.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php

namespace TelegramBot\Api\Types;

abstract class ArrayOfPhotoSize extends \ArrayObject
{
public static function fromResponse($data)
{
$arrayOfPhotoSize = array();
foreach ($data as $photoSizeItem) {
$arrayOfPhotoSize[] = PhotoSize::fromResponse($photoSizeItem);
}

return $arrayOfPhotoSize;
}
}
38 changes: 38 additions & 0 deletions tests/ArrayOfPhotoSizeTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<?php

namespace TelegramBot\Api\Test;


use TelegramBot\Api\Types\PhotoSize;
use TelegramBot\Api\Types\ArrayOfPhotoSize;

class ArrayOfPhotoSizeTest extends \PHPUnit_Framework_TestCase
{

public function testFromResponse()
{
$actual = ArrayOfPhotoSize::fromResponse(
array(
array(
'file_id' => 'testFileId1',
'width' => 5,
'height' => 6,
'file_size' => 7
)
)
);

$expected = array(
PhotoSize::fromResponse(array(
'file_id' => 'testFileId1',
'width' => 5,
'height' => 6,
'file_size' => 7
))
);

foreach($actual as $key => $item) {
$this->assertEquals($expected[$key], $item);
}
}
}

0 comments on commit c4740c0

Please sign in to comment.