You are here

protected function DfpTestBase::dfpGenerateSize in Doubleclick for Publishers (DFP) 8

Generates a random size (or array of sizes) to use when testing tags.

Parameters

int $count: How many sizes to generate.

Return value

string|array A size formatted as ###x### or an array of sizes if $count > 1.

2 calls to DfpTestBase::dfpGenerateSize()
DfpTestBase::dfpBasicTagEditValues in tests/src/Functional/DfpTestBase.php
Creates a simple form values $edit array to be used to create a DFP tag.
DisplayTagTest::testDisplayTagWithMapping in tests/src/Functional/DisplayTagTest.php
Tests breakpoint mappings.

File

tests/src/Functional/DfpTestBase.php, line 152
Contains \Drupal\Tests\dfp\Functional\DfpTestBase.

Class

DfpTestBase
An abstract class to build DFP tests from.

Namespace

Drupal\Tests\dfp\Functional

Code

protected function dfpGenerateSize($count = 1) {
  $sizes = [
    '300x250',
    '300x600',
    '728x90',
    '728x10',
    '160x600',
    '120x80',
    '300x100',
    '50x50',
    '160x300',
  ];
  shuffle($sizes);
  return $count == 1 ? array_pop($sizes) : array_slice($sizes, 0, min($count, count($sizes)));
}