aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests/Wallabag
diff options
context:
space:
mode:
Diffstat (limited to 'tests/Wallabag')
-rw-r--r--tests/Wallabag/CoreBundle/GuzzleSiteAuthenticator/GrabySiteConfigBuilderTest.php40
1 files changed, 27 insertions, 13 deletions
diff --git a/tests/Wallabag/CoreBundle/GuzzleSiteAuthenticator/GrabySiteConfigBuilderTest.php b/tests/Wallabag/CoreBundle/GuzzleSiteAuthenticator/GrabySiteConfigBuilderTest.php
index 8341b11f..8b50bce9 100644
--- a/tests/Wallabag/CoreBundle/GuzzleSiteAuthenticator/GrabySiteConfigBuilderTest.php
+++ b/tests/Wallabag/CoreBundle/GuzzleSiteAuthenticator/GrabySiteConfigBuilderTest.php
@@ -2,6 +2,8 @@
2 2
3namespace Tests\Wallabag\CoreBundle\GuzzleSiteAuthenticator; 3namespace Tests\Wallabag\CoreBundle\GuzzleSiteAuthenticator;
4 4
5use Monolog\Handler\TestHandler;
6use Monolog\Logger;
5use BD\GuzzleSiteAuthenticator\SiteConfig\SiteConfig; 7use BD\GuzzleSiteAuthenticator\SiteConfig\SiteConfig;
6use Graby\SiteConfig\SiteConfig as GrabySiteConfig; 8use Graby\SiteConfig\SiteConfig as GrabySiteConfig;
7use PHPUnit_Framework_TestCase; 9use PHPUnit_Framework_TestCase;
@@ -32,14 +34,19 @@ class GrabySiteConfigBuilderTest extends PHPUnit_Framework_TestCase
32 ->with('example.com') 34 ->with('example.com')
33 ->will($this->returnValue($grabySiteConfig)); 35 ->will($this->returnValue($grabySiteConfig));
34 36
37 $logger = new Logger('foo');
38 $handler = new TestHandler();
39 $logger->pushHandler($handler);
40
35 $this->builder = new GrabySiteConfigBuilder( 41 $this->builder = new GrabySiteConfigBuilder(
36 $grabyConfigBuilderMock, 42 $grabyConfigBuilderMock,
37 ['example.com' => ['username' => 'foo', 'password' => 'bar']] 43 ['example.com' => ['username' => 'foo', 'password' => 'bar']],
44 $logger
38 ); 45 );
39 46
40 $config = $this->builder->buildForHost('example.com'); 47 $config = $this->builder->buildForHost('example.com');
41 48
42 self::assertEquals( 49 $this->assertEquals(
43 new SiteConfig([ 50 new SiteConfig([
44 'host' => 'example.com', 51 'host' => 'example.com',
45 'requiresLogin' => true, 52 'requiresLogin' => true,
@@ -53,6 +60,10 @@ class GrabySiteConfigBuilderTest extends PHPUnit_Framework_TestCase
53 ]), 60 ]),
54 $config 61 $config
55 ); 62 );
63
64 $records = $handler->getRecords();
65
66 $this->assertCount(1, $records, 'One log was recorded');
56 } 67 }
57 68
58 public function testBuildConfigDoesntExist() 69 public function testBuildConfigDoesntExist()
@@ -67,19 +78,22 @@ class GrabySiteConfigBuilderTest extends PHPUnit_Framework_TestCase
67 ->with('unknown.com') 78 ->with('unknown.com')
68 ->will($this->returnValue(new GrabySiteConfig())); 79 ->will($this->returnValue(new GrabySiteConfig()));
69 80
70 $this->builder = new GrabySiteConfigBuilder($grabyConfigBuilderMock, []); 81 $logger = new Logger('foo');
82 $handler = new TestHandler();
83 $logger->pushHandler($handler);
84
85 $this->builder = new GrabySiteConfigBuilder(
86 $grabyConfigBuilderMock,
87 [],
88 $logger
89 );
71 90
72 $config = $this->builder->buildForHost('unknown.com'); 91 $config = $this->builder->buildForHost('unknown.com');
73 92
74 self::assertEquals( 93 $this->assertFalse($config);
75 new SiteConfig([ 94
76 'host' => 'unknown.com', 95 $records = $handler->getRecords();
77 'requiresLogin' => false, 96
78 'username' => null, 97 $this->assertCount(1, $records, 'One log was recorded');
79 'password' => null,
80 'extraFields' => [],
81 ]),
82 $config
83 );
84 } 98 }
85} 99}