<commit_before><?php

namespace SlackPHP\Tests\SlackAPI\Models\Abstracts;

use PHPUnit\Framework\TestCase;
use SlackPHP\SlackAPI\Models\Methods\ChatUpdate;
use SlackPHP\SlackAPI\Enumerators\Method;
use SlackPHP\SlackAPI\Models\Abstracts\AbstractPayload;
use SlackPHP\SlackAPI\Exceptions\SlackException;
use SlackPHP\Tests\SlackAPI\TestObjects\MockAbstractPayload;

/**
 * @author <NAME> <<EMAIL>>
 * @author Zxurian
 * @covers AbstractPayload
 */
class AbstractPayloadTest extends TestCase
{
    private $dummyString = 'String';
    
    /**
     * Test for setting token
     */
    public function testSettingToken()
    {
        $chatUpdateObject = new ChatUpdate();
        $chatUpdateObject->setToken($this->dummyString);
        $refChatUpdateObject = new \ReflectionObject($chatUpdateObject);
        $tokenProperty = $refChatUpdateObject->getProperty('token');
        $tokenProperty->setAccessible(true);
        
        $this->assertEquals($this->dummyString, $tokenProperty->getValue($chatUpdateObject));
    }

    /**
     * Test for setting invalid token
     */
    public function testSettingInvalidToken()
    {
        $this->expectException(\InvalidArgumentException::class);
        $chatUpdateObject = new ChatUpdate();
        $chatUpdateObject->setToken(null);
    }
    
    public function testGetResponseClass()
    {
        $chatUpdateObject = new ChatUpdate();
        
        $this->assertEquals(get_class($chatUpdateObject).'Response', $chatUpdateObject->getResponseClass());
    }
    
    /**
     * Test for getting API method from payload
     */
    public function testGetMethod()
    {
        $chatUpdateObject = new ChatUpdate();
        
        $this->assertEquals(Method::CHAT_UPDATE(), $chatUpdateObject->getMethod());
    }
    
    /**
     * Test for successful validation of model
     */
    public function testConvertToWebAPIArray()
    {
        $stub = $this->getMockForAbstractClass(AbstractPayload::class);<commit_msg>adding test for serializer<commit_after><?php

namespace SlackPHP\Tests\SlackAPI\Models\Abstracts;

use PHPUnit\Framework\TestCase;
use SlackPHP\SlackAPI\Models\Methods\ChatUpdate;
use SlackPHP\SlackAPI\Enumerators\Method;
use SlackPHP\SlackAPI\Models\Abstracts\AbstractPayload;
use SlackPHP\SlackAPI\Exceptions\SlackException;
use SlackPHP\Tests\SlackAPI\TestObjects\MockAbstractPayload;
use JMS\Serializer\Serializer;

/**
 * @author <NAME> <<EMAIL>>
 * @author Zxurian
 * @covers AbstractPayload
 */
class AbstractPayloadTest extends TestCase
{
    private $dummyString = 'String';
    
    /**
     * Test for setting token
     */
    public function testSettingToken()
    {
        $chatUpdateObject = new ChatUpdate();
        $chatUpdateObject->setToken($this->dummyString);
        $refChatUpdateObject = new \ReflectionObject($chatUpdateObject);
        $tokenProperty = $refChatUpdateObject->getProperty('token');
        $tokenProperty->setAccessible(true);
        
        $this->assertEquals($this->dummyString, $tokenProperty->getValue($chatUpdateObject));
    }

    /**
     * Test for setting invalid token
     */
    public function testSettingInvalidToken()
    {
        $this->expectException(\InvalidArgumentException::class);
        $chatUpdateObject = new ChatUpdate();
        $chatUpdateObject->setToken(null);
    }
    
    public function testGetResponseClass()
    {
        $chatUpdateObject = new ChatUpdate();
        
        $this->assertEquals(get_class($chatUpdateObject).'Response', $chatUpdateObject->getResponseClass());
    }
    
    /**
     * Test for getting API method from payload
     */
    public function testGetMethod()
    {
        $chatUpdateObject = new ChatUpdate();
        
        $this->assertEquals(Method::CHAT_UPDATE(), $chatUpdateObject->getMethod());
    }
    
    /** 
     * Test for getting serializer
     */
    public function testGetSerializer()
    {
        $stub = $this->getMockForAbstractClass(AbstractPayload::class);
        
        $this->assertInstanceOf(Serializer::class, $stub->getSerializer());
    }
    
    /**
     * Test for successful validation of model
     */
    public function testConvertToWebAPIArray()
    {
        $stub = $this->getMockForAbstractClass(AbstractPayload::class);
{'fraction_non_alphanumeric': 0.11614265603003285, 'fraction_numerical': 0.0, 'mean_word_length': 3.2082922013820334, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 40, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2556738', 'n_tokens_mistral': 1163, 'n_tokens_neox': 1167, 'n_words': 205}