-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add __call magic method, tests. Closes #22
- Loading branch information
Showing
3 changed files
with
80 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
<?php namespace IdeasOnPurpose\WP; | ||
|
||
use PHPUnit\Framework\TestCase; | ||
use IdeasOnPurpose\WP\Test; | ||
|
||
Test\Stubs::init(); | ||
/** | ||
/** | ||
* @covers \IdeasOnPurpose\WP\SVG | ||
*/ | ||
final class MagicMethodTest extends TestCase | ||
{ | ||
public $SVG; | ||
|
||
public function setUp(): void | ||
{ | ||
$this->SVG = new SVG(); | ||
} | ||
|
||
/** | ||
* Test magic methods for embedding SVGs | ||
* | ||
* Exact matches should work when quoted. | ||
* All names should also be directly callable using camelCase | ||
*/ | ||
public function testMagicGet() | ||
{ | ||
$arrow = $this->SVG->arrow; | ||
$this->assertStringContainsString('<svg', $arrow); | ||
} | ||
|
||
/** | ||
* Test magic methods for embedding SVGs | ||
* | ||
* Exact matches should work when quoted. | ||
* All names should also be directly callable using camelCase | ||
*/ | ||
public function testMagicCall() | ||
{ | ||
$widthArg = ['width' => 25]; | ||
|
||
$svg = $this->getMockBuilder('\IdeasOnPurpose\WP\SVG') | ||
->disableOriginalConstructor() | ||
->onlyMethods(['fetch']) | ||
->getMock(); | ||
|
||
$svg->expects($this->once()) | ||
->method('fetch') | ||
->with($this->equalTo('arrow'), $this->equalTo($widthArg)); | ||
|
||
$svg->arrow($widthArg); | ||
// $this->assertStringContainsString('<svg', $arrow); | ||
// $this->assertStringContainsString('width="25"', $arrow); | ||
} | ||
|
||
public function testMagicCallNoAttributes() | ||
{ | ||
$svg = $this->getMockBuilder('\IdeasOnPurpose\WP\SVG') | ||
->disableOriginalConstructor() | ||
->onlyMethods(['fetch']) | ||
->getMock(); | ||
|
||
$svg->expects($this->once()) | ||
->method('fetch') | ||
->with($this->equalTo('arrow'), $this->equalTo([])); | ||
|
||
$svg->arrow(); | ||
} | ||
} |