code
stringlengths 31
1.39M
| docstring
stringlengths 23
16.8k
| func_name
stringlengths 1
126
| language
stringclasses 1
value | repo
stringlengths 7
63
| path
stringlengths 7
166
| url
stringlengths 50
220
| license
stringclasses 7
values |
---|---|---|---|---|---|---|---|
public function testRenderDivisionHeader(): void
{
$this->object->setSilent(true);
$this->object->renderDivisionHeader('test');
static::assertSame('', file_get_contents($this->file));
} | tests rendering the header of one division
@throws ExpectationFailedException | testRenderDivisionHeader | php | browscap/browscap | tests/BrowscapTest/Writer/JsonWriterTest.php | https://github.com/browscap/browscap/blob/master/tests/BrowscapTest/Writer/JsonWriterTest.php | MIT |
public function testRenderSectionHeaderIfNotSilent(): void
{
$this->object->setSilent(false);
$mockFormatter = $this->getMockBuilder(JsonFormatter::class)
->disableOriginalConstructor()
->onlyMethods(['formatPropertyName'])
->getMock();
$mockFormatter
->expects(static::once())
->method('formatPropertyName')
->willReturn('test');
assert($mockFormatter instanceof JsonFormatter);
$this->object->setFormatter($mockFormatter);
$this->object->renderSectionHeader('test');
static::assertSame(' test: ', file_get_contents($this->file));
} | tests rendering the header of one section
@throws ExpectationFailedException
@throws JsonException | testRenderSectionHeaderIfNotSilent | php | browscap/browscap | tests/BrowscapTest/Writer/JsonWriterTest.php | https://github.com/browscap/browscap/blob/master/tests/BrowscapTest/Writer/JsonWriterTest.php | MIT |
public function testRenderSectionHeaderIfSilent(): void
{
$this->object->setSilent(true);
$this->object->renderSectionHeader('test');
static::assertSame('', file_get_contents($this->file));
} | tests rendering the header of one section
@throws ExpectationFailedException
@throws JsonException | testRenderSectionHeaderIfSilent | php | browscap/browscap | tests/BrowscapTest/Writer/JsonWriterTest.php | https://github.com/browscap/browscap/blob/master/tests/BrowscapTest/Writer/JsonWriterTest.php | MIT |
public function testRenderSectionBodyIfNotSilent(): void
{
$this->object->setSilent(false);
$section = [
'Test' => 1,
'isTest' => true,
'abc' => 'bcd',
];
$useragent = $this->getMockBuilder(UserAgent::class)
->disableOriginalConstructor()
->onlyMethods(['getProperties'])
->getMock();
$useragent
->expects(static::once())
->method('getProperties')
->willReturn([
'Test' => 'abc',
'abc' => true,
]);
$mockExpander = $this->getMockBuilder(TrimProperty::class)
->disableOriginalConstructor()
->onlyMethods(['trim'])
->getMock();
$mockExpander
->expects(static::once())
->method('trim')
->willReturnArgument(0);
$property = new ReflectionProperty($this->object, 'trimProperty');
$property->setValue($this->object, $mockExpander);
$division = $this->getMockBuilder(Division::class)
->disableOriginalConstructor()
->onlyMethods(['getUserAgents'])
->getMock();
$division
->expects(static::once())
->method('getUserAgents')
->willReturn([0 => $useragent]);
$collection = $this->getMockBuilder(DataCollection::class)
->disableOriginalConstructor()
->onlyMethods(['getDefaultProperties'])
->getMock();
$collection
->expects(static::once())
->method('getDefaultProperties')
->willReturn($division);
$mockFormatter = $this->getMockBuilder(JsonFormatter::class)
->disableOriginalConstructor()
->onlyMethods(['formatPropertyName', 'formatPropertyValue'])
->getMock();
$map1 = [
['{"Test":1,"abc":"bcd"}', 'Comment', '{"Test":1,"abc":"bcd"}'],
];
$mockFormatter
->expects(static::never())
->method('formatPropertyName');
$mockFormatter
->expects(static::once())
->method('formatPropertyValue')
->willReturnMap($map1);
assert($mockFormatter instanceof JsonFormatter);
$this->object->setFormatter($mockFormatter);
$mockFilter = $this->getMockBuilder(StandardFilter::class)
->disableOriginalConstructor()
->onlyMethods(['isOutputProperty'])
->getMock();
$map2 = [
['Test', $this->object, true],
['isTest', $this->object, false],
['abc', $this->object, true],
];
$mockFilter
->expects(static::exactly(2))
->method('isOutputProperty')
->willReturnMap($map2);
assert($mockFilter instanceof StandardFilter);
$this->object->setFilter($mockFilter);
assert($collection instanceof DataCollection);
$this->object->renderSectionBody($section, $collection);
static::assertSame(
'{"Test":1,"abc":"bcd"}',
file_get_contents($this->file),
);
} | tests rendering the body of one section
@throws ReflectionException
@throws InvalidArgumentException
@throws Exception
@throws JsonException | testRenderSectionBodyIfNotSilent | php | browscap/browscap | tests/BrowscapTest/Writer/JsonWriterTest.php | https://github.com/browscap/browscap/blob/master/tests/BrowscapTest/Writer/JsonWriterTest.php | MIT |
public function testRenderSectionBodyIfNotSilentWithParents(): void
{
$this->object->setSilent(false);
$section = [
'Parent' => 'X1',
'Comment' => '1',
'Win16' => true,
'Platform' => 'bcd',
];
$sections = [
'X1' => [
'Comment' => '12',
'Win16' => false,
'Platform' => 'bcd',
],
'X2' => $section,
];
$useragent = $this->getMockBuilder(UserAgent::class)
->disableOriginalConstructor()
->onlyMethods(['getProperties'])
->getMock();
$useragent
->expects(static::once())
->method('getProperties')
->willReturn([
'Comment' => 1,
'Win16' => true,
'Platform' => 'bcd',
]);
$mockExpander = $this->getMockBuilder(TrimProperty::class)
->disableOriginalConstructor()
->onlyMethods(['trim'])
->getMock();
$mockExpander
->expects(static::exactly(2))
->method('trim')
->willReturnArgument(0);
$property = new ReflectionProperty($this->object, 'trimProperty');
$property->setValue($this->object, $mockExpander);
$division = $this->getMockBuilder(Division::class)
->disableOriginalConstructor()
->onlyMethods(['getUserAgents'])
->getMock();
$division
->expects(static::once())
->method('getUserAgents')
->willReturn([0 => $useragent]);
$collection = $this->getMockBuilder(DataCollection::class)
->disableOriginalConstructor()
->onlyMethods(['getDefaultProperties'])
->getMock();
$collection
->expects(static::once())
->method('getDefaultProperties')
->willReturn($division);
$mockFormatter = $this->getMockBuilder(JsonFormatter::class)
->disableOriginalConstructor()
->onlyMethods(['formatPropertyName', 'formatPropertyValue'])
->getMock();
$mockFormatter
->expects(static::never())
->method('formatPropertyName')
->willReturnArgument(0);
$mockFormatter
->expects(static::once())
->method('formatPropertyValue')
->willReturnArgument(0);
assert($mockFormatter instanceof JsonFormatter);
$this->object->setFormatter($mockFormatter);
$map = [
['Comment', $this->object, true],
['Win16', $this->object, false],
['Platform', $this->object, true],
['Parent', $this->object, true],
];
$mockFilter = $this->getMockBuilder(StandardFilter::class)
->disableOriginalConstructor()
->onlyMethods(['isOutputProperty'])
->getMock();
$mockFilter
->expects(static::exactly(4))
->method('isOutputProperty')
->willReturnMap($map);
assert($mockFilter instanceof StandardFilter);
$this->object->setFilter($mockFilter);
assert($collection instanceof DataCollection);
$this->object->renderSectionBody($section, $collection, $sections);
static::assertSame(
'{"Parent":"X1","Comment":"1"}',
file_get_contents($this->file),
);
} | tests rendering the body of one section
@throws ReflectionException
@throws InvalidArgumentException
@throws Exception
@throws JsonException | testRenderSectionBodyIfNotSilentWithParents | php | browscap/browscap | tests/BrowscapTest/Writer/JsonWriterTest.php | https://github.com/browscap/browscap/blob/master/tests/BrowscapTest/Writer/JsonWriterTest.php | MIT |
public function testRenderSectionBodyIfNotSilentWithDefaultPropertiesAsParent(): void
{
$this->object->setSilent(false);
$section = [
'Parent' => 'DefaultProperties',
'Comment' => '1',
'Win16' => true,
'Platform' => 'bcd',
];
$sections = ['X2' => $section];
$useragent = $this->getMockBuilder(UserAgent::class)
->disableOriginalConstructor()
->onlyMethods(['getProperties'])
->getMock();
$useragent
->expects(static::once())
->method('getProperties')
->willReturn([
'Comment' => '12',
'Win16' => true,
'Platform' => 'bcd',
]);
$mockExpander = $this->getMockBuilder(TrimProperty::class)
->disableOriginalConstructor()
->onlyMethods(['trim'])
->getMock();
$mockExpander
->expects(static::exactly(2))
->method('trim')
->willReturnArgument(0);
$property = new ReflectionProperty($this->object, 'trimProperty');
$property->setValue($this->object, $mockExpander);
$division = $this->getMockBuilder(Division::class)
->disableOriginalConstructor()
->onlyMethods(['getUserAgents'])
->getMock();
$division
->expects(static::once())
->method('getUserAgents')
->willReturn([0 => $useragent]);
$collection = $this->getMockBuilder(DataCollection::class)
->disableOriginalConstructor()
->onlyMethods(['getDefaultProperties'])
->getMock();
$collection
->expects(static::once())
->method('getDefaultProperties')
->willReturn($division);
$mockFormatter = $this->getMockBuilder(JsonFormatter::class)
->disableOriginalConstructor()
->onlyMethods(['formatPropertyName', 'formatPropertyValue'])
->getMock();
$mockFormatter
->expects(static::never())
->method('formatPropertyName')
->willReturnArgument(0);
$mockFormatter
->expects(static::once())
->method('formatPropertyValue')
->willReturnArgument(0);
assert($mockFormatter instanceof JsonFormatter);
$this->object->setFormatter($mockFormatter);
$map = [
['Comment', $this->object, true],
['Win16', $this->object, false],
['Platform', $this->object, true],
['Parent', $this->object, true],
];
$mockFilter = $this->getMockBuilder(StandardFilter::class)
->disableOriginalConstructor()
->onlyMethods(['isOutputProperty'])
->getMock();
$mockFilter
->expects(static::exactly(4))
->method('isOutputProperty')
->willReturnMap($map);
assert($mockFilter instanceof StandardFilter);
$this->object->setFilter($mockFilter);
assert($collection instanceof DataCollection);
$this->object->renderSectionBody($section, $collection, $sections);
static::assertSame(
'{"Parent":"DefaultProperties","Comment":"1"}',
file_get_contents($this->file),
);
} | tests rendering the body of one section
@throws ReflectionException
@throws InvalidArgumentException
@throws Exception
@throws JsonException | testRenderSectionBodyIfNotSilentWithDefaultPropertiesAsParent | php | browscap/browscap | tests/BrowscapTest/Writer/JsonWriterTest.php | https://github.com/browscap/browscap/blob/master/tests/BrowscapTest/Writer/JsonWriterTest.php | MIT |
public function testRenderSectionBodyIfSilent(): void
{
$this->object->setSilent(true);
$section = [
'Test' => 1,
'isTest' => true,
'abc' => 'bcd',
];
$collection = $this->createMock(DataCollection::class);
assert($collection instanceof DataCollection);
$this->object->renderSectionBody($section, $collection);
static::assertSame('', file_get_contents($this->file));
} | tests rendering the body of one section
@throws ExpectationFailedException
@throws InvalidArgumentException
@throws Exception
@throws JsonException | testRenderSectionBodyIfSilent | php | browscap/browscap | tests/BrowscapTest/Writer/JsonWriterTest.php | https://github.com/browscap/browscap/blob/master/tests/BrowscapTest/Writer/JsonWriterTest.php | MIT |
public function testRenderSectionFooterIfNotSilent(): void
{
$this->object->setSilent(false);
$this->object->renderSectionFooter();
static::assertSame(',' . PHP_EOL, file_get_contents($this->file));
} | tests rendering the footer of one section
@throws ExpectationFailedException | testRenderSectionFooterIfNotSilent | php | browscap/browscap | tests/BrowscapTest/Writer/JsonWriterTest.php | https://github.com/browscap/browscap/blob/master/tests/BrowscapTest/Writer/JsonWriterTest.php | MIT |
public function testRenderSectionFooterIfSilent(): void
{
$this->object->setSilent(true);
$this->object->renderSectionFooter();
static::assertSame('', file_get_contents($this->file));
} | tests rendering the footer of one section
@throws ExpectationFailedException | testRenderSectionFooterIfSilent | php | browscap/browscap | tests/BrowscapTest/Writer/JsonWriterTest.php | https://github.com/browscap/browscap/blob/master/tests/BrowscapTest/Writer/JsonWriterTest.php | MIT |
public function testRenderDivisionFooter(): void
{
$this->object->renderDivisionFooter();
static::assertSame('', file_get_contents($this->file));
} | tests rendering the footer of one division
@throws ExpectationFailedException | testRenderDivisionFooter | php | browscap/browscap | tests/BrowscapTest/Writer/JsonWriterTest.php | https://github.com/browscap/browscap/blob/master/tests/BrowscapTest/Writer/JsonWriterTest.php | MIT |
public function testRenderAllDivisionsFooter(): void
{
$this->object->renderAllDivisionsFooter();
static::assertSame('', file_get_contents($this->file));
} | tests rendering the footer after all divisions
@throws ExpectationFailedException | testRenderAllDivisionsFooter | php | browscap/browscap | tests/BrowscapTest/Writer/JsonWriterTest.php | https://github.com/browscap/browscap/blob/master/tests/BrowscapTest/Writer/JsonWriterTest.php | MIT |
public function testAddWriterAndSetSilent(): void
{
$division = $this->createMock(Division::class);
$mockFilter = $this->createMock(FilterInterface::class);
$mockFilter
->expects(static::once())
->method('isOutput')
->with($division)
->willReturn(true);
$mockWriter = $this->createMock(WriterInterface::class);
$mockWriter
->expects(static::once())
->method('getFilter')
->willReturn($mockFilter);
$mockWriter
->expects(static::once())
->method('setSilent')
->with(false);
$this->object->addWriter($mockWriter);
$this->object->setSilent($division);
} | tests setting and getting a writer
@throws MethodNameAlreadyConfiguredException
@throws MethodCannotBeConfiguredException | testAddWriterAndSetSilent | php | browscap/browscap | tests/BrowscapTest/Writer/WriterCollectionTest.php | https://github.com/browscap/browscap/blob/master/tests/BrowscapTest/Writer/WriterCollectionTest.php | MIT |
public function testSetSilentSection(): void
{
$section = [];
$mockFilter = $this->createMock(FilterInterface::class);
$mockFilter
->expects(static::once())
->method('isOutputSection')
->with($section)
->willReturn(true);
$mockWriter = $this->createMock(WriterInterface::class);
$mockWriter
->expects(static::once())
->method('getFilter')
->willReturn($mockFilter);
$mockWriter
->expects(static::once())
->method('setSilent')
->with(false);
$this->object->addWriter($mockWriter);
$this->object->setSilentSection($section);
} | tests setting a file into silent mode
@throws MethodNameAlreadyConfiguredException
@throws MethodCannotBeConfiguredException | testSetSilentSection | php | browscap/browscap | tests/BrowscapTest/Writer/WriterCollectionTest.php | https://github.com/browscap/browscap/blob/master/tests/BrowscapTest/Writer/WriterCollectionTest.php | MIT |
public function testFileStart(): void
{
$mockWriter = $this->createMock(WriterInterface::class);
$mockWriter
->expects(static::once())
->method('fileStart');
$this->object->addWriter($mockWriter);
$this->object->fileStart();
} | tests rendering the start of the file
@throws MethodNameAlreadyConfiguredException
@throws MethodCannotBeConfiguredException | testFileStart | php | browscap/browscap | tests/BrowscapTest/Writer/WriterCollectionTest.php | https://github.com/browscap/browscap/blob/master/tests/BrowscapTest/Writer/WriterCollectionTest.php | MIT |
public function testFileEnd(): void
{
$mockWriter = $this->createMock(WriterInterface::class);
$mockWriter
->expects(static::once())
->method('fileEnd');
$this->object->addWriter($mockWriter);
$this->object->fileEnd();
} | tests rendering the end of the file
@throws MethodNameAlreadyConfiguredException
@throws MethodCannotBeConfiguredException | testFileEnd | php | browscap/browscap | tests/BrowscapTest/Writer/WriterCollectionTest.php | https://github.com/browscap/browscap/blob/master/tests/BrowscapTest/Writer/WriterCollectionTest.php | MIT |
public function testRenderHeader(): void
{
$header = ['TestData to be renderd into the Header'];
$mockWriter = $this->createMock(WriterInterface::class);
$mockWriter
->expects(static::once())
->method('renderHeader')
->with($header);
$this->object->addWriter($mockWriter);
$this->object->renderHeader($header);
} | tests rendering the header information
@throws MethodNameAlreadyConfiguredException
@throws MethodCannotBeConfiguredException
@throws JsonException | testRenderHeader | php | browscap/browscap | tests/BrowscapTest/Writer/WriterCollectionTest.php | https://github.com/browscap/browscap/blob/master/tests/BrowscapTest/Writer/WriterCollectionTest.php | MIT |
public function testRenderVersion(): void
{
$version = 'test';
$formatterType = 'test';
$filterType = 'Test';
$date = new DateTimeImmutable();
$collection = $this->createMock(DataCollection::class);
$mockFilter = $this->createMock(FilterInterface::class);
$mockFilter
->expects(static::never())
->method('isOutput')
->willReturn(true);
$mockFilter
->expects(static::once())
->method('getType')
->willReturn($filterType);
$mockFormatter = $this->createMock(FormatterInterface::class);
$mockFormatter
->expects(static::once())
->method('getType')
->willReturn($formatterType);
$mockWriter = $this->createMock(WriterInterface::class);
$mockWriter
->expects(static::once())
->method('getFilter')
->willReturn($mockFilter);
$mockWriter
->expects(static::once())
->method('getFormatter')
->willReturn($mockFormatter);
$mockWriter
->expects(static::once())
->method('renderVersion')
->with(
[
'version' => $version,
'released' => $date->format('r'),
'format' => $formatterType,
'type' => $filterType,
],
);
$this->object->addWriter($mockWriter);
assert($collection instanceof DataCollection);
$this->object->renderVersion($version, $date, $collection);
$this->object->close();
} | tests rendering the version information
@throws Exception
@throws JsonException | testRenderVersion | php | browscap/browscap | tests/BrowscapTest/Writer/WriterCollectionTest.php | https://github.com/browscap/browscap/blob/master/tests/BrowscapTest/Writer/WriterCollectionTest.php | MIT |
public function testRenderAllDivisionsHeader(): void
{
$collection = $this->createMock(DataCollection::class);
$mockWriter = $this->createMock(WriterInterface::class);
$mockWriter
->expects(static::once())
->method('renderAllDivisionsHeader')
->with($collection);
$this->object->addWriter($mockWriter);
$this->object->renderAllDivisionsHeader($collection);
} | tests rendering the header for all division
@throws MethodNameAlreadyConfiguredException
@throws MethodCannotBeConfiguredException | testRenderAllDivisionsHeader | php | browscap/browscap | tests/BrowscapTest/Writer/WriterCollectionTest.php | https://github.com/browscap/browscap/blob/master/tests/BrowscapTest/Writer/WriterCollectionTest.php | MIT |
public function testRenderDivisionHeader(): void
{
$division = 'test';
$parent = 'test-parent';
$mockWriter = $this->createMock(WriterInterface::class);
$mockWriter
->expects(static::once())
->method('renderDivisionHeader')
->with($division, $parent);
$this->object->addWriter($mockWriter);
$this->object->renderDivisionHeader($division, $parent);
} | tests rendering the header of one division
@throws MethodNameAlreadyConfiguredException
@throws MethodCannotBeConfiguredException | testRenderDivisionHeader | php | browscap/browscap | tests/BrowscapTest/Writer/WriterCollectionTest.php | https://github.com/browscap/browscap/blob/master/tests/BrowscapTest/Writer/WriterCollectionTest.php | MIT |
public function testRenderSectionHeader(): void
{
$section = 'test';
$mockWriter = $this->createMock(WriterInterface::class);
$mockWriter
->expects(static::once())
->method('renderSectionHeader')
->with($section);
$this->object->addWriter($mockWriter);
$this->object->renderSectionHeader($section);
} | tests rendering the header of one section
@throws MethodNameAlreadyConfiguredException
@throws MethodCannotBeConfiguredException | testRenderSectionHeader | php | browscap/browscap | tests/BrowscapTest/Writer/WriterCollectionTest.php | https://github.com/browscap/browscap/blob/master/tests/BrowscapTest/Writer/WriterCollectionTest.php | MIT |
public function testRenderSectionBody(): void
{
$section = [
'Comment' => 1,
'Win16' => true,
'Platform' => 'bcd',
];
$collection = $this->createMock(DataCollection::class);
$mockWriter = $this->createMock(WriterInterface::class);
$mockWriter
->expects(static::once())
->method('renderSectionBody')
->with($section, $collection);
$this->object->addWriter($mockWriter);
$this->object->renderSectionBody($section, $collection);
} | tests rendering the body of one section
@throws InvalidArgumentException | testRenderSectionBody | php | browscap/browscap | tests/BrowscapTest/Writer/WriterCollectionTest.php | https://github.com/browscap/browscap/blob/master/tests/BrowscapTest/Writer/WriterCollectionTest.php | MIT |
public function testRenderSectionFooter(): void
{
$sectionName = 'test';
$mockWriter = $this->createMock(WriterInterface::class);
$mockWriter
->expects(static::once())
->method('renderSectionFooter')
->with($sectionName);
$this->object->addWriter($mockWriter);
$this->object->renderSectionFooter($sectionName);
} | tests rendering the footer of one section
@throws MethodNameAlreadyConfiguredException
@throws MethodCannotBeConfiguredException | testRenderSectionFooter | php | browscap/browscap | tests/BrowscapTest/Writer/WriterCollectionTest.php | https://github.com/browscap/browscap/blob/master/tests/BrowscapTest/Writer/WriterCollectionTest.php | MIT |
public function testRenderDivisionFooter(): void
{
$mockWriter = $this->createMock(WriterInterface::class);
$mockWriter
->expects(static::once())
->method('renderDivisionFooter');
$this->object->addWriter($mockWriter);
$this->object->renderDivisionFooter();
} | tests rendering the footer of one division
@throws MethodNameAlreadyConfiguredException
@throws MethodCannotBeConfiguredException | testRenderDivisionFooter | php | browscap/browscap | tests/BrowscapTest/Writer/WriterCollectionTest.php | https://github.com/browscap/browscap/blob/master/tests/BrowscapTest/Writer/WriterCollectionTest.php | MIT |
public function testRenderAllDivisionsFooter(): void
{
$mockWriter = $this->createMock(WriterInterface::class);
$mockWriter
->expects(static::once())
->method('renderAllDivisionsFooter');
$this->object->addWriter($mockWriter);
$this->object->renderAllDivisionsFooter();
} | tests rendering the footer after all divisions
@throws MethodNameAlreadyConfiguredException
@throws MethodCannotBeConfiguredException
@throws \PHPUnit\Framework\InvalidArgumentException | testRenderAllDivisionsFooter | php | browscap/browscap | tests/BrowscapTest/Writer/WriterCollectionTest.php | https://github.com/browscap/browscap/blob/master/tests/BrowscapTest/Writer/WriterCollectionTest.php | MIT |
public function testGetType(): void
{
static::assertSame(WriterInterface::TYPE_XML, $this->object->getType());
} | tests getting the writer type
@throws ExpectationFailedException | testGetType | php | browscap/browscap | tests/BrowscapTest/Writer/XmlWriterTest.php | https://github.com/browscap/browscap/blob/master/tests/BrowscapTest/Writer/XmlWriterTest.php | MIT |
public function testSetGetFormatter(): void
{
$mockFormatter = $this->createMock(XmlFormatter::class);
$this->object->setFormatter($mockFormatter);
static::assertSame($mockFormatter, $this->object->getFormatter());
} | tests setting and getting a formatter
@throws ExpectationFailedException | testSetGetFormatter | php | browscap/browscap | tests/BrowscapTest/Writer/XmlWriterTest.php | https://github.com/browscap/browscap/blob/master/tests/BrowscapTest/Writer/XmlWriterTest.php | MIT |
public function testSetGetFilter(): void
{
$mockFilter = $this->createMock(FullFilter::class);
$this->object->setFilter($mockFilter);
static::assertSame($mockFilter, $this->object->getFilter());
} | tests setting and getting a filter
@throws ExpectationFailedException | testSetGetFilter | php | browscap/browscap | tests/BrowscapTest/Writer/XmlWriterTest.php | https://github.com/browscap/browscap/blob/master/tests/BrowscapTest/Writer/XmlWriterTest.php | MIT |
public function testSetGetSilent(): void
{
$this->object->setSilent(true);
static::assertTrue($this->object->isSilent());
} | tests setting a file into silent mode
@throws ExpectationFailedException | testSetGetSilent | php | browscap/browscap | tests/BrowscapTest/Writer/XmlWriterTest.php | https://github.com/browscap/browscap/blob/master/tests/BrowscapTest/Writer/XmlWriterTest.php | MIT |
public function testFileStartIfNotSilent(): void
{
$this->object->setSilent(false);
$this->object->fileStart();
static::assertSame(
'<?xml version="1.0" encoding="UTF-8"?>' . PHP_EOL . '<browsercaps>' . PHP_EOL,
file_get_contents($this->file),
);
} | tests rendering the start of the file
@throws ExpectationFailedException | testFileStartIfNotSilent | php | browscap/browscap | tests/BrowscapTest/Writer/XmlWriterTest.php | https://github.com/browscap/browscap/blob/master/tests/BrowscapTest/Writer/XmlWriterTest.php | MIT |
public function testFileStartIfSilent(): void
{
$this->object->setSilent(true);
$this->object->fileStart();
static::assertSame('', file_get_contents($this->file));
} | tests rendering the start of the file
@throws ExpectationFailedException | testFileStartIfSilent | php | browscap/browscap | tests/BrowscapTest/Writer/XmlWriterTest.php | https://github.com/browscap/browscap/blob/master/tests/BrowscapTest/Writer/XmlWriterTest.php | MIT |
public function testFileEndIfNotSilent(): void
{
$this->object->setSilent(false);
$this->object->fileEnd();
static::assertSame('</browsercaps>' . PHP_EOL, file_get_contents($this->file));
} | tests rendering the end of the file
@throws ExpectationFailedException | testFileEndIfNotSilent | php | browscap/browscap | tests/BrowscapTest/Writer/XmlWriterTest.php | https://github.com/browscap/browscap/blob/master/tests/BrowscapTest/Writer/XmlWriterTest.php | MIT |
public function testFileEndIfSilent(): void
{
$this->object->setSilent(true);
$this->object->fileEnd();
static::assertSame('', file_get_contents($this->file));
} | tests rendering the end of the file
@throws ExpectationFailedException | testFileEndIfSilent | php | browscap/browscap | tests/BrowscapTest/Writer/XmlWriterTest.php | https://github.com/browscap/browscap/blob/master/tests/BrowscapTest/Writer/XmlWriterTest.php | MIT |
public function testRenderHeaderIfSilent(): void
{
$header = ['TestData to be renderd into the Header'];
$this->object->setSilent(true);
$this->object->renderHeader($header);
static::assertSame('', file_get_contents($this->file));
} | tests rendering the header information
@throws ExpectationFailedException | testRenderHeaderIfSilent | php | browscap/browscap | tests/BrowscapTest/Writer/XmlWriterTest.php | https://github.com/browscap/browscap/blob/master/tests/BrowscapTest/Writer/XmlWriterTest.php | MIT |
public function testRenderHeaderIfNotSilent(): void
{
$header = ['TestData to be renderd into the Header'];
$this->object->setSilent(false);
$this->object->renderHeader($header);
static::assertSame(
'<comments>' . PHP_EOL . '<comment><![CDATA[TestData to be renderd into the Header]]></comment>' . PHP_EOL
. '</comments>' . PHP_EOL,
file_get_contents($this->file),
);
} | tests rendering the header information
@throws ExpectationFailedException | testRenderHeaderIfNotSilent | php | browscap/browscap | tests/BrowscapTest/Writer/XmlWriterTest.php | https://github.com/browscap/browscap/blob/master/tests/BrowscapTest/Writer/XmlWriterTest.php | MIT |
public function testRenderVersionIfSilent(): void
{
$version = [
'version' => 'test',
'released' => date('Y-m-d'),
'format' => 'TEST',
'type' => 'full',
];
$this->object->setSilent(true);
$this->object->renderVersion($version);
static::assertSame('', file_get_contents($this->file));
} | tests rendering the version information
@throws ExpectationFailedException
@throws JsonException | testRenderVersionIfSilent | php | browscap/browscap | tests/BrowscapTest/Writer/XmlWriterTest.php | https://github.com/browscap/browscap/blob/master/tests/BrowscapTest/Writer/XmlWriterTest.php | MIT |
public function testRenderVersionIfNotSilent(): void
{
$version = [
'version' => 'test',
'released' => date('Y-m-d'),
'format' => 'TEST',
'type' => 'full',
];
$this->object->setSilent(false);
$mockFormatter = $this->getMockBuilder(XmlFormatter::class)
->disableOriginalConstructor()
->onlyMethods(['formatPropertyName'])
->getMock();
$mockFormatter
->expects(static::exactly(2))
->method('formatPropertyName')
->willReturn('test');
assert($mockFormatter instanceof XmlFormatter);
$this->object->setFormatter($mockFormatter);
$this->object->renderVersion($version);
static::assertSame(
'<gjk_browscap_version>' . PHP_EOL . '<item name="Version" value="test"/>' . PHP_EOL
. '<item name="Released" value="test"/>' . PHP_EOL . '</gjk_browscap_version>' . PHP_EOL,
file_get_contents($this->file),
);
} | tests rendering the version information
@throws ExpectationFailedException
@throws JsonException | testRenderVersionIfNotSilent | php | browscap/browscap | tests/BrowscapTest/Writer/XmlWriterTest.php | https://github.com/browscap/browscap/blob/master/tests/BrowscapTest/Writer/XmlWriterTest.php | MIT |
public function testRenderVersionIfNotSilentButWithoutVersion(): void
{
$version = [];
$this->object->setSilent(false);
$mockFormatter = $this->getMockBuilder(XmlFormatter::class)
->disableOriginalConstructor()
->onlyMethods(['formatPropertyName'])
->getMock();
$mockFormatter
->expects(static::exactly(2))
->method('formatPropertyName')
->willReturn('test');
assert($mockFormatter instanceof XmlFormatter);
$this->object->setFormatter($mockFormatter);
$this->object->renderVersion($version);
static::assertSame(
'<gjk_browscap_version>' . PHP_EOL . '<item name="Version" value="test"/>' . PHP_EOL
. '<item name="Released" value="test"/>' . PHP_EOL . '</gjk_browscap_version>' . PHP_EOL,
file_get_contents($this->file),
);
} | tests rendering the version information
@throws ExpectationFailedException
@throws JsonException | testRenderVersionIfNotSilentButWithoutVersion | php | browscap/browscap | tests/BrowscapTest/Writer/XmlWriterTest.php | https://github.com/browscap/browscap/blob/master/tests/BrowscapTest/Writer/XmlWriterTest.php | MIT |
public function testRenderAllDivisionsHeader(): void
{
$collection = $this->createMock(DataCollection::class);
assert($collection instanceof DataCollection);
$this->object->renderAllDivisionsHeader($collection);
static::assertSame('<browsercapitems>' . PHP_EOL, file_get_contents($this->file));
} | tests rendering the header for all division
@throws ExpectationFailedException | testRenderAllDivisionsHeader | php | browscap/browscap | tests/BrowscapTest/Writer/XmlWriterTest.php | https://github.com/browscap/browscap/blob/master/tests/BrowscapTest/Writer/XmlWriterTest.php | MIT |
public function testRenderDivisionHeader(): void
{
$this->object->setSilent(true);
$this->object->renderDivisionHeader('test');
static::assertSame('', file_get_contents($this->file));
} | tests rendering the header of one division
@throws ExpectationFailedException | testRenderDivisionHeader | php | browscap/browscap | tests/BrowscapTest/Writer/XmlWriterTest.php | https://github.com/browscap/browscap/blob/master/tests/BrowscapTest/Writer/XmlWriterTest.php | MIT |
public function testRenderSectionHeaderIfNotSilent(): void
{
$this->object->setSilent(false);
$mockFormatter = $this->getMockBuilder(XmlFormatter::class)
->disableOriginalConstructor()
->onlyMethods(['formatPropertyName'])
->getMock();
$mockFormatter
->expects(static::once())
->method('formatPropertyName')
->willReturn('test');
assert($mockFormatter instanceof XmlFormatter);
$this->object->setFormatter($mockFormatter);
$this->object->renderSectionHeader('test');
static::assertSame('<browscapitem name="test">' . PHP_EOL, file_get_contents($this->file));
} | tests rendering the header of one section
@throws ExpectationFailedException
@throws JsonException | testRenderSectionHeaderIfNotSilent | php | browscap/browscap | tests/BrowscapTest/Writer/XmlWriterTest.php | https://github.com/browscap/browscap/blob/master/tests/BrowscapTest/Writer/XmlWriterTest.php | MIT |
public function testRenderSectionHeaderIfSilent(): void
{
$this->object->setSilent(true);
$this->object->renderSectionHeader('test');
static::assertSame('', file_get_contents($this->file));
} | tests rendering the header of one section
@throws ExpectationFailedException
@throws JsonException | testRenderSectionHeaderIfSilent | php | browscap/browscap | tests/BrowscapTest/Writer/XmlWriterTest.php | https://github.com/browscap/browscap/blob/master/tests/BrowscapTest/Writer/XmlWriterTest.php | MIT |
public function testRenderSectionBodyIfNotSilent(): void
{
$this->object->setSilent(false);
$section = [
'Test' => 1,
'isTest' => true,
'abc' => 'bcd',
];
$useragent = $this->getMockBuilder(UserAgent::class)
->disableOriginalConstructor()
->onlyMethods(['getProperties'])
->getMock();
$useragent
->expects(static::once())
->method('getProperties')
->willReturn([
'Test' => 'abc',
'abc' => true,
]);
$division = $this->getMockBuilder(Division::class)
->disableOriginalConstructor()
->onlyMethods(['getUserAgents'])
->getMock();
$division
->expects(static::once())
->method('getUserAgents')
->willReturn([0 => $useragent]);
$collection = $this->getMockBuilder(DataCollection::class)
->disableOriginalConstructor()
->onlyMethods(['getDefaultProperties'])
->getMock();
$collection
->expects(static::once())
->method('getDefaultProperties')
->willReturn($division);
$mockFormatter = $this->getMockBuilder(XmlFormatter::class)
->disableOriginalConstructor()
->onlyMethods(['formatPropertyName', 'formatPropertyValue'])
->getMock();
$map1a = [
['Test', 'Test'],
['abc', 'abc'],
];
$map1b = [
[1, 'Test', '1'],
['bcd', 'abc', 'bcd'],
];
$mockFormatter
->expects(static::exactly(2))
->method('formatPropertyName')
->willReturnMap($map1a);
$mockFormatter
->expects(static::exactly(2))
->method('formatPropertyValue')
->willReturnMap($map1b);
assert($mockFormatter instanceof XmlFormatter);
$this->object->setFormatter($mockFormatter);
$mockFilter = $this->getMockBuilder(FullFilter::class)
->disableOriginalConstructor()
->onlyMethods(['isOutputProperty'])
->getMock();
$map2 = [
['Test', $this->object, true],
['isTest', $this->object, false],
['abc', $this->object, true],
];
$mockFilter
->expects(static::exactly(2))
->method('isOutputProperty')
->willReturnMap($map2);
assert($mockFilter instanceof FullFilter);
$this->object->setFilter($mockFilter);
assert($collection instanceof DataCollection);
$this->object->renderSectionBody($section, $collection);
static::assertSame(
'<item name="Test" value="1"/>' . PHP_EOL . '<item name="abc" value="bcd"/>' . PHP_EOL,
file_get_contents($this->file),
);
} | tests rendering the body of one section
@throws ExpectationFailedException
@throws InvalidArgumentException
@throws JsonException
@throws Exception | testRenderSectionBodyIfNotSilent | php | browscap/browscap | tests/BrowscapTest/Writer/XmlWriterTest.php | https://github.com/browscap/browscap/blob/master/tests/BrowscapTest/Writer/XmlWriterTest.php | MIT |
public function testRenderSectionBodyIfNotSilentWithParents(): void
{
$this->object->setSilent(false);
$section = [
'Parent' => 'X1',
'Comment' => '1',
'Win16' => true,
'Platform' => 'bcd',
];
$sections = [
'X1' => [
'Comment' => '12',
'Win16' => false,
'Platform' => 'bcd',
],
'X2' => $section,
];
$useragent = $this->getMockBuilder(UserAgent::class)
->disableOriginalConstructor()
->onlyMethods(['getProperties'])
->getMock();
$useragent
->expects(static::once())
->method('getProperties')
->willReturn([
'Comment' => 1,
'Win16' => true,
'Platform' => 'bcd',
]);
$division = $this->getMockBuilder(Division::class)
->disableOriginalConstructor()
->onlyMethods(['getUserAgents'])
->getMock();
$division
->expects(static::once())
->method('getUserAgents')
->willReturn([0 => $useragent]);
$collection = $this->getMockBuilder(DataCollection::class)
->disableOriginalConstructor()
->onlyMethods(['getDefaultProperties'])
->getMock();
$collection
->expects(static::once())
->method('getDefaultProperties')
->willReturn($division);
$propertyHolder = $this->createMock(PropertyHolder::class);
$mockFormatter = $this->getMockBuilder(XmlFormatter::class)
->setConstructorArgs([$propertyHolder])
->onlyMethods(['formatPropertyName'])
->getMock();
$mockFormatter
->expects(static::exactly(3))
->method('formatPropertyName')
->willReturnArgument(0);
assert($mockFormatter instanceof XmlFormatter);
$this->object->setFormatter($mockFormatter);
$map = [
['Comment', $this->object, true],
['Win16', $this->object, false],
['Platform', $this->object, true],
['Parent', $this->object, true],
];
$mockFilter = $this->getMockBuilder(StandardFilter::class)
->setConstructorArgs([$propertyHolder])
->onlyMethods(['isOutputProperty'])
->getMock();
$mockFilter
->expects(static::exactly(4))
->method('isOutputProperty')
->willReturnMap($map);
assert($mockFilter instanceof StandardFilter);
$this->object->setFilter($mockFilter);
assert($collection instanceof DataCollection);
$this->object->renderSectionBody($section, $collection, $sections);
static::assertSame(
'<item name="Parent" value="X1"/>' . PHP_EOL . '<item name="Comment" value="1"/>' . PHP_EOL
. '<item name="Platform" value="bcd"/>' . PHP_EOL,
file_get_contents($this->file),
);
} | tests rendering the body of one section
@throws ExpectationFailedException
@throws InvalidArgumentException
@throws JsonException
@throws Exception | testRenderSectionBodyIfNotSilentWithParents | php | browscap/browscap | tests/BrowscapTest/Writer/XmlWriterTest.php | https://github.com/browscap/browscap/blob/master/tests/BrowscapTest/Writer/XmlWriterTest.php | MIT |
public function testRenderSectionBodyIfNotSilentWithDefaultPropertiesAsParent(): void
{
$this->object->setSilent(false);
$section = [
'Parent' => 'DefaultProperties',
'Comment' => '1',
'Win16' => true,
'Platform' => 'bcd',
];
$sections = ['X2' => $section];
$useragent = $this->getMockBuilder(UserAgent::class)
->disableOriginalConstructor()
->onlyMethods(['getProperties'])
->getMock();
$useragent
->expects(static::once())
->method('getProperties')
->willReturn([
'Comment' => '12',
'Win16' => true,
'Platform' => 'bcd',
]);
$division = $this->getMockBuilder(Division::class)
->disableOriginalConstructor()
->onlyMethods(['getUserAgents'])
->getMock();
$division
->expects(static::once())
->method('getUserAgents')
->willReturn([0 => $useragent]);
$collection = $this->getMockBuilder(DataCollection::class)
->disableOriginalConstructor()
->onlyMethods(['getDefaultProperties'])
->getMock();
$collection
->expects(static::once())
->method('getDefaultProperties')
->willReturn($division);
$propertyHolder = $this->createMock(PropertyHolder::class);
$mockFormatter = $this->getMockBuilder(XmlFormatter::class)
->setConstructorArgs([$propertyHolder])
->onlyMethods(['formatPropertyName'])
->getMock();
$mockFormatter
->expects(static::exactly(3))
->method('formatPropertyName')
->willReturnArgument(0);
assert($mockFormatter instanceof XmlFormatter);
$this->object->setFormatter($mockFormatter);
$map = [
['Comment', $this->object, true],
['Win16', $this->object, false],
['Platform', $this->object, true],
['Parent', $this->object, true],
];
$mockFilter = $this->getMockBuilder(StandardFilter::class)
->setConstructorArgs([$propertyHolder])
->onlyMethods(['isOutputProperty'])
->getMock();
$mockFilter
->expects(static::exactly(4))
->method('isOutputProperty')
->willReturnMap($map);
assert($mockFilter instanceof StandardFilter);
$this->object->setFilter($mockFilter);
assert($collection instanceof DataCollection);
$this->object->renderSectionBody($section, $collection, $sections);
static::assertSame(
'<item name="Parent" value="DefaultProperties"/>' . PHP_EOL . '<item name="Comment" value="1"/>' . PHP_EOL
. '<item name="Platform" value="bcd"/>' . PHP_EOL,
file_get_contents($this->file),
);
} | tests rendering the body of one section
@throws ExpectationFailedException
@throws InvalidArgumentException
@throws JsonException
@throws Exception | testRenderSectionBodyIfNotSilentWithDefaultPropertiesAsParent | php | browscap/browscap | tests/BrowscapTest/Writer/XmlWriterTest.php | https://github.com/browscap/browscap/blob/master/tests/BrowscapTest/Writer/XmlWriterTest.php | MIT |
public function testRenderSectionBodyIfSilent(): void
{
$this->object->setSilent(true);
$section = [
'Test' => 1,
'isTest' => true,
'abc' => 'bcd',
];
$collection = $this->createMock(DataCollection::class);
assert($collection instanceof DataCollection);
$this->object->renderSectionBody($section, $collection);
static::assertSame('', file_get_contents($this->file));
} | tests rendering the body of one section
@throws InvalidArgumentException
@throws JsonException
@throws Exception | testRenderSectionBodyIfSilent | php | browscap/browscap | tests/BrowscapTest/Writer/XmlWriterTest.php | https://github.com/browscap/browscap/blob/master/tests/BrowscapTest/Writer/XmlWriterTest.php | MIT |
public function testRenderSectionFooterIfNotSilent(): void
{
$this->object->setSilent(false);
$this->object->renderSectionFooter();
static::assertSame('</browscapitem>' . PHP_EOL, file_get_contents($this->file));
} | tests rendering the footer of one section
@throws ExpectationFailedException | testRenderSectionFooterIfNotSilent | php | browscap/browscap | tests/BrowscapTest/Writer/XmlWriterTest.php | https://github.com/browscap/browscap/blob/master/tests/BrowscapTest/Writer/XmlWriterTest.php | MIT |
public function testRenderSectionFooterIfSilent(): void
{
$this->object->setSilent(true);
$this->object->renderSectionFooter();
static::assertSame('', file_get_contents($this->file));
} | tests rendering the footer of one section
@throws ExpectationFailedException | testRenderSectionFooterIfSilent | php | browscap/browscap | tests/BrowscapTest/Writer/XmlWriterTest.php | https://github.com/browscap/browscap/blob/master/tests/BrowscapTest/Writer/XmlWriterTest.php | MIT |
public function testRenderDivisionFooter(): void
{
$this->object->renderDivisionFooter();
static::assertSame('', file_get_contents($this->file));
} | tests rendering the footer of one division
@throws ExpectationFailedException | testRenderDivisionFooter | php | browscap/browscap | tests/BrowscapTest/Writer/XmlWriterTest.php | https://github.com/browscap/browscap/blob/master/tests/BrowscapTest/Writer/XmlWriterTest.php | MIT |
public function testRenderAllDivisionsFooter(): void
{
$this->object->renderAllDivisionsFooter();
static::assertSame('</browsercapitems>' . PHP_EOL, file_get_contents($this->file));
} | tests rendering the footer after all divisions
@throws ExpectationFailedException | testRenderAllDivisionsFooter | php | browscap/browscap | tests/BrowscapTest/Writer/XmlWriterTest.php | https://github.com/browscap/browscap/blob/master/tests/BrowscapTest/Writer/XmlWriterTest.php | MIT |
public function testCreateCollectionWithDefaultParams(): void
{
$logger = $this->createMock(LoggerInterface::class);
$dir = vfsStream::url(self::STORAGE_DIR);
assert($logger instanceof LoggerInterface);
static::assertInstanceOf(WriterCollection::class, $this->object->createCollection($logger, $dir));
} | tests creating a writer collection
@throws Exception
@throws InvalidArgumentException | testCreateCollectionWithDefaultParams | php | browscap/browscap | tests/BrowscapTest/Writer/Factory/CustomWriterFactoryTest.php | https://github.com/browscap/browscap/blob/master/tests/BrowscapTest/Writer/Factory/CustomWriterFactoryTest.php | MIT |
public function testCreateCollectionForCsvFile(): void
{
$logger = $this->createMock(LoggerInterface::class);
$dir = vfsStream::url(self::STORAGE_DIR);
assert($logger instanceof LoggerInterface);
static::assertInstanceOf(WriterCollection::class, $this->object->createCollection($logger, $dir, null, [], FormatterInterface::TYPE_CSV));
} | tests creating a writer collection
@throws Exception
@throws InvalidArgumentException | testCreateCollectionForCsvFile | php | browscap/browscap | tests/BrowscapTest/Writer/Factory/CustomWriterFactoryTest.php | https://github.com/browscap/browscap/blob/master/tests/BrowscapTest/Writer/Factory/CustomWriterFactoryTest.php | MIT |
public function testCreateCollectionForAspFile(): void
{
$logger = $this->createMock(LoggerInterface::class);
$dir = vfsStream::url(self::STORAGE_DIR);
assert($logger instanceof LoggerInterface);
static::assertInstanceOf(WriterCollection::class, $this->object->createCollection($logger, $dir, null, [], FormatterInterface::TYPE_ASP));
} | tests creating a writer collection
@throws Exception
@throws InvalidArgumentException | testCreateCollectionForAspFile | php | browscap/browscap | tests/BrowscapTest/Writer/Factory/CustomWriterFactoryTest.php | https://github.com/browscap/browscap/blob/master/tests/BrowscapTest/Writer/Factory/CustomWriterFactoryTest.php | MIT |
public function testCreateCollectionForXmlFile(): void
{
$logger = $this->createMock(LoggerInterface::class);
$dir = vfsStream::url(self::STORAGE_DIR);
assert($logger instanceof LoggerInterface);
static::assertInstanceOf(WriterCollection::class, $this->object->createCollection($logger, $dir, null, [], FormatterInterface::TYPE_XML));
} | tests creating a writer collection
@throws Exception
@throws InvalidArgumentException | testCreateCollectionForXmlFile | php | browscap/browscap | tests/BrowscapTest/Writer/Factory/CustomWriterFactoryTest.php | https://github.com/browscap/browscap/blob/master/tests/BrowscapTest/Writer/Factory/CustomWriterFactoryTest.php | MIT |
public function testCreateCollectionForJsonFile(): void
{
$logger = $this->createMock(LoggerInterface::class);
$dir = vfsStream::url(self::STORAGE_DIR);
assert($logger instanceof LoggerInterface);
static::assertInstanceOf(WriterCollection::class, $this->object->createCollection($logger, $dir, null, [], FormatterInterface::TYPE_JSON));
} | tests creating a writer collection
@throws Exception
@throws InvalidArgumentException | testCreateCollectionForJsonFile | php | browscap/browscap | tests/BrowscapTest/Writer/Factory/CustomWriterFactoryTest.php | https://github.com/browscap/browscap/blob/master/tests/BrowscapTest/Writer/Factory/CustomWriterFactoryTest.php | MIT |
public function testCreateCollectionForPhpFile(): void
{
$logger = $this->createMock(LoggerInterface::class);
$dir = vfsStream::url(self::STORAGE_DIR);
assert($logger instanceof LoggerInterface);
static::assertInstanceOf(WriterCollection::class, $this->object->createCollection($logger, $dir, null, [], FormatterInterface::TYPE_PHP));
} | tests creating a writer collection
@throws Exception
@throws InvalidArgumentException | testCreateCollectionForPhpFile | php | browscap/browscap | tests/BrowscapTest/Writer/Factory/CustomWriterFactoryTest.php | https://github.com/browscap/browscap/blob/master/tests/BrowscapTest/Writer/Factory/CustomWriterFactoryTest.php | MIT |
public function testCreateCollection(): void
{
$logger = $this->createMock(LoggerInterface::class);
$dir = vfsStream::url(self::STORAGE_DIR);
assert($logger instanceof LoggerInterface);
static::assertInstanceOf(WriterCollection::class, $this->object->createCollection($logger, $dir));
} | tests creating a writer collection
@throws Exception
@throws InvalidArgumentException | testCreateCollection | php | browscap/browscap | tests/BrowscapTest/Writer/Factory/FullCollectionFactoryTest.php | https://github.com/browscap/browscap/blob/master/tests/BrowscapTest/Writer/Factory/FullCollectionFactoryTest.php | MIT |
public function testCreateCollection(): void
{
$logger = $this->createMock(LoggerInterface::class);
$dir = vfsStream::url(self::STORAGE_DIR);
assert($logger instanceof LoggerInterface);
static::assertInstanceOf(WriterCollection::class, $this->object->createCollection($logger, $dir));
} | tests creating a writer collection
@throws Exception
@throws InvalidArgumentException | testCreateCollection | php | browscap/browscap | tests/BrowscapTest/Writer/Factory/FullPhpWriterFactoryTest.php | https://github.com/browscap/browscap/blob/master/tests/BrowscapTest/Writer/Factory/FullPhpWriterFactoryTest.php | MIT |
public function testCreateCollection(): void
{
$logger = $this->createMock(LoggerInterface::class);
$dir = vfsStream::url(self::STORAGE_DIR);
assert($logger instanceof LoggerInterface);
static::assertInstanceOf(WriterCollection::class, $this->object->createCollection($logger, $dir));
} | tests creating a writer collection
@throws Exception
@throws InvalidArgumentException | testCreateCollection | php | browscap/browscap | tests/BrowscapTest/Writer/Factory/PhpWriterFactoryTest.php | https://github.com/browscap/browscap/blob/master/tests/BrowscapTest/Writer/Factory/PhpWriterFactoryTest.php | MIT |
public function log($level, $message, array $context = []): void
{
assert(is_string($level));
echo '[', $level, '] ', $message, PHP_EOL;
} | @param mixed $level
@param string $message
@param mixed[] $context
@phpcsSuppress SlevomatCodingStandard.TypeHints.ParameterTypeHint.MissingNativeTypeHint | log | php | browscap/browscap | tests/UserAgentsTest/V4/FullTest.php | https://github.com/browscap/browscap/blob/master/tests/UserAgentsTest/V4/FullTest.php | MIT |
public function debug($message, array $context = []): void
{
// do nothing here
} | @param string $message
@param mixed[] $context
@phpcsSuppress SlevomatCodingStandard.TypeHints.ParameterTypeHint.MissingNativeTypeHint | debug | php | browscap/browscap | tests/UserAgentsTest/V4/FullTest.php | https://github.com/browscap/browscap/blob/master/tests/UserAgentsTest/V4/FullTest.php | MIT |
public function info($message, array $context = []): void
{
// do nothing here
} | @param string $message
@param mixed[] $context
@phpcsSuppress SlevomatCodingStandard.TypeHints.ParameterTypeHint.MissingNativeTypeHint | info | php | browscap/browscap | tests/UserAgentsTest/V4/FullTest.php | https://github.com/browscap/browscap/blob/master/tests/UserAgentsTest/V4/FullTest.php | MIT |
public static function tearDownAfterClass(): void
{
if (empty(self::$coveredPatterns)) {
return;
}
$coverageProcessor = new Processor(__DIR__ . '/../../../resources/user-agents/');
$coverageProcessor->process(self::$coveredPatterns);
$coverageProcessor->write(__DIR__ . '/../../../coverage-full4.json');
} | Runs after the entire test suite is run. Generates a coverage report for JSON resource files if
the $coveredPatterns array isn't empty
@throws JsonException
@throws RuntimeException
@throws DirectoryNotFoundException | tearDownAfterClass | php | browscap/browscap | tests/UserAgentsTest/V4/FullTest.php | https://github.com/browscap/browscap/blob/master/tests/UserAgentsTest/V4/FullTest.php | MIT |
public static function userAgentDataProvider(): array
{
[$data, $errors] = (new IteratorHelper())->getTestFiles(new NullLogger(), 'full');
if (! empty($errors)) {
throw new RuntimeException(
'Errors occured while collecting test files' . PHP_EOL . implode(PHP_EOL, $errors),
);
}
return $data;
} | @return array<string, array<string, bool|int|string>|bool|string>
@phpstan-return array<string, array{ua: string, properties: array<string, string|int|bool>, lite: bool, standard: bool, full: bool}>
@throws RuntimeException | userAgentDataProvider | php | browscap/browscap | tests/UserAgentsTest/V4/FullTest.php | https://github.com/browscap/browscap/blob/master/tests/UserAgentsTest/V4/FullTest.php | MIT |
public function testUserAgents(string $userAgent, array $expectedProperties): void
{
if (! count($expectedProperties)) {
static::markTestSkipped('Could not run test - no properties were defined to test');
}
$actualProps = (array) self::$browscap->getBrowser($userAgent);
if (isset($actualProps['PatternId']) && is_string($actualProps['PatternId'])) {
self::$coveredPatterns[] = $actualProps['PatternId'];
}
foreach ($expectedProperties as $propName => $propValue) {
if (! is_string($propName) || ! self::$filter->isOutputProperty($propName, self::$writer)) {
continue;
}
assert(array_key_exists('browser_name_pattern', $actualProps) && is_scalar($actualProps['browser_name_pattern']));
static::assertFalse(
self::$propertyHolder->isDeprecatedProperty($propName),
'Actual result expects to test for deprecated property "' . $propName . '"'
. '; used pattern: "' . $actualProps['browser_name_pattern'] . '")',
);
static::assertArrayHasKey(
$propName,
$actualProps,
'Actual result does not have "' . $propName . '" property'
. '; used pattern: "' . $actualProps['browser_name_pattern'] . '")',
);
assert(array_key_exists($propName, $actualProps), sprintf('Property %s does not exist', $propName));
assert(is_scalar($actualProps[$propName]), get_debug_type($actualProps[$propName]));
static::assertSame(
$propValue,
$actualProps[$propName],
'Expected actual "' . $propName . '" to be "' . $propValue . '" (was "' . $actualProps[$propName]
. '"; used pattern: "' . $actualProps['browser_name_pattern'] . '")',
);
}
} | @param array<string> $expectedProperties
@throws Exception
@throws \BrowscapPHP\Exception
@dataProvider userAgentDataProvider
@coversNothing | testUserAgents | php | browscap/browscap | tests/UserAgentsTest/V4/FullTest.php | https://github.com/browscap/browscap/blob/master/tests/UserAgentsTest/V4/FullTest.php | MIT |
public function log($level, $message, array $context = []): void
{
assert(is_string($level));
echo '[', $level, '] ', $message, PHP_EOL;
} | @param mixed $level
@param string $message
@param mixed[] $context
@phpcsSuppress SlevomatCodingStandard.TypeHints.ParameterTypeHint.MissingNativeTypeHint | log | php | browscap/browscap | tests/UserAgentsTest/V4/LiteTest.php | https://github.com/browscap/browscap/blob/master/tests/UserAgentsTest/V4/LiteTest.php | MIT |
public function debug($message, array $context = []): void
{
// do nothing here
} | @param string $message
@param mixed[] $context
@phpcsSuppress SlevomatCodingStandard.TypeHints.ParameterTypeHint.MissingNativeTypeHint | debug | php | browscap/browscap | tests/UserAgentsTest/V4/LiteTest.php | https://github.com/browscap/browscap/blob/master/tests/UserAgentsTest/V4/LiteTest.php | MIT |
public function info($message, array $context = []): void
{
// do nothing here
} | @param string $message
@param mixed[] $context
@phpcsSuppress SlevomatCodingStandard.TypeHints.ParameterTypeHint.MissingNativeTypeHint | info | php | browscap/browscap | tests/UserAgentsTest/V4/LiteTest.php | https://github.com/browscap/browscap/blob/master/tests/UserAgentsTest/V4/LiteTest.php | MIT |
public static function tearDownAfterClass(): void
{
if (empty(self::$coveredPatterns)) {
return;
}
$coverageProcessor = new Processor(__DIR__ . '/../../../resources/user-agents/');
$coverageProcessor->process(self::$coveredPatterns);
$coverageProcessor->write(__DIR__ . '/../../../coverage-lite4.json');
} | Runs after the entire test suite is run. Generates a coverage report for JSON resource files if
the $coveredPatterns array isn't empty
@throws JsonException
@throws RuntimeException
@throws DirectoryNotFoundException | tearDownAfterClass | php | browscap/browscap | tests/UserAgentsTest/V4/LiteTest.php | https://github.com/browscap/browscap/blob/master/tests/UserAgentsTest/V4/LiteTest.php | MIT |
public static function userAgentDataProvider(): array
{
[$data, $errors] = (new IteratorHelper())->getTestFiles(new NullLogger(), 'lite');
if (! empty($errors)) {
throw new RuntimeException(
'Errors occured while collecting test files' . PHP_EOL . implode(PHP_EOL, $errors),
);
}
return $data;
} | @return array<string, array<string, bool|int|string>|bool|string>
@phpstan-return array<string, array{ua: string, properties: array<string, string|int|bool>, lite: bool, standard: bool, full: bool}>
@throws RuntimeException | userAgentDataProvider | php | browscap/browscap | tests/UserAgentsTest/V4/LiteTest.php | https://github.com/browscap/browscap/blob/master/tests/UserAgentsTest/V4/LiteTest.php | MIT |
public function testUserAgents(string $userAgent, array $expectedProperties): void
{
if (! count($expectedProperties)) {
static::markTestSkipped('Could not run test - no properties were defined to test');
}
$actualProps = (array) self::$browscap->getBrowser($userAgent);
if (isset($actualProps['PatternId']) && is_string($actualProps['PatternId'])) {
self::$coveredPatterns[] = $actualProps['PatternId'];
}
foreach ($expectedProperties as $propName => $propValue) {
if (! is_string($propName) || ! self::$filter->isOutputProperty($propName, self::$writer)) {
continue;
}
assert(array_key_exists('browser_name_pattern', $actualProps) && is_scalar($actualProps['browser_name_pattern']));
static::assertFalse(
self::$propertyHolder->isDeprecatedProperty($propName),
'Actual result expects to test for deprecated property "' . $propName . '"'
. '; used pattern: "' . $actualProps['browser_name_pattern'] . '")',
);
static::assertArrayHasKey(
$propName,
$actualProps,
'Actual result does not have "' . $propName . '" property'
. '; used pattern: "' . $actualProps['browser_name_pattern'] . '")',
);
assert(array_key_exists($propName, $actualProps), sprintf('Property %s does not exist', $propName));
assert(is_scalar($actualProps[$propName]), get_debug_type($actualProps[$propName]));
static::assertSame(
$propValue,
$actualProps[$propName],
'Expected actual "' . $propName . '" to be "' . $propValue . '" (was "' . $actualProps[$propName]
. '"; used pattern: "' . $actualProps['browser_name_pattern'] . '")',
);
}
} | @param array<string> $expectedProperties
@throws Exception
@throws \BrowscapPHP\Exception
@dataProvider userAgentDataProvider
@coversNothing | testUserAgents | php | browscap/browscap | tests/UserAgentsTest/V4/LiteTest.php | https://github.com/browscap/browscap/blob/master/tests/UserAgentsTest/V4/LiteTest.php | MIT |
public function log($level, $message, array $context = []): void
{
assert(is_string($level));
echo '[', $level, '] ', $message, PHP_EOL;
} | @param mixed $level
@param string $message
@param mixed[] $context
@phpcsSuppress SlevomatCodingStandard.TypeHints.ParameterTypeHint.MissingNativeTypeHint | log | php | browscap/browscap | tests/UserAgentsTest/V4/StandardTest.php | https://github.com/browscap/browscap/blob/master/tests/UserAgentsTest/V4/StandardTest.php | MIT |
public function debug($message, array $context = []): void
{
// do nothing here
} | @param string $message
@param mixed[] $context
@phpcsSuppress SlevomatCodingStandard.TypeHints.ParameterTypeHint.MissingNativeTypeHint | debug | php | browscap/browscap | tests/UserAgentsTest/V4/StandardTest.php | https://github.com/browscap/browscap/blob/master/tests/UserAgentsTest/V4/StandardTest.php | MIT |
public function info($message, array $context = []): void
{
// do nothing here
} | @param string $message
@param mixed[] $context
@phpcsSuppress SlevomatCodingStandard.TypeHints.ParameterTypeHint.MissingNativeTypeHint | info | php | browscap/browscap | tests/UserAgentsTest/V4/StandardTest.php | https://github.com/browscap/browscap/blob/master/tests/UserAgentsTest/V4/StandardTest.php | MIT |
public static function tearDownAfterClass(): void
{
if (empty(self::$coveredPatterns)) {
return;
}
$coverageProcessor = new Processor(__DIR__ . '/../../../resources/user-agents/');
$coverageProcessor->process(self::$coveredPatterns);
$coverageProcessor->write(__DIR__ . '/../../../coverage-standard4.json');
} | Runs after the entire test suite is run. Generates a coverage report for JSON resource files if
the $coveredPatterns array isn't empty
@throws JsonException
@throws RuntimeException
@throws DirectoryNotFoundException | tearDownAfterClass | php | browscap/browscap | tests/UserAgentsTest/V4/StandardTest.php | https://github.com/browscap/browscap/blob/master/tests/UserAgentsTest/V4/StandardTest.php | MIT |
public static function userAgentDataProvider(): array
{
[$data, $errors] = (new IteratorHelper())->getTestFiles(new NullLogger(), 'standard');
if (! empty($errors)) {
throw new RuntimeException(
'Errors occured while collecting test files' . PHP_EOL . implode(PHP_EOL, $errors),
);
}
return $data;
} | @return array<string, array<string, bool|int|string>|bool|string>
@phpstan-return array<string, array{ua: string, properties: array<string, string|int|bool>, lite: bool, standard: bool, full: bool}>
@throws RuntimeException | userAgentDataProvider | php | browscap/browscap | tests/UserAgentsTest/V4/StandardTest.php | https://github.com/browscap/browscap/blob/master/tests/UserAgentsTest/V4/StandardTest.php | MIT |
public function testUserAgents(string $userAgent, array $expectedProperties): void
{
if (! count($expectedProperties)) {
static::markTestSkipped('Could not run test - no properties were defined to test');
}
$actualProps = (array) self::$browscap->getBrowser($userAgent);
if (isset($actualProps['PatternId']) && is_string($actualProps['PatternId'])) {
self::$coveredPatterns[] = $actualProps['PatternId'];
}
foreach ($expectedProperties as $propName => $propValue) {
if (! is_string($propName) || ! self::$filter->isOutputProperty($propName, self::$writer)) {
continue;
}
assert(array_key_exists('browser_name_pattern', $actualProps) && is_scalar($actualProps['browser_name_pattern']));
static::assertFalse(
self::$propertyHolder->isDeprecatedProperty($propName),
'Actual result expects to test for deprecated property "' . $propName . '"'
. '; used pattern: "' . $actualProps['browser_name_pattern'] . '")',
);
static::assertArrayHasKey(
$propName,
$actualProps,
'Actual result does not have "' . $propName . '" property'
. '; used pattern: "' . $actualProps['browser_name_pattern'] . '")',
);
assert(array_key_exists($propName, $actualProps), sprintf('Property %s does not exist', $propName));
assert(is_scalar($actualProps[$propName]), get_debug_type($actualProps[$propName]));
static::assertSame(
$propValue,
$actualProps[$propName],
'Expected actual "' . $propName . '" to be "' . $propValue . '" (was "' . $actualProps[$propName]
. '"; used pattern: "' . $actualProps['browser_name_pattern'] . '")',
);
}
} | @param array<string> $expectedProperties
@throws Exception
@throws \BrowscapPHP\Exception
@dataProvider userAgentDataProvider
@coversNothing | testUserAgents | php | browscap/browscap | tests/UserAgentsTest/V4/StandardTest.php | https://github.com/browscap/browscap/blob/master/tests/UserAgentsTest/V4/StandardTest.php | MIT |
public function subscriptions()
{
return $this->morphMany(Subscription::class, 'owner');
} | Get all of the subscriptions for the billable model.
@return \Illuminate\Database\Eloquent\Relations\HasMany | subscriptions | php | laravel/cashier-mollie | src/Billable.php | https://github.com/laravel/cashier-mollie/blob/master/src/Billable.php | MIT |
public function subscription($subscription = 'default')
{
return $this->subscriptions->sortByDesc(function ($value) {
return $value->created_at->getTimestamp();
})
->first(function ($value) use ($subscription) {
return $value->name === $subscription;
});
} | Get a subscription instance by name for the billable model.
@param string $subscription
@return \Laravel\Cashier\Subscription|null | subscription | php | laravel/cashier-mollie | src/Billable.php | https://github.com/laravel/cashier-mollie/blob/master/src/Billable.php | MIT |
public function newSubscription($subscription, $plan, $firstPaymentOptions = [])
{
if (! empty($this->mollie_mandate_id)) {
$mandate = $this->mollieMandate();
$planModel = app(PlanRepository::class)::findOrFail($plan);
$method = MandateMethod::getForFirstPaymentMethod($planModel->firstPaymentMethod());
if (
! empty($mandate)
&& $mandate->isValid()
&& $mandate->method === $method
) {
return $this->newSubscriptionForMandateId($this->mollie_mandate_id, $subscription, $plan);
}
}
return $this->newSubscriptionViaMollieCheckout($subscription, $plan, $firstPaymentOptions);
} | Begin creating a new subscription. If necessary, the customer will be redirected to Mollie's checkout
to perform a first mandate payment.
@param string $subscription
@param string $plan
@param array $firstPaymentOptions
@return \Laravel\Cashier\SubscriptionBuilder\Contracts\SubscriptionBuilder
@throws \Laravel\Cashier\Exceptions\InvalidMandateException
@throws \Laravel\Cashier\Exceptions\PlanNotFoundException
@throws \Throwable | newSubscription | php | laravel/cashier-mollie | src/Billable.php | https://github.com/laravel/cashier-mollie/blob/master/src/Billable.php | MIT |
public function newSubscriptionViaMollieCheckout($subscription, $plan, $firstPaymentOptions = [])
{
return new FirstPaymentSubscriptionBuilder($this, $subscription, $plan, $firstPaymentOptions);
} | Begin creating a new subscription. The customer will always be redirected to Mollie's checkout to make the first
mandate payment.
@param $subscription
@param $plan
@param array $firstPaymentOptions
@return \Laravel\Cashier\SubscriptionBuilder\FirstPaymentSubscriptionBuilder
@throws \Laravel\Cashier\Exceptions\PlanNotFoundException | newSubscriptionViaMollieCheckout | php | laravel/cashier-mollie | src/Billable.php | https://github.com/laravel/cashier-mollie/blob/master/src/Billable.php | MIT |
public function newSubscriptionForMandateId($mandateId, $subscription, $plan)
{
// The mandateId has changed
if ($this->mollie_mandate_id !== $mandateId) {
$this->mollie_mandate_id = $mandateId;
$this->guardMollieMandate();
$this->save();
}
return new MandatedSubscriptionBuilder($this, $subscription, $plan);
} | Begin creating a new subscription using an existing mandate.
@param string $mandateId
@param string $subscription
@param string $plan
@return \Laravel\Cashier\SubscriptionBuilder\MandatedSubscriptionBuilder
@throws \Laravel\Cashier\Exceptions\PlanNotFoundException
@throws \Throwable|\Laravel\Cashier\Exceptions\InvalidMandateException | newSubscriptionForMandateId | php | laravel/cashier-mollie | src/Billable.php | https://github.com/laravel/cashier-mollie/blob/master/src/Billable.php | MIT |
public function mollieCustomerId()
{
if (empty($this->mollie_customer_id)) {
return $this->createAsMollieCustomer()->id;
}
return $this->mollie_customer_id;
} | Retrieve the Mollie customer ID for this model
@return string | mollieCustomerId | php | laravel/cashier-mollie | src/Billable.php | https://github.com/laravel/cashier-mollie/blob/master/src/Billable.php | MIT |
public function createAsMollieCustomer(array $override_options = [])
{
$options = array_merge($this->mollieCustomerFields(), $override_options);
/** @var CreateMollieCustomer $createMollieCustomer */
$createMollieCustomer = app()->make(CreateMollieCustomer::class);
$customer = $createMollieCustomer->execute($options);
$this->mollie_customer_id = $customer->id;
$this->save();
return $customer;
} | Create a Mollie customer for the billable model.
@param array $override_options
@return Customer | createAsMollieCustomer | php | laravel/cashier-mollie | src/Billable.php | https://github.com/laravel/cashier-mollie/blob/master/src/Billable.php | MIT |
public function asMollieCustomer()
{
if (empty($this->mollie_customer_id)) {
return $this->createAsMollieCustomer();
}
/** @var GetMollieCustomer $getMollieCustomer */
$getMollieCustomer = app()->make(GetMollieCustomer::class);
return $getMollieCustomer->execute($this->mollie_customer_id);
} | Fetch the Mollie Customer for the billable model.
@return Customer | asMollieCustomer | php | laravel/cashier-mollie | src/Billable.php | https://github.com/laravel/cashier-mollie/blob/master/src/Billable.php | MIT |
public function onTrial($subscription = 'default', $plan = null)
{
if (func_num_args() === 0 && $this->onGenericTrial()) {
return true;
}
$subscription = $this->subscription($subscription);
if (is_null($plan)) {
return $subscription && $subscription->onTrial();
}
return $subscription && $subscription->onTrial() &&
$subscription->plan === $plan;
} | Determine if the billable model is on trial.
@param string $subscription
@param string|null $plan
@return bool | onTrial | php | laravel/cashier-mollie | src/Billable.php | https://github.com/laravel/cashier-mollie/blob/master/src/Billable.php | MIT |
public function onGenericTrial()
{
return $this->trial_ends_at && $this->trial_ends_at->isFuture();
} | Determine if the billable model is on a "generic" trial.
@return bool | onGenericTrial | php | laravel/cashier-mollie | src/Billable.php | https://github.com/laravel/cashier-mollie/blob/master/src/Billable.php | MIT |
public function cancelGenericTrial()
{
if ($this->onGenericTrial()) {
$this->forceFill(['trial_ends_at' => now()])->save();
}
return $this;
} | Cancel the generic trial if active.
@return $this | cancelGenericTrial | php | laravel/cashier-mollie | src/Billable.php | https://github.com/laravel/cashier-mollie/blob/master/src/Billable.php | MIT |
public function subscribed($subscription = 'default', $plan = null)
{
$subscription = $this->subscription($subscription);
if (is_null($subscription)) {
return false;
}
if (is_null($plan)) {
return $subscription->valid();
}
return $subscription->valid() &&
$subscription->plan === $plan;
} | Determine if the billable model has a given subscription.
@param string $subscription
@param string|null $plan
@return bool | subscribed | php | laravel/cashier-mollie | src/Billable.php | https://github.com/laravel/cashier-mollie/blob/master/src/Billable.php | MIT |
public function subscribedToPlan($plans, $subscription = 'default')
{
$subscription = $this->subscription($subscription);
if (! $subscription || ! $subscription->valid()) {
return false;
}
foreach ((array) $plans as $plan) {
if ($subscription->plan === $plan) {
return true;
}
}
return false;
} | @param $plans
@param string $subscription
@return bool | subscribedToPlan | php | laravel/cashier-mollie | src/Billable.php | https://github.com/laravel/cashier-mollie/blob/master/src/Billable.php | MIT |
public function orders()
{
return $this->morphMany(Order::class, 'owner');
} | Get all of the Orders for the billable model.
@return \Illuminate\Database\Eloquent\Relations\MorphMany | orders | php | laravel/cashier-mollie | src/Billable.php | https://github.com/laravel/cashier-mollie/blob/master/src/Billable.php | MIT |
public function orderItems()
{
return $this->morphMany(OrderItem::class, 'owner');
} | Get all of the Order Items for the billable model.
@return \Illuminate\Database\Eloquent\Relations\MorphMany | orderItems | php | laravel/cashier-mollie | src/Billable.php | https://github.com/laravel/cashier-mollie/blob/master/src/Billable.php | MIT |
public function credits()
{
return $this->morphMany(Credit::class, 'owner');
} | Get the balances for the billable model. A separate balance is kept for each currency.
@return \Illuminate\Database\Eloquent\Relations\MorphMany | credits | php | laravel/cashier-mollie | src/Billable.php | https://github.com/laravel/cashier-mollie/blob/master/src/Billable.php | MIT |
public function hasCredit($currency = null)
{
if (empty($currency)) {
return $this->credits()
->where('value', '<>', 0)
->exists();
}
return $this->credits()
->whereCurrency($currency)
->where('value', '<>', 0)
->exists();
} | Checks whether the billable model has a credit balance.
@param string|null $currency
@return bool | hasCredit | php | laravel/cashier-mollie | src/Billable.php | https://github.com/laravel/cashier-mollie/blob/master/src/Billable.php | MIT |
public function credit($currency)
{
$credit = $this->credits()->whereCurrency($currency)->first();
if (! $credit) {
$credit = $this->credits()->create([
'currency' => $currency,
'value' => 0,
]);
}
return $credit;
} | Retrieve the credit balance for the billable model for a specific currency.
@param $currency
@return \Illuminate\Database\Eloquent\Model | credit | php | laravel/cashier-mollie | src/Billable.php | https://github.com/laravel/cashier-mollie/blob/master/src/Billable.php | MIT |
public function addCredit(Money $amount)
{
Credit::addAmountForOwner($this, $amount);
return $this;
} | Add a credit amount for the billable model balance.
@param \Money\Money $amount
@return $this | addCredit | php | laravel/cashier-mollie | src/Billable.php | https://github.com/laravel/cashier-mollie/blob/master/src/Billable.php | MIT |
public function maxOutCredit(Money $amount)
{
return Credit::maxOutForOwner($this, $amount);
} | Use this model's max amount of credit.
@param \Money\Money $amount
@return Money | maxOutCredit | php | laravel/cashier-mollie | src/Billable.php | https://github.com/laravel/cashier-mollie/blob/master/src/Billable.php | MIT |
public function taxPercentage()
{
return $this->tax_percentage ?? 0;
} | Get the tax percentage to apply to the subscription.
@example 20 (for 20%)
@return float | taxPercentage | php | laravel/cashier-mollie | src/Billable.php | https://github.com/laravel/cashier-mollie/blob/master/src/Billable.php | MIT |
public function invoices()
{
return $this->orders->invoices();
} | Get the invoice instances for this model.
@return \Illuminate\Database\Eloquent\Collection | invoices | php | laravel/cashier-mollie | src/Billable.php | https://github.com/laravel/cashier-mollie/blob/master/src/Billable.php | MIT |
public function downloadInvoice($orderId, $data = [], $view = Invoice::DEFAULT_VIEW, Options $options = null)
{
/** @var Order $order */
$order = $this->orders()->where('id', $orderId)->firstOrFail();
return $order->invoice()->download($data, $view, $options);
} | Create an invoice download response.
@param $orderId
@param null|array $data
@param string $view
@param \Dompdf\Options $options
@return \Symfony\Component\HttpFoundation\Response | downloadInvoice | php | laravel/cashier-mollie | src/Billable.php | https://github.com/laravel/cashier-mollie/blob/master/src/Billable.php | MIT |
public function mollieMandate()
{
$mandateId = $this->mollieMandateId();
if (! empty($mandateId)) {
$customer = $this->asMollieCustomer();
try {
/** @var GetMollieMandate $getMollieMandate */
$getMollieMandate = app()->make(GetMollieMandate::class);
return $getMollieMandate->execute($customer->id, $mandateId);
} catch (ApiException $e) {
// Status 410: mandate was revoked
if (! $e->getCode() == 410) {
throw $e;
}
}
}
return null;
} | Retrieve the Mollie Mandate for the billable model.
@return \Mollie\Api\Resources\Mandate|null
@throws \Mollie\Api\Exceptions\ApiException | mollieMandate | php | laravel/cashier-mollie | src/Billable.php | https://github.com/laravel/cashier-mollie/blob/master/src/Billable.php | MIT |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.